????
| Current Path : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/classes/ |
| Current File : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/classes/attachment-fields.php |
<?php
/**
* Adds new fields for the media items
*
* @package Wanderfuls WordPress Theme
* @subpackage Framework
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Start Class
class TB_Media_Fields {
/**
* Main constructor
*
* @since 2.0.0
*/
public function __construct() {
add_filter( 'attachment_fields_to_edit', array( $this, 'edit_fields' ), null, 2 );
add_filter( 'attachment_fields_to_save', array( $this, 'save_fields' ), null , 2 );
}
/**
* Adds new edit attachment fields
*
* @since 2.0.0
*/
public function edit_fields( $form_fields, $post ) {
$form_fields['tb_video_url'] = array(
'label' => __( 'Video URL', 'tb' ),
'input' => 'text',
'value' => get_post_meta( $post->ID, '_video_url', true ),
);
return $form_fields;
}
/**
* Save new attachment fields
*
* @since 2.0.0
*/
public function save_fields( $post, $attachment ) {
if ( isset( $attachment['tb_video_url'] ) ) {
update_post_meta( $post['ID'], '_video_url', $attachment['tb_video_url'] );
}
return $post;
}
}
new TB_Media_Fields();