Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (5 years 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/general-template.php

    r47557 r47808  
    254254
    255255    $search_form_template = locate_template( 'searchform.php' );
    256     if ( '' != $search_form_template ) {
     256
     257    if ( '' !== $search_form_template ) {
    257258        ob_start();
    258259        require $search_form_template;
     
    269270            $aria_label = '';
    270271        }
    271         if ( 'html5' == $format ) {
     272        if ( 'html5' === $format ) {
    272273            $form = '<form role="search" ' . $aria_label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
    273274                <label>
     
    763764        case 'charset':
    764765            $output = get_option( 'blog_charset' );
    765             if ( '' == $output ) {
     766            if ( '' === $output ) {
    766767                $output = 'UTF-8';
    767768            }
     
    817818    }
    818819
    819     if ( 'display' == $filter ) {
     820    if ( 'display' === $filter ) {
    820821        if ( $url ) {
    821822            /**
     
    12871288
    12881289    // Determines position of the separator and direction of the breadcrumb.
    1289     if ( 'right' == $seplocation ) { // Separator on right, so reverse the order.
     1290    if ( 'right' === $seplocation ) { // Separator on right, so reverse the order.
    12901291        $title_array = array_reverse( $title_array );
    12911292        $title       = implode( " $sep ", $title_array ) . $prefix;
     
    18351836        return;
    18361837    }
     1838
    18371839    $parsed_args['post_type'] = $post_type_object->name;
    18381840
    1839     if ( '' == $parsed_args['type'] ) {
     1841    if ( '' === $parsed_args['type'] ) {
    18401842        $parsed_args['type'] = 'monthly';
    18411843    }
     
    18821884    $limit = $parsed_args['limit'];
    18831885
    1884     if ( 'monthly' == $parsed_args['type'] ) {
     1886    if ( 'monthly' === $parsed_args['type'] ) {
    18851887        $query   = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
    18861888        $key     = md5( $query );
     
    19071909            }
    19081910        }
    1909     } elseif ( 'yearly' == $parsed_args['type'] ) {
     1911    } elseif ( 'yearly' === $parsed_args['type'] ) {
    19101912        $query   = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
    19111913        $key     = md5( $query );
     
    19311933            }
    19321934        }
    1933     } elseif ( 'daily' == $parsed_args['type'] ) {
     1935    } elseif ( 'daily' === $parsed_args['type'] ) {
    19341936        $query   = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
    19351937        $key     = md5( $query );
     
    19561958            }
    19571959        }
    1958     } elseif ( 'weekly' == $parsed_args['type'] ) {
     1960    } elseif ( 'weekly' === $parsed_args['type'] ) {
    19591961        $week    = _wp_mysql_week( '`post_date`' );
    19601962        $query   = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
     
    19951997            }
    19961998        }
    1997     } elseif ( ( 'postbypost' == $parsed_args['type'] ) || ( 'alpha' == $parsed_args['type'] ) ) {
    1998         $orderby = ( 'alpha' == $parsed_args['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
     1999    } elseif ( ( 'postbypost' === $parsed_args['type'] ) || ( 'alpha' === $parsed_args['type'] ) ) {
     2000        $orderby = ( 'alpha' === $parsed_args['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
    19992001        $query   = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
    20002002        $key     = md5( $query );
     
    24032405    }
    24042406
    2405     if ( '' == $format ) {
     2407    if ( '' === $format ) {
    24062408        $the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
    24072409    } else {
     
    25322534    }
    25332535
    2534     if ( '' == $format ) {
     2536    if ( '' === $format ) {
    25352537        $the_time = get_post_time( get_option( 'time_format' ), false, $post, true );
    25362538    } else {
     
    33433345        $wp_rich_edit = false;
    33443346
    3345         if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // Default to 'true' for logged out users.
     3347        if ( 'true' === get_user_option( 'rich_editing' ) || ! is_user_logged_in() ) { // Default to 'true' for logged out users.
    33463348            if ( $is_safari ) {
    33473349                $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
Note: See TracChangeset for help on using the changeset viewer.