Don't show "Manage Locations" tab if the theme has no menu locations defined. props DrewAPicture. fixes #24115.

git-svn-id: http://core.svn.wordpress.org/trunk@24217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2013-05-09 02:43:26 +00:00
parent a7fd4ea020
commit 8c8a8d6e0d
1 changed files with 9 additions and 2 deletions

View File

@ -351,6 +351,11 @@ switch ( $action ) {
} }
break; break;
case 'locations': case 'locations':
if ( ! $num_locations ) {
wp_redirect( admin_url( 'nav-menus.php' ) );
exit();
}
add_filter( 'screen_options_show_screen', '__return_false' ); add_filter( 'screen_options_show_screen', '__return_false' );
if ( isset( $_POST['menu-locations'] ) ) { if ( isset( $_POST['menu-locations'] ) ) {
@ -466,7 +471,7 @@ add_filter('admin_body_class', 'wp_nav_menu_max_depth');
wp_nav_menu_setup(); wp_nav_menu_setup();
wp_initial_nav_menu_meta_boxes(); wp_initial_nav_menu_meta_boxes();
if ( ! current_theme_supports( 'menus' ) && ! wp_get_nav_menus() ) if ( ! current_theme_supports( 'menus' ) && ! $num_locations )
$messages[] = '<div id="message" class="updated"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>'; $messages[] = '<div id="message" class="updated"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>';
if ( ! $locations_screen ) : // Main tab if ( ! $locations_screen ) : // Main tab
@ -532,7 +537,9 @@ require_once( './admin-header.php' );
<?php screen_icon(); ?> <?php screen_icon(); ?>
<h2 class="nav-tab-wrapper"> <h2 class="nav-tab-wrapper">
<a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a> <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a>
<a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a> <?php if ( $num_locations && $menu_count ) : ?>
<a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a>
<?php endif; ?>
</h2> </h2>
<?php <?php
foreach( $messages as $message ) : foreach( $messages as $message ) :