WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (11 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison where static strings are involved.

This reduces the number of WordPress.PHP.StrictComparisons.LooseComparison issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

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

    r47557 r47808  
    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
     395        if ( $wp_query->is_singular && 'taxonomy' === $menu_item->type
    396396            && in_array( (int) $menu_item->object_id, $possible_object_parents, true )
    397397        ) {
     
    404404            $menu_item->object_id == $queried_object_id
    405405            && (
    406                 ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id )
    407                 || ( 'post_type' == $menu_item->type && $wp_query->is_singular )
    408                 || ( 'taxonomy' == $menu_item->type
     406                ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type
     407                    && $wp_query->is_home && $home_page_id == $menu_item->object_id )
     408                || ( 'post_type' === $menu_item->type && $wp_query->is_singular )
     409                || ( 'taxonomy' === $menu_item->type
    409410                    && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax )
    410411                    && $queried_object->taxonomy == $menu_item->object )
     
    422423            }
    423424
    424             if ( 'post_type' == $menu_item->type && 'page' == $menu_item->object ) {
     425            if ( 'post_type' === $menu_item->type && 'page' === $menu_item->object ) {
    425426                // Back compat classes for pages to match wp_page_menu().
    426427                $classes[] = 'page_item';
     
    435436            // If the menu item corresponds to the currently queried post type archive.
    436437        } elseif (
    437             'post_type_archive' == $menu_item->type
     438            'post_type_archive' === $menu_item->type
    438439            && is_post_type_archive( array( $menu_item->object ) )
    439440        ) {
     
    452453
    453454            // If the menu item corresponds to the currently requested URL.
    454         } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
     455        } elseif ( 'custom' === $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
    455456            $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
    456457
     
    505506
    506507        // Back-compat with wp_page_menu(): add "current_page_parent" to static home page link for any non-page query.
    507         if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id ) {
     508        if ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type
     509            && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id
     510        ) {
    508511            $classes[] = 'current_page_parent';
    509512        }
     
    526529                // Ancestral post object.
    527530                (
    528                     'post_type' == $parent_item->type
     531                    'post_type' === $parent_item->type
    529532                    && ! empty( $queried_object->post_type )
    530533                    && is_post_type_hierarchical( $queried_object->post_type )
     
    535538                // Ancestral term.
    536539                (
    537                     'taxonomy' == $parent_item->type
     540                    'taxonomy' === $parent_item->type
    538541                    && isset( $possible_taxonomy_ancestors[ $parent_item->object ] )
    539542                    && in_array( (int) $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ], true )
     
    566569        }
    567570
    568         if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) {
     571        if ( 'post_type' === $parent_item->type && 'page' === $parent_item->object ) {
    569572            // Back compat classes for pages to match wp_page_menu().
    570573            if ( in_array( 'current-menu-parent', $classes, true ) ) {
Note: See TracChangeset for help on using the changeset viewer.