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-admin/includes/nav-menu.php

    r47747 r47808  
    3232    }
    3333
    34     if ( 'markup' == $response_format ) {
     34    if ( 'markup' === $response_format ) {
    3535        $args['walker'] = new Walker_Nav_Menu_Checklist;
    3636    }
    3737
    38     if ( 'get-post-item' == $type ) {
     38    if ( 'get-post-item' === $type ) {
    3939        if ( post_type_exists( $object_type ) ) {
    4040            if ( isset( $request['ID'] ) ) {
    4141                $object_id = (int) $request['ID'];
    42                 if ( 'markup' == $response_format ) {
     42                if ( 'markup' === $response_format ) {
    4343                    echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
    44                 } elseif ( 'json' == $response_format ) {
     44                } elseif ( 'json' === $response_format ) {
    4545                    echo wp_json_encode(
    4646                        array(
     
    5656            if ( isset( $request['ID'] ) ) {
    5757                $object_id = (int) $request['ID'];
    58                 if ( 'markup' == $response_format ) {
     58                if ( 'markup' === $response_format ) {
    5959                    echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
    60                 } elseif ( 'json' == $response_format ) {
     60                } elseif ( 'json' === $response_format ) {
    6161                    $post_obj = get_term( $object_id, $object_type );
    6262                    echo wp_json_encode(
     
    7272        }
    7373    } elseif ( preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches ) ) {
    74         if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
     74        if ( 'posttype' === $matches[1] && get_post_type_object( $matches[2] ) ) {
    7575            $post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) );
    7676            $args          = array_merge(
     
    9494            while ( $search_results_query->have_posts() ) {
    9595                $post = $search_results_query->next_post();
    96                 if ( 'markup' == $response_format ) {
     96                if ( 'markup' === $response_format ) {
    9797                    $var_by_ref = $post->ID;
    9898                    echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
    99                 } elseif ( 'json' == $response_format ) {
     99                } elseif ( 'json' === $response_format ) {
    100100                    echo wp_json_encode(
    101101                        array(
     
    108108                }
    109109            }
    110         } elseif ( 'taxonomy' == $matches[1] ) {
     110        } elseif ( 'taxonomy' === $matches[1] ) {
    111111            $terms = get_terms(
    112112                array(
     
    121121            }
    122122            foreach ( (array) $terms as $term ) {
    123                 if ( 'markup' == $response_format ) {
     123                if ( 'markup' === $response_format ) {
    124124                    echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
    125                 } elseif ( 'json' == $response_format ) {
     125                } elseif ( 'json' === $response_format ) {
    126126                    echo wp_json_encode(
    127127                        array(
     
    232232            $id = $post_type->name;
    233233            // Give pages a higher priority.
    234             $priority = ( 'page' == $post_type->name ? 'core' : 'default' );
     234            $priority = ( 'page' === $post_type->name ? 'core' : 'default' );
    235235            add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
    236236        }
     
    369369     */
    370370    $important_pages = array();
    371     if ( 'page' == $post_type_name ) {
     371    if ( 'page' === $post_type_name ) {
    372372        $suppress_page_ids = array();
    373373
    374374        // Insert Front Page or custom Home link.
    375         $front_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0;
     375        $front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0;
    376376
    377377        $front_page_obj = null;
     
    401401
    402402        // Insert Posts Page.
    403         $posts_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0;
     403        $posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0;
    404404
    405405        if ( ! empty( $posts_page ) ) {
     
    509509    <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
    510510        <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
    511             <li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>>
     511            <li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>>
    512512                <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php echo $most_recent_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
    513513                    <?php _e( 'Most Recent' ); ?>
    514514                </a>
    515515            </li>
    516             <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
     516            <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>>
    517517                <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php echo $view_all_url; ?>#<?php echo $post_type_name; ?>-all">
    518518                    <?php _e( 'View All' ); ?>
    519519                </a>
    520520            </li>
    521             <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
     521            <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>>
    522522                <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php echo $search_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
    523523                    <?php _e( 'Search' ); ?>
     
    526526        </ul><!-- .posttype-tabs -->
    527527
    528         <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php _e( 'Most Recent' ); ?>" tabindex="0">
     528        <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php _e( 'Most Recent' ); ?>" tabindex="0">
    529529            <ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
    530530                <?php
     
    561561        </div><!-- /.tabs-panel -->
    562562
    563         <div class="tabs-panel <?php echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search" role="region" aria-label="<?php echo $post_type->labels->search_items; ?>" tabindex="0">
     563        <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search" role="region" aria-label="<?php echo $post_type->labels->search_items; ?>" tabindex="0">
    564564            <?php
    565565            if ( isset( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) {
     
    599599        </div><!-- /.tabs-panel -->
    600600
    601         <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $post_type->labels->all_items; ?>" tabindex="0">
     601        <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $post_type->labels->all_items; ?>" tabindex="0">
    602602            <?php if ( ! empty( $page_links ) ) : ?>
    603603                <div class="add-menu-item-pagelinks">
     
    796796    <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
    797797        <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
    798             <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>>
     798            <li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>>
    799799                <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php echo $most_used_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
    800800                    <?php echo esc_html( $taxonomy->labels->most_used ); ?>
    801801                </a>
    802802            </li>
    803             <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
     803            <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>>
    804804                <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php echo $view_all_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
    805805                    <?php _e( 'View All' ); ?>
    806806                </a>
    807807            </li>
    808             <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
     808            <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>>
    809809                <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php echo $search_url; ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
    810810                    <?php _e( 'Search' ); ?>
     
    813813        </ul><!-- .taxonomy-tabs -->
    814814
    815         <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->most_used; ?>" tabindex="0">
     815        <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->most_used; ?>" tabindex="0">
    816816            <ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
    817817                <?php
     
    831831        </div><!-- /.tabs-panel -->
    832832
    833         <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->all_items; ?>" tabindex="0">
     833        <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->all_items; ?>" tabindex="0">
    834834            <?php if ( ! empty( $page_links ) ) : ?>
    835835                <div class="add-menu-item-pagelinks">
     
    850850        </div><!-- /.tabs-panel -->
    851851
    852         <div class="tabs-panel <?php echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>" role="region" aria-label="<?php echo $taxonomy->labels->search_items; ?>" tabindex="0">
     852        <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>" role="region" aria-label="<?php echo $taxonomy->labels->search_items; ?>" tabindex="0">
    853853            <?php
    854854            if ( isset( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) {
     
    932932                    in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ), true ) ||
    933933                    // Or it's not a custom menu item (but not the custom home page).
    934                     ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) ||
     934                    ! ( 'custom' === $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) ||
    935935                    // Or it *is* a custom menu item that already exists.
    936936                    ! empty( $_item_object_data['menu-item-db-id'] )
     
    988988    if ( isset( $object->name ) ) {
    989989
    990         if ( 'page' == $object->name ) {
     990        if ( 'page' === $object->name ) {
    991991            $object->_default_query = array(
    992992                'orderby'     => 'menu_order title',
     
    995995
    996996            // Posts should show only published items.
    997         } elseif ( 'post' == $object->name ) {
     997        } elseif ( 'post' === $object->name ) {
    998998            $object->_default_query = array(
    999999                'post_status' => 'publish',
     
    10011001
    10021002            // Categories should be in reverse chronological order.
    1003         } elseif ( 'category' == $object->name ) {
     1003        } elseif ( 'category' === $object->name ) {
    10041004            $object->_default_query = array(
    10051005                'orderby' => 'id',
     
    10671067        $some_invalid_menu_items = false;
    10681068        foreach ( (array) $menu_items as $menu_item ) {
    1069             if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) {
     1069            if ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) {
    10701070                $some_pending_menu_items = true;
    10711071            }
     
    11831183
    11841184            // Menu item title can't be blank.
    1185             if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) {
     1185            if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' === $_POST['menu-item-title'][ $_key ] ) {
    11861186                continue;
    11871187            }
Note: See TracChangeset for help on using the changeset viewer.