File: /home/dwauav0tm6jp/www/wp-content/themes/photographer-wp/admin/meta-box-title-visibility.php
<?php
function pixelwars_theme_custom_box_show_post_title_visibility( $post )
{
?>
<div class="admin-inside-box">
<?php
wp_nonce_field( 'pixelwars_theme_custom_box_show_post_title_visibility', 'pixelwars_theme_custom_box_nonce_post_title_visibility' );
?>
<p>
<?php
$hide_post_title = get_option( $post->ID . 'hide_post_title', false );
if ( $hide_post_title )
{
$hide_post_title_out = 'checked="checked"';
}
else
{
$hide_post_title_out = "";
}
?>
<label for="hide_post_title"><input type="checkbox" id="hide_post_title" name="hide_post_title" <?php echo $hide_post_title_out; ?>> Hide title</label>
</p>
</div>
<?php
}
function pixelwars_theme_custom_box_add_post_title_visibility()
{
add_meta_box( 'pixelwars_theme_custom_box_post_title_visibility_post', __( 'Title Visibility', 'read' ), 'pixelwars_theme_custom_box_show_post_title_visibility', 'post', 'side', 'high' );
add_meta_box( 'pixelwars_theme_custom_box_post_title_visibility_page', __( 'Title Visibility', 'read' ), 'pixelwars_theme_custom_box_show_post_title_visibility', 'page', 'side', 'high' );
}
add_action( 'add_meta_boxes', 'pixelwars_theme_custom_box_add_post_title_visibility' );
function pixelwars_theme_custom_box_save_post_title_visibility( $post_id )
{
if ( ! isset( $_POST['pixelwars_theme_custom_box_nonce_post_title_visibility'] ) )
{
return $post_id;
}
$nonce = $_POST['pixelwars_theme_custom_box_nonce_post_title_visibility'];
if ( ! wp_verify_nonce( $nonce, 'pixelwars_theme_custom_box_show_post_title_visibility' ) )
{
return $post_id;
}
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
{
return $post_id;
}
if ( 'page' == $_POST['post_type'] )
{
if ( ! current_user_can( 'edit_page', $post_id ) )
{
return $post_id;
}
}
else
{
if ( ! current_user_can( 'edit_post', $post_id ) )
{
return $post_id;
}
}
update_option( $post_id . 'hide_post_title', $_POST['hide_post_title'] );
}
add_action( 'save_post', 'pixelwars_theme_custom_box_save_post_title_visibility' );
?>