Changeset 47122 for trunk/src/wp-includes/nav-menu-template.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/nav-menu-template.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/nav-menu-template.php
r47097 r47122 73 73 74 74 if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { 75 // invalid value, fall back to default.75 // Invalid value, fall back to default. 76 76 $args['item_spacing'] = $defaults['item_spacing']; 77 77 } … … 114 114 } 115 115 116 // Get the nav menu based on the requested menu 116 // Get the nav menu based on the requested menu. 117 117 $menu = wp_get_nav_menu_object( $args->menu ); 118 118 119 // Get the nav menu based on the theme_location 119 // Get the nav menu based on the theme_location. 120 120 $locations = get_nav_menu_locations(); 121 121 if ( ! $menu && $args->theme_location && $locations && isset( $locations[ $args->theme_location ] ) ) { … … 123 123 } 124 124 125 // get the first menu that has items if we still can't find a menu125 // Get the first menu that has items if we still can't find a menu. 126 126 if ( ! $menu && ! $args->theme_location ) { 127 127 $menus = wp_get_nav_menus(); … … 183 183 } 184 184 185 // Set up the $menu_item variables 185 // Set up the $menu_item variables. 186 186 _wp_menu_item_classes_by_context( $menu_items ); 187 187 … … 195 195 } 196 196 197 // Add the menu-item-has-children class where applicable 197 // Add the menu-item-has-children class where applicable. 198 198 if ( $menu_items_with_children ) { 199 199 foreach ( $sorted_menu_items as &$menu_item ) { … … 219 219 unset( $sorted_menu_items ); 220 220 221 // Attributes 221 // Attributes. 222 222 if ( ! empty( $args->menu_id ) ) { 223 223 $wrap_id = $args->menu_id; … … 390 390 } 391 391 392 // if the menu item corresponds to a taxonomy term for the currently-queried non-hierarchical post object392 // If the menu item corresponds to a taxonomy term for the currently queried non-hierarchical post object. 393 393 if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) { 394 394 $active_parent_object_ids[] = (int) $menu_item->object_id; … … 396 396 $active_object = $queried_object->post_type; 397 397 398 // if the menu item corresponds to the currently-queried post or taxonomy object398 // If the menu item corresponds to the currently queried post or taxonomy object. 399 399 } elseif ( 400 400 $menu_item->object_id == $queried_object_id && … … 417 417 418 418 if ( 'post_type' == $menu_item->type && 'page' == $menu_item->object ) { 419 // Back compat classes for pages to match wp_page_menu() 419 // Back compat classes for pages to match wp_page_menu(). 420 420 $classes[] = 'page_item'; 421 421 $classes[] = 'page-item-' . $menu_item->object_id; … … 427 427 $active_object = $menu_item->object; 428 428 429 // if the menu item corresponds to the currently-queried post type archive429 // If the menu item corresponds to the currently queried post type archive. 430 430 } elseif ( 431 431 'post_type_archive' == $menu_item->type && … … 445 445 $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; 446 446 447 // if the menu item corresponds to the currently-requested URL447 // If the menu item corresponds to the currently requested URL. 448 448 } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) { 449 449 $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); 450 450 451 // if it is the customize page then it will strips the query var off the urlbefore entering the comparison block.451 // If it's the customize page then it will strip the query var off the URL before entering the comparison block. 452 452 if ( is_customize_preview() ) { 453 453 $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' ); … … 481 481 482 482 if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) { 483 // Back compat for home link to match wp_page_menu() 483 // Back compat for home link to match wp_page_menu(). 484 484 $classes[] = 'current_page_item'; 485 485 } … … 488 488 $active_object = $menu_item->object; 489 489 490 // give front page item current-menu-item class when extra query arguments involved490 // Give front page item the 'current-menu-item' class when extra query arguments are involved. 491 491 } elseif ( $item_url == $front_page_url && is_front_page() ) { 492 492 $classes[] = 'current-menu-item'; … … 498 498 } 499 499 500 // back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query500 // Back-compat with wp_page_menu(): add "current_page_parent" to static home page link for any non-page query. 501 501 if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id ) { 502 502 $classes[] = 'current_page_parent'; … … 509 509 $active_parent_object_ids = array_filter( array_unique( $active_parent_object_ids ) ); 510 510 511 // set parent's class511 // Set parent's class. 512 512 foreach ( (array) $menu_items as $key => $parent_item ) { 513 513 $classes = (array) $parent_item->classes; … … 518 518 isset( $parent_item->type ) && 519 519 ( 520 // ancestral post object520 // Ancestral post object. 521 521 ( 522 522 'post_type' == $parent_item->type && … … 527 527 ) || 528 528 529 // ancestral term529 // Ancestral term. 530 530 ( 531 531 'taxonomy' == $parent_item->type && … … 555 555 556 556 if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) { 557 // Back compat classes for pages to match wp_page_menu() 557 // Back compat classes for pages to match wp_page_menu(). 558 558 if ( in_array( 'current-menu-parent', $classes ) ) { 559 559 $classes[] = 'current_page_parent';
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)