File: /home/dwauav0tm6jp/public_html/wp-content/themes/photographer-wp/admin/meta-box-sidebar.php
<?php
function pixelwars_theme_custom_box_show_sidebar( $post )
{
?>
<div class="admin-inside-box">
<?php
wp_nonce_field( 'pixelwars_theme_custom_box_show_sidebar', 'pixelwars_theme_custom_box_nonce_sidebar' );
?>
<p>
<?php
$my_sidebar = get_option( $post->ID . 'my_sidebar', 'pixelwars_page_sidebar' );
?>
<select name="my_sidebar">
<option <?php if ( $my_sidebar == 'pixelwars_page_sidebar' ) { echo 'selected="selected"'; } ?> value="pixelwars_page_sidebar"><?php echo __( 'Page Sidebar', 'read' ); ?></option>
<option <?php if ( $my_sidebar == 'pixelwars_blog_sidebar' ) { echo 'selected="selected"'; } ?> value="pixelwars_blog_sidebar"><?php echo __( 'Blog Sidebar', 'read' ); ?></option>
<?php
$sidebars_with_commas = get_option( 'sidebars_with_commas' );
if ( $sidebars_with_commas != "" )
{
$sidebars = preg_split( "/[\s]*[,][\s]*/", $sidebars_with_commas );
foreach ( $sidebars as $sidebar_name )
{
$selected = "";
if ( $my_sidebar == $sidebar_name )
{
$selected = 'selected="selected"';
}
echo '<option ' . $selected . ' value="' . $sidebar_name . '">' . $sidebar_name . '</option>';
}
}
?>
</select>
</p>
<p class="howto">
Select Page with Sidebar template.
</p>
</div>
<?php
}
function pixelwars_theme_custom_box_add_sidebar()
{
add_meta_box( 'pixelwars_theme_custom_box_sidebar', __( 'Sidebar', 'read' ), 'pixelwars_theme_custom_box_show_sidebar', 'page', 'side', 'low' );
}
add_action( 'add_meta_boxes', 'pixelwars_theme_custom_box_add_sidebar' );
function pixelwars_theme_custom_box_save_sidebar( $post_id )
{
if ( ! isset( $_POST['pixelwars_theme_custom_box_nonce_sidebar'] ) )
{
return $post_id;
}
$nonce = $_POST['pixelwars_theme_custom_box_nonce_sidebar'];
if ( ! wp_verify_nonce( $nonce, 'pixelwars_theme_custom_box_show_sidebar' ) )
{
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 . 'my_sidebar', $_POST['my_sidebar'] );
}
add_action( 'save_post', 'pixelwars_theme_custom_box_save_sidebar' );
?>