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/comment.php

    r47626 r47808  
    128128     */
    129129    if ( 1 == get_option( 'comment_whitelist' ) ) {
    130         if ( 'trackback' !== $comment_type && 'pingback' !== $comment_type && '' != $author && '' != $email ) {
     130        if ( 'trackback' !== $comment_type && 'pingback' !== $comment_type && '' !== $author && '' !== $email ) {
    131131            $comment_user = get_user_by( 'email', wp_unslash( $email ) );
    132132            if ( ! empty( $comment_user->ID ) ) {
     
    964964        'pings'     => array(),
    965965    );
    966     $count            = count( $comments );
     966
     967    $count = count( $comments );
     968
    967969    for ( $i = 0; $i < $count; $i++ ) {
    968970        $type = $comments[ $i ]->comment_type;
     971
    969972        if ( empty( $type ) ) {
    970973            $type = 'comment';
    971974        }
     975
    972976        $comments_by_type[ $type ][] = &$comments[ $i ];
    973         if ( 'trackback' == $type || 'pingback' == $type ) {
     977
     978        if ( 'trackback' === $type || 'pingback' === $type ) {
    974979            $comments_by_type['pings'][] = &$comments[ $i ];
    975980        }
     
    12821287
    12831288    $mod_keys = trim( get_option( 'blacklist_keys' ) );
    1284     if ( '' == $mod_keys ) {
     1289    if ( '' === $mod_keys ) {
    12851290        return false; // If moderation keys are empty.
    12861291    }
     
    16721677    } elseif ( '0' == $approved ) {
    16731678        return 'unapproved';
    1674     } elseif ( 'spam' == $approved ) {
     1679    } elseif ( 'spam' === $approved ) {
    16751680        return 'spam';
    1676     } elseif ( 'trash' == $approved ) {
     1681    } elseif ( 'trash' === $approved ) {
    16771682        return 'trash';
    16781683    } else {
     
    21152120
    21162121    $commentdata['comment_parent'] = isset( $commentdata['comment_parent'] ) ? absint( $commentdata['comment_parent'] ) : 0;
    2117     $parent_status                 = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status( $commentdata['comment_parent'] ) : '';
    2118     $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
     2122
     2123    $parent_status = ( $commentdata['comment_parent'] > 0 ) ? wp_get_comment_status( $commentdata['comment_parent'] ) : '';
     2124
     2125    $commentdata['comment_parent'] = ( 'approved' === $parent_status || 'unapproved' === $parent_status ) ? $commentdata['comment_parent'] : 0;
    21192126
    21202127    if ( ! isset( $commentdata['comment_author_IP'] ) ) {
     
    23762383    if ( ! isset( $data['comment_approved'] ) ) {
    23772384        $data['comment_approved'] = 1;
    2378     } elseif ( 'hold' == $data['comment_approved'] ) {
     2385    } elseif ( 'hold' === $data['comment_approved'] ) {
    23792386        $data['comment_approved'] = 0;
    2380     } elseif ( 'approve' == $data['comment_approved'] ) {
     2387    } elseif ( 'approve' === $data['comment_approved'] ) {
    23812388        $data['comment_approved'] = 1;
    23822389    }
     
    28012808    foreach ( (array) $services as $service ) {
    28022809        $service = trim( $service );
    2803         if ( '' != $service ) {
     2810        if ( '' !== $service ) {
    28042811            weblog_ping( $service );
    28052812        }
     
    29862993
    29872994    // Using a timeout of 3 seconds should be enough to cover slow servers.
    2988     $client             = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' == $path ) ) ? false : $path ) );
     2995    $client             = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' === $path ) ) ? false : $path ) );
    29892996    $client->timeout    = 3;
    29902997    $client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' );
     
    32673274    $status = get_post_status( $post );
    32683275
    3269     if ( ( 'private' == $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) {
     3276    if ( ( 'private' === $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) {
    32703277        return new WP_Error( 'comment_id_not_found' );
    32713278    }
     
    32863293        return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 );
    32873294
    3288     } elseif ( 'trash' == $status ) {
     3295    } elseif ( 'trash' === $status ) {
    32893296
    32903297        /**
Note: See TracChangeset for help on using the changeset viewer.