diff options
Diffstat (limited to 'wp-includes/nav-menu-template.php')
-rw-r--r-- | wp-includes/nav-menu-template.php | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index 316a591..860efa9 100644 --- a/wp-includes/nav-menu-template.php +++ b/wp-includes/nav-menu-template.php @@ -341,9 +341,9 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { if ( is_array( $terms ) ) { $possible_object_parents = array_merge( $possible_object_parents, $terms ); $term_to_ancestor = array(); - foreach ( (array) $term_hierarchy as $anc => $descs ) { - foreach ( (array) $descs as $desc ) { - $term_to_ancestor[ $desc ] = $anc; + foreach ( (array) $term_hierarchy as $ancestor => $descendents ) { + foreach ( (array) $descendents as $desc ) { + $term_to_ancestor[ $desc ] = $ancestor; } } @@ -365,9 +365,9 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } elseif ( ! empty( $queried_object->taxonomy ) && is_taxonomy_hierarchical( $queried_object->taxonomy ) ) { $term_hierarchy = _get_term_hierarchy( $queried_object->taxonomy ); $term_to_ancestor = array(); - foreach ( (array) $term_hierarchy as $anc => $descs ) { - foreach ( (array) $descs as $desc ) { - $term_to_ancestor[ $desc ] = $anc; + foreach ( (array) $term_hierarchy as $ancestor => $descendents ) { + foreach ( (array) $descendents as $desc ) { + $term_to_ancestor[ $desc ] = $ancestor; } } $desc = $queried_object->term_id; @@ -418,25 +418,25 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { // If the menu item corresponds to the currently queried post or taxonomy object. } elseif ( - $menu_item->object_id == $queried_object_id + (int) $menu_item->object_id === $queried_object_id && ( ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type - && $wp_query->is_home && $home_page_id == $menu_item->object_id ) + && $wp_query->is_home && $home_page_id === (int) $menu_item->object_id ) || ( 'post_type' === $menu_item->type && $wp_query->is_singular ) || ( 'taxonomy' === $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) - && $queried_object->taxonomy == $menu_item->object ) + && $queried_object->taxonomy === $menu_item->object ) ) ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; - $_anc_id = (int) $menu_item->db_id; + $ancestor_id = (int) $menu_item->db_id; while ( - ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) - && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) + ( $ancestor_id = (int) get_post_meta( $ancestor_id, '_menu_item_menu_item_parent', true ) ) + && ! in_array( $ancestor_id, $active_ancestor_item_ids, true ) ) { - $active_ancestor_item_ids[] = $_anc_id; + $active_ancestor_item_ids[] = $ancestor_id; } if ( 'post_type' === $menu_item->type && 'page' === $menu_item->object ) { @@ -457,13 +457,13 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; - $_anc_id = (int) $menu_item->db_id; + $ancestor_id = (int) $menu_item->db_id; while ( - ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) - && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) + ( $ancestor_id = (int) get_post_meta( $ancestor_id, '_menu_item_menu_item_parent', true ) ) + && ! in_array( $ancestor_id, $active_ancestor_item_ids, true ) ) { - $active_ancestor_item_ids[] = $_anc_id; + $active_ancestor_item_ids[] = $ancestor_id; } $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; @@ -494,13 +494,13 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { if ( $raw_item_url && in_array( $item_url, $matches, true ) ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; - $_anc_id = (int) $menu_item->db_id; + $ancestor_id = (int) $menu_item->db_id; while ( - ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) - && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) + ( $ancestor_id = (int) get_post_meta( $ancestor_id, '_menu_item_menu_item_parent', true ) ) + && ! in_array( $ancestor_id, $active_ancestor_item_ids, true ) ) { - $active_ancestor_item_ids[] = $_anc_id; + $active_ancestor_item_ids[] = $ancestor_id; } if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ), true ) ) { @@ -512,18 +512,18 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $active_object = $menu_item->object; // Give front page item the 'current-menu-item' class when extra query arguments are involved. - } elseif ( $item_url == $front_page_url && is_front_page() ) { + } elseif ( $item_url === $front_page_url && is_front_page() ) { $classes[] = 'current-menu-item'; } - if ( untrailingslashit( $item_url ) == home_url() ) { + if ( untrailingslashit( $item_url ) === home_url() ) { $classes[] = 'menu-item-home'; } } // Back-compat with wp_page_menu(): add "current_page_parent" to static home page link for any non-page query. if ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type - && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id + && empty( $wp_query->is_page ) && $home_page_id === (int) $menu_item->object_id ) { $classes[] = 'current_page_parent'; } @@ -549,7 +549,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { && ! empty( $queried_object->post_type ) && is_post_type_hierarchical( $queried_object->post_type ) && in_array( (int) $parent_item->object_id, $queried_object->ancestors, true ) - && $parent_item->object != $queried_object->ID + && (int) $parent_item->object_id !== $queried_object->ID ) || // Ancestral term. @@ -559,7 +559,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { && in_array( (int) $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ], true ) && ( ! isset( $queried_object->term_id ) || - $parent_item->object_id != $queried_object->term_id + (int) $parent_item->object_id !== $queried_object->term_id ) ) ) |