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/class-wp-xmlrpc-server.php

    r47550 r47808  
    11321132        if ( '0' == $comment->comment_approved ) {
    11331133            $comment_status = 'hold';
    1134         } elseif ( 'spam' == $comment->comment_approved ) {
     1134        } elseif ( 'spam' === $comment->comment_approved ) {
    11351135            $comment_status = 'spam';
    11361136        } elseif ( '1' == $comment->comment_approved ) {
     
    33803380        $cat_id = wp_insert_category( $new_category, true );
    33813381        if ( is_wp_error( $cat_id ) ) {
    3382             if ( 'term_exists' == $cat_id->get_error_code() ) {
     3382            if ( 'term_exists' === $cat_id->get_error_code() ) {
    33833383                return (int) $cat_id->get_error_data();
    33843384            } else {
     
    39133913
    39143914            if ( get_option( 'require_name_email' ) ) {
    3915                 if ( 6 > strlen( $comment['comment_author_email'] ) || '' == $comment['comment_author'] ) {
     3915                if ( strlen( $comment['comment_author_email'] < 6 ) || '' === $comment['comment_author'] ) {
    39163916                    return new IXR_Error( 403, __( 'Comment author name and email are required.' ) );
    39173917                } elseif ( ! is_email( $comment['comment_author_email'] ) ) {
     
    57215721
    57225722        $page_template = null;
    5723         if ( ! empty( $content_struct['wp_page_template'] ) && 'page' == $post_type ) {
     5723        if ( ! empty( $content_struct['wp_page_template'] ) && 'page' === $post_type ) {
    57245724            $page_template = $content_struct['wp_page_template'];
    57255725        }
     
    58485848
    58495849        if ( 'publish' === $post_status || 'private' === $post_status ) {
    5850             if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) {
     5850            if ( 'page' === $post_type && ! current_user_can( 'publish_pages' ) ) {
    58515851                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) );
    58525852            } elseif ( ! current_user_can( 'publish_posts' ) ) {
     
    59925992        do_action( 'xmlrpc_call', 'metaWeblog.getPost' );
    59935993
    5994         if ( '' != $postdata['post_date'] ) {
     5994        if ( '' !== $postdata['post_date'] ) {
    59955995            $post_date         = $this->_convert_date( $postdata['post_date'] );
    59965996            $post_date_gmt     = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] );
     
    60216021            $author = get_userdata( $postdata['post_author'] );
    60226022
    6023             $allow_comments = ( 'open' == $postdata['comment_status'] ) ? 1 : 0;
    6024             $allow_pings    = ( 'open' == $postdata['ping_status'] ) ? 1 : 0;
     6023            $allow_comments = ( 'open' === $postdata['comment_status'] ) ? 1 : 0;
     6024            $allow_pings    = ( 'open' === $postdata['ping_status'] ) ? 1 : 0;
    60256025
    60266026            // Consider future posts as published.
     
    61736173            $author = get_userdata( $entry['post_author'] );
    61746174
    6175             $allow_comments = ( 'open' == $entry['comment_status'] ) ? 1 : 0;
    6176             $allow_pings    = ( 'open' == $entry['ping_status'] ) ? 1 : 0;
     6175            $allow_comments = ( 'open' === $entry['comment_status'] ) ? 1 : 0;
     6176            $allow_pings    = ( 'open' === $entry['ping_status'] ) ? 1 : 0;
    61776177
    61786178            // Consider future posts as published.
     
    66826682        $trackback_pings = array();
    66836683        foreach ( $comments as $comment ) {
    6684             if ( 'trackback' == $comment->comment_type ) {
     6684            if ( 'trackback' === $comment->comment_type ) {
    66856685                $content           = $comment->comment_content;
    66866686                $title             = substr( $content, 8, ( strpos( $content, '</strong>' ) - 8 ) );
     
    70297029        $pingbacks = array();
    70307030        foreach ( $comments as $comment ) {
    7031             if ( 'pingback' == $comment->comment_type ) {
     7031            if ( 'pingback' === $comment->comment_type ) {
    70327032                $pingbacks[] = $comment->comment_author_url;
    70337033            }
Note: See TracChangeset for help on using the changeset viewer.