Don't show an error when the theme supports widgets but not menus. see #13825.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15191 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
af612805e8
commit
2010aac02c
|
@ -365,7 +365,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||||
**/
|
**/
|
||||||
function wp_nav_menu_setup() {
|
function wp_nav_menu_setup() {
|
||||||
// Register meta boxes
|
// 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( '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' );
|
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();
|
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() {
|
function wp_nav_menu_locations_meta_box() {
|
||||||
global $nav_menu_selected_id;
|
global $nav_menu_selected_id;
|
||||||
$locations = get_registered_nav_menus();
|
$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 “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$menus = wp_get_nav_menus();
|
$menus = wp_get_nav_menus();
|
||||||
$menu_locations = get_nav_menu_locations();
|
$menu_locations = get_nav_menu_locations();
|
||||||
$num_locations = count( array_keys($locations) );
|
$num_locations = count( array_keys($locations) );
|
||||||
|
|
|
@ -248,7 +248,7 @@ switch ( $action ) {
|
||||||
} else {
|
} else {
|
||||||
// Remove this menu from any locations.
|
// Remove this menu from any locations.
|
||||||
$locations = get_theme_mod( 'nav_menu_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 )
|
if ( $menu_id == $nav_menu_selected_id )
|
||||||
$locations[ $location ] = 0;
|
$locations[ $location ] = 0;
|
||||||
}
|
}
|
||||||
|
@ -430,20 +430,12 @@ foreach( (array) $nav_menus as $key => $_nav_menu ) {
|
||||||
$nav_menus[$key]->truncated_name = $_nav_menu->truncated_name;
|
$nav_menus[$key]->truncated_name = $_nav_menu->truncated_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The theme supports menus
|
wp_nav_menu_setup();
|
||||||
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 “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '</p></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_initial_nav_menu_meta_boxes();
|
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 “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '</p></div>';
|
||||||
|
|
||||||
$help = '<p>' . __('This feature is new in version 3.0; to use a custom menu in place of your theme’s default menus, support for this feature must be registered in the theme’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>' . __('This feature is new in version 3.0; to use a custom menu in place of your theme’s default menus, support for this feature must be registered in the theme’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>' . __('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’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’ll see when the position of the drop target shifts over to create the nested placement. Don’t forget to click Save when you’re finished.') . '</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’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’ll see when the position of the drop target shifts over to create the nested placement. Don’t forget to click Save when you’re finished.') . '</p>';
|
||||||
|
|
Loading…
Reference in New Issue