WordPress.org

Make WordPress Core

Ticket #13825: 13825.diff

File 13825.diff, 4.2 KB (added by nacin, 4 years ago)
  • wp-admin/nav-menus.php

     
    248248                        } else { 
    249249                                // Remove this menu from any locations. 
    250250                                $locations = get_theme_mod( 'nav_menu_locations' ); 
    251                                 foreach ( $locations as $location => $menu_id ) { 
     251                                foreach ( (array) $locations as $location => $menu_id ) { 
    252252                                        if ( $menu_id == $nav_menu_selected_id ) 
    253253                                                $locations[ $location ] = 0; 
    254254                                } 
     
    430430        $nav_menus[$key]->truncated_name = $_nav_menu->truncated_name; 
    431431} 
    432432 
    433 // The theme supports menus 
    434 if ( current_theme_supports('nav-menus') ) { 
    435         // Set up nav menu 
    436         wp_nav_menu_setup(); 
    437  
    438 // The theme does not support menus but supports widgets 
    439 } elseif ( current_theme_supports('widgets') ) { 
    440         // Set up nav menu 
    441         wp_nav_menu_setup(); 
    442         $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>'; 
    443 } 
    444  
     433wp_nav_menu_setup(); 
    445434wp_initial_nav_menu_meta_boxes(); 
    446435 
     436if ( ! get_registered_nav_menus() && ! wp_get_nav_menus() ) 
     437        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>'; 
     438 
    447439$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>'; 
    448440$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>'; 
    449441$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>'; 
  • wp-admin/includes/nav-menu.php

     
    365365 **/ 
    366366function wp_nav_menu_setup() { 
    367367        // Register meta boxes 
    368         if ( get_registered_nav_menus() && wp_get_nav_menus() ) 
     368        if ( ( current_theme_supports( 'widgets' ) || get_registered_nav_menus() ) && wp_get_nav_menus() ) 
    369369                add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' ); 
    370370        add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); 
    371371        wp_nav_menu_post_type_meta_boxes(); 
     
    461461function wp_nav_menu_locations_meta_box() { 
    462462        global $nav_menu_selected_id; 
    463463        $locations = get_registered_nav_menus(); 
     464 
     465        if ( empty( $locations ) ) { 
     466                // We must only support widgets. Leave a message and bail. 
     467                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>'; 
     468                return; 
     469        } 
     470 
    464471        $menus = wp_get_nav_menus(); 
    465472        $menu_locations = get_nav_menu_locations(); 
    466473        $num_locations = count( array_keys($locations) );