WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/09/2020 04:52:28 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use Yoda conditions where appropriate.

See #49222.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-query.php

    r47181 r47219  
    911911            unset( $tax_query );
    912912
    913             if ( empty( $qv['author'] ) || ( $qv['author'] == '0' ) ) {
     913            if ( empty( $qv['author'] ) || ( '0' == $qv['author'] ) ) {
    914914                $this->is_author = false;
    915915            } else {
     
    10181018            }
    10191019
    1020             if ( 'page' == get_option( 'show_on_front' ) && isset( $this->queried_object_id ) && $this->queried_object_id == get_option( 'page_for_posts' ) ) {
     1020            if ( 'page' === get_option( 'show_on_front' ) && isset( $this->queried_object_id ) && get_option( 'page_for_posts' ) == $this->queried_object_id ) {
    10211021                $this->is_page       = false;
    10221022                $this->is_home       = true;
     
    10241024            }
    10251025
    1026             if ( isset( $this->queried_object_id ) && $this->queried_object_id == get_option( 'wp_page_for_privacy_policy' ) ) {
     1026            if ( isset( $this->queried_object_id ) && get_option( 'wp_page_for_privacy_policy' ) == $this->queried_object_id ) {
    10271027                $this->is_privacy_policy = true;
    10281028            }
     
    10301030
    10311031        if ( $qv['page_id'] ) {
    1032             if ( 'page' == get_option( 'show_on_front' ) && $qv['page_id'] == get_option( 'page_for_posts' ) ) {
     1032            if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == $qv['page_id'] ) {
    10331033                $this->is_page       = false;
    10341034                $this->is_home       = true;
     
    10361036            }
    10371037
    1038             if ( $qv['page_id'] == get_option( 'wp_page_for_privacy_policy' ) ) {
     1038            if ( get_option( 'wp_page_for_privacy_policy' ) == $qv['page_id'] ) {
    10391039                $this->is_privacy_policy = true;
    10401040            }
     
    13781378        foreach ( $q['search_terms'] as $term ) {
    13791379            // If there is an $exclusion_prefix, terms prefixed with it should be excluded.
    1380             $exclude = $exclusion_prefix && ( $exclusion_prefix === substr( $term, 0, 1 ) );
     1380            $exclude = $exclusion_prefix && ( substr( $term, 0, 1 ) === $exclusion_prefix );
    13811381            if ( $exclude ) {
    13821382                $like_op  = 'NOT LIKE';
     
    18621862            $q['posts_per_page'] = $q['showposts'];
    18631863        }
    1864         if ( ( isset( $q['posts_per_archive_page'] ) && $q['posts_per_archive_page'] != 0 ) && ( $this->is_archive || $this->is_search ) ) {
     1864        if ( ( isset( $q['posts_per_archive_page'] ) && 0 != $q['posts_per_archive_page'] ) && ( $this->is_archive || $this->is_search ) ) {
    18651865            $q['posts_per_page'] = $q['posts_per_archive_page'];
    18661866        }
    18671867        if ( ! isset( $q['nopaging'] ) ) {
    1868             if ( $q['posts_per_page'] == -1 ) {
     1868            if ( -1 == $q['posts_per_page'] ) {
    18691869                $q['nopaging'] = true;
    18701870            } else {
     
    18851885        if ( $q['posts_per_page'] < -1 ) {
    18861886            $q['posts_per_page'] = abs( $q['posts_per_page'] );
    1887         } elseif ( $q['posts_per_page'] == 0 ) {
     1887        } elseif ( 0 == $q['posts_per_page'] ) {
    18881888            $q['posts_per_page'] = 1;
    18891889        }
    18901890
    1891         if ( ! isset( $q['comments_per_page'] ) || $q['comments_per_page'] == 0 ) {
     1891        if ( ! isset( $q['comments_per_page'] ) || 0 == $q['comments_per_page'] ) {
    18921892            $q['comments_per_page'] = get_option( 'comments_per_page' );
    18931893        }
    18941894
    1895         if ( $this->is_home && ( empty( $this->query ) || $q['preview'] == 'true' ) && ( 'page' == get_option( 'show_on_front' ) ) && get_option( 'page_on_front' ) ) {
     1895        if ( $this->is_home && ( empty( $this->query ) || 'true' === $q['preview'] ) && ( 'page' === get_option( 'show_on_front' ) ) && get_option( 'page_on_front' ) ) {
    18961896            $this->is_page = true;
    18971897            $this->is_home = false;
     
    20972097
    20982098        if ( $q['page_id'] ) {
    2099             if ( ( 'page' != get_option( 'show_on_front' ) ) || ( $q['page_id'] != get_option( 'page_for_posts' ) ) ) {
     2099            if ( ( 'page' !== get_option( 'show_on_front' ) ) || ( get_option( 'page_for_posts' ) != $q['page_id'] ) ) {
    21002100                $q['p'] = $q['page_id'];
    21012101                $where  = " AND {$wpdb->posts}.ID = " . $q['page_id'];
     
    21362136                $taxonomies = array_keys( $this->tax_query->queried_terms );
    21372137                foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
    2138                     $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
     2138                    $object_taxonomies = 'attachment' === $pt ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
    21392139                    if ( array_intersect( $taxonomies, $object_taxonomies ) ) {
    21402140                        $post_type[] = $pt;
     
    22152215        // Author/user stuff.
    22162216
    2217         if ( ! empty( $q['author'] ) && $q['author'] != '0' ) {
     2217        if ( ! empty( $q['author'] ) && '0' != $q['author'] ) {
    22182218            $q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) );
    22192219            $authors     = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $q['author'] ) ) );
     
    32913291        $this->in_the_loop = true;
    32923292
    3293         if ( $this->current_post == -1 ) { // Loop has just started.
     3293        if ( -1 == $this->current_post ) { // Loop has just started.
    32943294            /**
    32953295             * Fires once the loop is started.
     
    33813381        $comment = $this->next_comment();
    33823382
    3383         if ( $this->current_comment == 0 ) {
     3383        if ( 0 == $this->current_comment ) {
    33843384            /**
    33853385             * Fires once the comment loop is started.
     
    43014301         * or when on an RSS feed. Otherwise respect the 'more' tag.
    43024302         */
    4303         if ( $post->ID === get_queried_object_id() && ( $this->is_page() || $this->is_single() ) ) {
     4303        if ( get_queried_object_id() === $post->ID && ( $this->is_page() || $this->is_single() ) ) {
    43044304            $more = 1;
    43054305        } elseif ( $this->is_feed() ) {
Note: See TracChangeset for help on using the changeset viewer.