Make WordPress Core

Changeset 47054


Ignore:
Timestamp:
01/09/2020 12:53:29 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison and Yoda conditions in the root directory files.

Props pikamander2.
Fixes #48965.

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-activate.php

    r45932 r47054  
    3838        $redirect_url = remove_query_arg( 'key' );
    3939
    40         if ( $redirect_url !== remove_query_arg( false ) ) {
     40        if ( remove_query_arg( false ) !== $redirect_url ) {
    4141                setcookie( $activate_cookie, $key, 0, $activate_path, COOKIE_DOMAIN, is_ssl(), true );
    4242                wp_safe_redirect( $redirect_url );
     
    4747}
    4848
    49 if ( $result === null && isset( $_COOKIE[ $activate_cookie ] ) ) {
     49if ( null === $result && isset( $_COOKIE[ $activate_cookie ] ) ) {
    5050        $key    = $_COOKIE[ $activate_cookie ];
    5151        $result = wpmu_activate_signup( $key );
     
    5353}
    5454
    55 if ( $result === null || ( is_wp_error( $result ) && 'invalid_key' === $result->get_error_code() ) ) {
     55if ( null === $result || ( is_wp_error( $result ) && 'invalid_key' === $result->get_error_code() ) ) {
    5656        status_header( 404 );
    5757} elseif ( is_wp_error( $result ) ) {
     
    143143                        <?php
    144144                        echo '<p class="lead-in">';
    145                         if ( $signup->domain . $signup->path == '' ) {
     145                        if ( '' === $signup->domain . $signup->path ) {
    146146                                printf(
    147147                                        /* translators: 1: Login URL, 2: Username, 3: User email address, 4: Lost password URL. */
     
    163163                        }
    164164                        echo '</p>';
    165                 } elseif ( $result === null || is_wp_error( $result ) ) {
     165                } elseif ( null === $result || is_wp_error( $result ) ) {
    166166                        ?>
    167167                        <h2><?php _e( 'An error occurred during the activation' ); ?></h2>
     
    182182
    183183                        <?php
    184                         if ( $url && $url != network_home_url( '', 'http' ) ) :
     184                        if ( $url && network_home_url( '', 'http' ) !== $url ) :
    185185                                switch_to_blog( (int) $result['blog_id'] );
    186186                                $login_url = wp_login_url();
  • trunk/src/wp-cron.php

    r46733 r47054  
    106106 * must match $doing_wp_cron (the "key").
    107107 */
    108 if ( $doing_cron_transient != $doing_wp_cron ) {
     108if ( $doing_cron_transient !== $doing_wp_cron ) {
    109109        return;
    110110}
     
    139139
    140140                        // If the hook ran too long and another cron process stole the lock, quit.
    141                         if ( _get_cron_lock() != $doing_wp_cron ) {
     141                        if ( _get_cron_lock() !== $doing_wp_cron ) {
    142142                                return;
    143143                        }
     
    146146}
    147147
    148 if ( _get_cron_lock() == $doing_wp_cron ) {
     148if ( _get_cron_lock() === $doing_wp_cron ) {
    149149        delete_transient( 'doing_cron' );
    150150}
  • trunk/src/wp-links-opml.php

    r47033 r47054  
    8383<outline text="<?php echo esc_attr( $title ); ?>" type="link" xmlUrl="<?php echo esc_attr( $bookmark->link_rss ); ?>" htmlUrl="<?php echo esc_attr( $bookmark->link_url ); ?>" updated="
    8484                                                        <?php
    85                                                         if ( '0000-00-00 00:00:00' != $bookmark->link_updated ) {
     85                                                        if ( '0000-00-00 00:00:00' !== $bookmark->link_updated ) {
    8686                                                                echo $bookmark->link_updated;}
    8787                                                        ?>
  • trunk/src/wp-login.php

    r46838 r47054  
    524524setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
    525525
    526 if ( SITECOOKIEPATH != COOKIEPATH ) {
     526if ( SITECOOKIEPATH !== COOKIEPATH ) {
    527527        setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
    528528}
     
    933933                $errors = new WP_Error();
    934934
    935                 if ( isset( $_POST['pass1'] ) && $_POST['pass1'] != $_POST['pass2'] ) {
     935                if ( isset( $_POST['pass1'] ) && $_POST['pass1'] !== $_POST['pass2'] ) {
    936936                        $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) );
    937937                }
  • trunk/src/wp-mail.php

    r45932 r47054  
    102102                                $content_transfer_encoding = $content_transfer_encoding[0];
    103103                        }
    104                         if ( ( $content_type == 'multipart/alternative' ) && ( false !== strpos( $line, 'boundary="' ) ) && ( '' == $boundary ) ) {
     104                        if ( ( 'multipart/alternative' === $content_type ) && ( false !== strpos( $line, 'boundary="' ) ) && ( '' === $boundary ) ) {
    105105                                $boundary = trim( $line );
    106106                                $boundary = explode( '"', $boundary );
     
    143143
    144144                        if ( preg_match( '/Date: /i', $line ) ) { // of the form '20 Mar 2002 20:32:37 +0100'
    145                                 $ddate         = str_replace( 'Date: ', '', trim( $line ) );
    146                                 $ddate         = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); // remove parenthesised timezone string if it exists, as this confuses strtotime
    147                                 $ddate_U      = strtotime( $ddate );
    148                                 $post_date     = gmdate( 'Y-m-d H:i:s', $ddate_U + $time_difference );
    149                                 $post_date_gmt = gmdate( 'Y-m-d H:i:s', $ddate_U );
     145                                $ddate           = str_replace( 'Date: ', '', trim( $line ) );
     146                                $ddate           = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); // remove parenthesised timezone string if it exists, as this confuses strtotime
     147                                $ddate_timestamp = strtotime( $ddate );
     148                                $post_date       = gmdate( 'Y-m-d H:i:s', $ddate_timestamp + $time_difference );
     149                                $post_date_gmt   = gmdate( 'Y-m-d H:i:s', $ddate_timestamp );
    150150                        }
    151151                }
     
    163163        $subject = trim( $subject );
    164164
    165         if ( $content_type == 'multipart/alternative' ) {
     165        if ( 'multipart/alternative' === $content_type ) {
    166166                $content = explode( '--' . $boundary, $content );
    167167                $content = $content[2];
     
    213213        $post_title = xmlrpc_getposttitle( $content );
    214214
    215         if ( $post_title == '' ) {
     215        if ( '' === $post_title ) {
    216216                $post_title = $subject;
    217217        }
  • trunk/src/wp-signup.php

    r46696 r47054  
    190190                $blog_public_on_checked  = '';
    191191                $blog_public_off_checked = '';
    192         if ( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) {
     192        if ( isset( $_POST['blog_public'] ) && '0' === $_POST['blog_public'] ) {
    193193                $blog_public_off_checked = 'checked="checked"';
    194194        } else {
     
    642642        }
    643643
    644         if ( 'blog' == $_POST['signup_for'] ) {
     644        if ( 'blog' === $_POST['signup_for'] ) {
    645645                signup_blog( $user_name, $user_email );
    646646                return false;
Note: See TracChangeset for help on using the changeset viewer.