/*-----------------------------------------------------------------------------------
Add Post Format meta boxes
-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/* Define Metabox Fields
/*-----------------------------------------------------------------------------------*/
$prefix = 'tj_';
$meta_box_video = array(
'id' => 'tj-meta-box-video',
'title' => __('Video Settings', 'themejunkie'),
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array( "name" => __('Video Embed Code','themejunkie'),
"desc" => __('Here you could enter the video embed code.','themejunkie'),
"id" => $prefix."video_embed",
"type" => "textarea"
),
array( "name" => __('Video Thumbnail URL','themejunkie'),
"desc" => __('Specify an image here or set Featured Image as the video thumbnail. (best size: 216px x 120px)','themejunkie'),
"id" => $prefix."video_img_url",
"type" => "text",
)
)
);
add_action('admin_menu', 'tj_add_box');
/*-----------------------------------------------------------------------------------*/
/* Add metabox to edit page
/*-----------------------------------------------------------------------------------*/
function tj_add_box() {
global $meta_box_video;
add_meta_box($meta_box_video['id'], $meta_box_video['title'], 'tj_show_box_video', $meta_box_video['page'], $meta_box_video['context'], $meta_box_video['priority']);
}
function tj_show_box_video() {
global $meta_box_video, $post;
echo ''.__('You could fill the video details below.', 'themejunkie').'
';
// Use nonce for verification
echo '';
echo '';
foreach ($meta_box_video['fields'] as $field) {
// get current post meta data
$meta = get_post_meta($post->ID, $field['id'], true);
switch ($field['type']) {
//If Text
case 'text':
echo '',
' ',
'';
echo '';
break;
//If textarea
case 'textarea':
echo ' ',
' ',
'';
echo '';
break;
//If Button
case 'button':
echo '';
echo ' ',
' ';
break;
}
}
echo '
';
}
add_action('save_post', 'tj_save_data');
/*-- Save data when post is edited --*/
function tj_save_data($post_id) {
global $meta_box_video;
// verify nonce
if (!wp_verify_nonce($_POST['tj_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($meta_box_video['fields'] as $field) {
$old = get_post_meta($post_id, $field['id'], true);
$new = $_POST[$field['id']];
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new)));
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
}
}
}
/*-----------------------------------------------------------------------------------
Add Post Format meta boxes
-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/* Define Metabox Fields
/*-----------------------------------------------------------------------------------*/
$prefix = 'tj_';
$meta_box_video = array(
'id' => 'tj-meta-box-video',
'title' => __('Video Settings', 'themejunkie'),
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array( "name" => __('Video Embed Code','themejunkie'),
"desc" => __('Here you could enter the video embed code.','themejunkie'),
"id" => $prefix."video_embed",
"type" => "textarea"
),
array( "name" => __('Video Thumbnail URL','themejunkie'),
"desc" => __('Specify an image here or set Featured Image as the video thumbnail. (best size: 216px x 120px)','themejunkie'),
"id" => $prefix."video_img_url",
"type" => "text",
)
)
);
add_action('admin_menu', 'tj_add_box');
/*-----------------------------------------------------------------------------------*/
/* Add metabox to edit page
/*-----------------------------------------------------------------------------------*/
function tj_add_box() {
global $meta_box_video;
add_meta_box($meta_box_video['id'], $meta_box_video['title'], 'tj_show_box_video', $meta_box_video['page'], $meta_box_video['context'], $meta_box_video['priority']);
}
function tj_show_box_video() {
global $meta_box_video, $post;
echo ''.__('You could fill the video details below.', 'themejunkie').'
';
// Use nonce for verification
echo '';
echo '';
foreach ($meta_box_video['fields'] as $field) {
// get current post meta data
$meta = get_post_meta($post->ID, $field['id'], true);
switch ($field['type']) {
//If Text
case 'text':
echo '',
' ',
'';
echo '';
break;
//If textarea
case 'textarea':
echo ' ',
' ',
'';
echo '';
break;
//If Button
case 'button':
echo '';
echo ' ',
' ';
break;
}
}
echo '
';
}
add_action('save_post', 'tj_save_data');
/*-- Save data when post is edited --*/
function tj_save_data($post_id) {
global $meta_box_video;
// verify nonce
if (!wp_verify_nonce($_POST['tj_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($meta_box_video['fields'] as $field) {
$old = get_post_meta($post_id, $field['id'], true);
$new = $_POST[$field['id']];
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new)));
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
}
}
}
?>
/*-----------------------------------------------------------------------------------
Add Post Format meta boxes
-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/* Define Metabox Fields
/*-----------------------------------------------------------------------------------*/
$prefix = 'tj_';
$meta_box_video = array(
'id' => 'tj-meta-box-video',
'title' => __('Video Settings', 'themejunkie'),
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array( "name" => __('Video Embed Code','themejunkie'),
"desc" => __('Here you could enter the video embed code.','themejunkie'),
"id" => $prefix."video_embed",
"type" => "textarea"
),
array( "name" => __('Video Thumbnail URL','themejunkie'),
"desc" => __('Specify an image here or set Featured Image as the video thumbnail. (best size: 216px x 120px)','themejunkie'),
"id" => $prefix."video_img_url",
"type" => "text",
)
)
);
add_action('admin_menu', 'tj_add_box');
/*-----------------------------------------------------------------------------------*/
/* Add metabox to edit page
/*-----------------------------------------------------------------------------------*/
function tj_add_box() {
global $meta_box_video;
add_meta_box($meta_box_video['id'], $meta_box_video['title'], 'tj_show_box_video', $meta_box_video['page'], $meta_box_video['context'], $meta_box_video['priority']);
}
function tj_show_box_video() {
global $meta_box_video, $post;
echo ''.__('You could fill the video details below.', 'themejunkie').'
';
// Use nonce for verification
echo '';
echo '';
foreach ($meta_box_video['fields'] as $field) {
// get current post meta data
$meta = get_post_meta($post->ID, $field['id'], true);
switch ($field['type']) {
//If Text
case 'text':
echo '',
' ',
'';
echo '';
break;
//If textarea
case 'textarea':
echo ' ',
' ',
'';
echo '';
break;
//If Button
case 'button':
echo '';
echo ' ',
' ';
break;
}
}
echo '
';
}
add_action('save_post', 'tj_save_data');
/*-- Save data when post is edited --*/
function tj_save_data($post_id) {
global $meta_box_video;
// verify nonce
if (!wp_verify_nonce($_POST['tj_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($meta_box_video['fields'] as $field) {
$old = get_post_meta($post_id, $field['id'], true);
$new = $_POST[$field['id']];
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new)));
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
else
{
}
}
}
}
?>
/*-----------------------------------------------------------------------------------
Add Post Format meta boxes
-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/* Define Metabox Fields
/*-----------------------------------------------------------------------------------*/
$prefix = 'tj_';
$meta_box_video = array(
'id' => 'tj-meta-box-video',
'title' => __('Video Settings', 'themejunkie'),
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array( "name" => __('Video Embed Code','themejunkie'),
"desc" => __('Here you could enter the video embed code.','themejunkie'),
"id" => $prefix."video_embed",
"type" => "textarea"
),
array( "name" => __('Video Thumbnail URL','themejunkie'),
"desc" => __('Specify an image here or set Featured Image as the video thumbnail. (best size: 216px x 120px)','themejunkie'),
"id" => $prefix."video_img_url",
"type" => "text",
)
)
);
add_action('admin_menu', 'tj_add_box');
/*-----------------------------------------------------------------------------------*/
/* Add metabox to edit page
/*-----------------------------------------------------------------------------------*/
function tj_add_box() {
global $meta_box_video;
add_meta_box($meta_box_video['id'], $meta_box_video['title'], 'tj_show_box_video', $meta_box_video['page'], $meta_box_video['context'], $meta_box_video['priority']);
}
function tj_show_box_video() {
global $meta_box_video, $post;
echo ''.__('You could fill the video details below.', 'themejunkie').'
';
// Use nonce for verification
echo '';
echo '';
foreach ($meta_box_video['fields'] as $field) {
// get current post meta data
$meta = get_post_meta($post->ID, $field['id'], true);
switch ($field['type']) {
//If Text
case 'text':
echo '',
' ',
'';
echo '';
break;
//If textarea
case 'textarea':
echo ' ',
' ',
'';
echo '';
break;
//If Button
case 'button':
echo '';
echo ' ',
' ';
break;
}
}
echo '
';
}
add_action('save_post', 'tj_save_data');
/*-- Save data when post is edited --*/
function tj_save_data($post_id) {
global $meta_box_video;
// verify nonce
if (!wp_verify_nonce($_POST['tj_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($meta_box_video['fields'] as $field) {
$old = get_post_meta($post_id, $field['id'], true);
$new = $_POST[$field['id']];
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new)));
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
}
else{}
}
}