Changes in trunk/wp-admin/nav-menus.php [15219:15010]
- File:
-
- 1 edited
-
trunk/wp-admin/nav-menus.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/nav-menus.php
r15219 r15010 16 16 require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' ); 17 17 18 if ( ! current_theme_supports( ' menus' ) && ! current_theme_supports( 'widgets' ) )18 if ( ! current_theme_supports( 'nav-menus' ) && ! current_theme_supports( 'widgets' ) ) 19 19 wp_die( __( 'Your theme does not support navigation menus or widgets.' ) ); 20 20 … … 56 56 check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' ); 57 57 if ( isset( $_REQUEST['nav-menu-locations'] ) ) 58 set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_REQUEST['menu-locations'] ));58 set_theme_mod( 'nav_menu_locations', $_REQUEST['menu-locations'] ); 59 59 elseif ( isset( $_REQUEST['menu-item'] ) ) 60 60 wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] ); … … 234 234 235 235 236 if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) ) 237 $messages[] = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>'; 236 if ( is_nav_menu_item( $menu_item_id ) ) { 237 if ( wp_delete_post( $menu_item_id, true ) ) { 238 239 $messages[] = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>'; 240 } 241 } 238 242 break; 239 243 case 'delete': … … 247 251 $messages[] = '<div id="message" class="error"><p>' . $delete_nav_menu->get_error_message() . '</p></div>'; 248 252 } else { 249 // Remove this menu from any locations.250 $locations = get_theme_mod( 'nav_menu_locations' );251 foreach ( (array) $locations as $location => $menu_id ) {252 if ( $menu_id == $nav_menu_selected_id )253 $locations[ $location ] = 0;254 }255 set_theme_mod( 'nav_menu_locations', $locations );256 253 $messages[] = '<div id="message" class="updated"><p>' . __('The menu has been successfully deleted.') . '</p></div>'; 257 254 // Select the next available menu … … 279 276 // Update menu theme locations 280 277 if ( isset( $_POST['menu-locations'] ) ) 281 set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ));278 set_theme_mod( 'nav_menu_locations', $_POST['menu-locations'] ); 282 279 283 280 // Add Menu 284 281 if ( 0 == $nav_menu_selected_id ) { 285 $new_menu_title = trim( esc_html( $_POST['menu-name'] ));282 $new_menu_title = esc_html( $_POST['menu-name'] ); 286 283 287 284 if ( $new_menu_title ) { … … 308 305 $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); 309 306 310 $menu_title = trim( esc_html( $_POST['menu-name'] ) );311 if ( ! $menu_title ) {312 $messages[] = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>';313 $menu_title = $_menu_object->name;314 }315 316 307 if ( ! is_wp_error( $_menu_object ) ) { 317 $_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $ menu_title) );308 $_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $_POST['menu-name'] ) ); 318 309 if ( is_wp_error( $_nav_menu_selected_id ) ) { 319 310 $_menu_object = $_nav_menu_selected_id; … … 328 319 329 320 if ( ! is_wp_error( $_menu_object ) ) { 330 $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,p ending,publish') );321 $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish') ); 331 322 $menu_items = array(); 332 323 // Index menu items by db ID … … 334 325 $menu_items[$_item->db_id] = $_item; 335 326 336 $post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item- status', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' );327 $post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' ); 337 328 wp_defer_term_counting(true); 338 329 // Loop through all the menu items' POST variables … … 431 422 } 432 423 433 // Ensure the user will be able to scroll horizontally 434 // by adding a class for the max menu depth. 435 global $_wp_nav_menu_max_depth; 436 $_wp_nav_menu_max_depth = 0; 437 438 // Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth 439 if ( is_nav_menu( $nav_menu_selected_id ) ) 440 $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); 441 442 function wp_nav_menu_max_depth() { 443 global $_wp_nav_menu_max_depth; 444 return "menu-max-depth-$_wp_nav_menu_max_depth"; 424 // The theme supports menus 425 if ( current_theme_supports('nav-menus') ) { 426 // Set up nav menu 427 wp_nav_menu_setup(); 428 429 // The theme does not support menus but supports widgets 430 } elseif ( current_theme_supports('widgets') ) { 431 // Set up nav menu 432 wp_nav_menu_setup(); 433 $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>'; 445 434 } 446 435 447 add_action('admin_body_class','wp_nav_menu_max_depth');448 449 wp_nav_menu_setup();450 436 wp_initial_nav_menu_meta_boxes(); 451 437 452 if ( ! current_theme_supports( 'menus' ) && ! wp_get_nav_menus() ) 453 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>'; 454 455 $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>'; 438 $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>'; 456 439 $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>'; 457 440 $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>'; 458 $help .= '<p><strong>' . __('For more information:') . '</strong></p>'; 459 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Menus_SubPanel" target="_blank">Menus Documentation</a>') . '</p>';460 $help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';441 $help .= '<p><strong>' . __('For more information:') . '</strong></p>'; 442 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Menus_SubPanel">Menus Documentation</a>') . '</p>'; 443 $help .= '<p>' . __('<a href="http://wordpress.org/support/">Support Forums</a>') . '</p>'; 461 444 462 445 add_contextual_help($current_screen, $help); … … 474 457 ?> 475 458 <div id="nav-menus-frame"> 476 <div id="menu-settings-column" class="metabox-holder <?php if ( !$nav_menu_selected_id ) { echo ' metabox-holder-disabled'; } ?>">459 <div id="menu-settings-column" class="metabox-holder"> 477 460 478 461 <form id="nav-menu-meta" action="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-menu-meta" method="post" enctype="multipart/form-data"> … … 580 563 <div id="post-body"> 581 564 <div id="post-body-content"> 582 <?php 583 if ( isset( $edit_markup ) ) { 584 if ( ! is_wp_error( $edit_markup ) ) 565 <?php if ( is_nav_menu( $nav_menu_selected_id ) ) : ?> 566 <ul class="menu" id="menu-to-edit"> 567 <?php 568 $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); 569 if ( ! is_wp_error( $edit_markup ) ) { 585 570 echo $edit_markup; 586 } else if ( empty( $nav_menu_selected_id ) ) { 571 } 572 ?> 573 </ul> 574 <?php elseif ( empty($nav_menu_selected_id) ): 587 575 echo '<div class="post-body-plain">'; 588 576 echo '<p>' . __('To create a custom menu, give it a name above and click Create Menu. Then choose items like pages, categories or custom links from the left column to add to this menu.') . '</p>'; … … 590 578 echo '<p>' . __('When you have finished building your custom menu, make sure you click the Save Menu button.') . '</p>'; 591 579 echo '</div>'; 592 } 593 ?> 580 endif; ?> 594 581 </div><!-- /#post-body-content --> 595 582 </div><!-- /#post-body -->
Note: See TracChangeset
for help on using the changeset viewer.