Make WordPress Core


Ignore:
Timestamp:
04/09/2020 03:41:04 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict type check for in_array() and array_search().

This addresses all the remaining WordPress.PHP.StrictInArray.MissingTrueStrict issues in core.

Includes minor code layout fixes for better readability.

Follow-up to [47550].

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu-template.php

    r47550 r47557  
    393393
    394394                // If the menu item corresponds to a taxonomy term for the currently queried non-hierarchical post object.
    395                 if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) {
     395                if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type
     396                        && in_array( (int) $menu_item->object_id, $possible_object_parents, true )
     397                ) {
    396398                        $active_parent_object_ids[] = (int) $menu_item->object_id;
    397399                        $active_parent_item_ids[]   = (int) $menu_item->db_id;
     
    405407                                || ( 'post_type' == $menu_item->type && $wp_query->is_singular )
    406408                                || ( 'taxonomy' == $menu_item->type
    407                                         && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) && $queried_object->taxonomy == $menu_item->object )
     409                                        && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax )
     410                                        && $queried_object->taxonomy == $menu_item->object )
    408411                        )
    409412                ) {
     
    526529                                        && ! empty( $queried_object->post_type )
    527530                                        && is_post_type_hierarchical( $queried_object->post_type )
    528                                         && in_array( $parent_item->object_id, $queried_object->ancestors )
     531                                        && in_array( (int) $parent_item->object_id, $queried_object->ancestors, true )
    529532                                        && $parent_item->object != $queried_object->ID
    530533                                ) ||
     
    534537                                        'taxonomy' == $parent_item->type
    535538                                        && isset( $possible_taxonomy_ancestors[ $parent_item->object ] )
    536                                         && in_array( $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ] )
     539                                        && in_array( (int) $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ], true )
    537540                                        && (
    538541                                                ! isset( $queried_object->term_id ) ||
Note: See TracChangeset for help on using the changeset viewer.