Don't show an error when the theme supports widgets but not menus. see #13825.

git-svn-id: https://develop.svn.wordpress.org/trunk@15191 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-06-10 17:37:15 +00:00
parent 9d38c0af9e
commit 5dcf82f22f
2 changed files with 13 additions and 14 deletions

View File

@ -365,7 +365,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
**/
function wp_nav_menu_setup() {
// Register meta boxes
if ( get_registered_nav_menus() && wp_get_nav_menus() )
if ( ( current_theme_supports( 'widgets' ) || get_registered_nav_menus() ) && wp_get_nav_menus() )
add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );
add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
wp_nav_menu_post_type_meta_boxes();
@ -461,6 +461,13 @@ function wp_nav_menu_taxonomy_meta_boxes() {
function wp_nav_menu_locations_meta_box() {
global $nav_menu_selected_id;
$locations = get_registered_nav_menus();
if ( empty( $locations ) ) {
// We must only support widgets. Leave a message and bail.
echo '<p class="howto">' . __('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>';
return;
}
$menus = wp_get_nav_menus();
$menu_locations = get_nav_menu_locations();
$num_locations = count( array_keys($locations) );

View File

@ -248,7 +248,7 @@ switch ( $action ) {
} else {
// Remove this menu from any locations.
$locations = get_theme_mod( 'nav_menu_locations' );
foreach ( $locations as $location => $menu_id ) {
foreach ( (array) $locations as $location => $menu_id ) {
if ( $menu_id == $nav_menu_selected_id )
$locations[ $location ] = 0;
}
@ -430,20 +430,12 @@ foreach( (array) $nav_menus as $key => $_nav_menu ) {
$nav_menus[$key]->truncated_name = $_nav_menu->truncated_name;
}
// The theme supports menus
if ( current_theme_supports('nav-menus') ) {
// Set up nav menu
wp_nav_menu_setup();
// The theme does not support menus but supports widgets
} elseif ( current_theme_supports('widgets') ) {
// Set up nav menu
wp_nav_menu_setup();
$messages[] = '<div id="message" class="error"><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>';
}
wp_nav_menu_setup();
wp_initial_nav_menu_meta_boxes();
if ( ! get_registered_nav_menus() && ! wp_get_nav_menus() )
echo '<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>';
$help = '<p>' . __('This feature is new in version 3.0; to use a custom menu in place of your theme&#8217;s default menus, support for this feature must be registered in the theme&#8217;s functions.php file. If your theme does not support the custom menus feature yet (the new default theme, Twenty Ten, does), you can learn about adding support yourself by following the below link.') . '</p>';
$help .= '<p>' . __('You can create custom menus for your site. These menus may contain links to pages, categories, custom links or other content types (use the Screen Options tab to decide which ones to show on the screen). You can specify a different navigation label for a menu item as well as other attributes. You can create multiple menus. If your theme includes more than one menu, you can choose which custom menu to associate with each. You can also use custom menus in conjunction with the Custom Menus widget.') . '</p>';
$help .= '<p>' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You&#8217;ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. You&#8217;ll see when the position of the drop target shifts over to create the nested placement. Don&#8217;t forget to click Save when you&#8217;re finished.') . '</p>';