Changeset 47122 for trunk/src/wp-includes/nav-menu.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/nav-menu.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/nav-menu.php
r47060 r47122 325 325 ); 326 326 327 // double-check that we're not going to have one menu take the name of another327 // Double-check that we're not going to have one menu take the name of another. 328 328 $_possible_existing = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' ); 329 329 if ( … … 343 343 } 344 344 345 // menu doesn't already exist, so create a new menu345 // Menu doesn't already exist, so create a new menu. 346 346 if ( ! $_menu || is_wp_error( $_menu ) ) { 347 347 $menu_exists = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' ); … … 420 420 $menu_item_db_id = (int) $menu_item_db_id; 421 421 422 // make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects422 // Make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects. 423 423 if ( ! empty( $menu_item_db_id ) && ! is_nav_menu_item( $menu_item_db_id ) ) { 424 424 return new WP_Error( 'update_nav_menu_item_failed', __( 'The given object ID is not that of a menu item.' ) ); … … 496 496 } 497 497 498 // hack to get wp to create a post object when too many properties are empty498 // Hack to get wp to create a post object when too many properties are empty. 499 499 if ( '' == $args['menu-item-title'] && '' == $args['menu-item-description'] ) { 500 500 $args['menu-item-description'] = ' '; … … 502 502 } 503 503 504 // Populate the menu item object 504 // Populate the menu item object. 505 505 $post = array( 506 506 'menu_order' => $args['menu-item-position'], … … 515 515 $update = 0 != $menu_item_db_id; 516 516 517 // New menu item. Default is draft status 517 // New menu item. Default is draft status. 518 518 if ( ! $update ) { 519 519 $post['ID'] = 0; … … 538 538 } 539 539 540 // Associate the menu item with the menu term 541 // Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms() 540 // Associate the menu item with the menu term. 541 // Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms(). 542 542 if ( $menu_id && ( ! $update || ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) ) ) { 543 543 wp_set_object_terms( $menu_item_db_id, array( $menu->term_id ), 'nav_menu' ); … … 569 569 } 570 570 571 // Update existing menu item. Default is publish status 571 // Update existing menu item. Default is publish status. 572 572 if ( $update ) { 573 573 $post['ID'] = $menu_item_db_id; … … 702 702 } 703 703 704 // Get all posts and terms at once to prime the caches 704 // Get all posts and terms at once to prime the caches. 705 705 if ( empty( $fetched[ $menu->term_id ] ) && ! wp_using_ext_object_cache() ) { 706 706 $fetched[ $menu->term_id ] = true; … … 749 749 $items = array_map( 'wp_setup_nav_menu_item', $items ); 750 750 751 if ( ! is_admin() ) { // Remove invalid items only in front end751 if ( ! is_admin() ) { // Remove invalid items only on front end. 752 752 $items = array_filter( $items, '_is_valid_nav_menu_item' ); 753 753 } … … 1246 1246 continue 3; 1247 1247 } 1248 } // endforeach ( $slug_group as $slug )1249 } // endforeach ( $old_nav_menu_locations as $location => $menu_id )1250 } // endforeach foreach ( $registered_nav_menus as $new_location => $name )1251 } // endforeach ( $slug_group as $slug )1252 } // endforeach ( $common_slug_groups as $slug_group )1248 } // End foreach ( $slug_group as $slug ). 1249 } // End foreach ( $old_nav_menu_locations as $location => $menu_id ). 1250 } // End foreach foreach ( $registered_nav_menus as $new_location => $name ). 1251 } // End foreach ( $slug_group as $slug ). 1252 } // End foreach ( $common_slug_groups as $slug_group ). 1253 1253 1254 1254 return $new_nav_menu_locations;
Note: See TracChangeset
for help on using the changeset viewer.