WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/09/2020 04:52:28 PM (14 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-xmlrpc-server.php

    r47122 r47219  
    697697        foreach ( $blogs as $blog ) {
    698698            // Don't include blogs that aren't hosted at this site.
    699             if ( $blog->site_id != get_current_network_id() ) {
     699            if ( get_current_network_id() != $blog->site_id ) {
    700700                continue;
    701701            }
     
    828828     */
    829829    protected function _convert_date( $date ) {
    830         if ( $date === '0000-00-00 00:00:00' ) {
     830        if ( '0000-00-00 00:00:00' === $date ) {
    831831            return new IXR_Date( '00000000T00:00:00Z' );
    832832        }
     
    842842     */
    843843    protected function _convert_date_gmt( $date_gmt, $date ) {
    844         if ( $date !== '0000-00-00 00:00:00' && $date_gmt === '0000-00-00 00:00:00' ) {
     844        if ( '0000-00-00 00:00:00' !== $date && '0000-00-00 00:00:00' === $date_gmt ) {
    845845            return new IXR_Date( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $date, false ), 'Ymd\TH:i:s' ) );
    846846        }
     
    880880            'comment_status'    => $post['comment_status'],
    881881            'ping_status'       => $post['ping_status'],
    882             'sticky'            => ( $post['post_type'] === 'post' && is_sticky( $post['ID'] ) ),
     882            'sticky'            => ( 'post' === $post['post_type'] && is_sticky( $post['ID'] ) ),
    883883        );
    884884
     
    892892
    893893        // Consider future posts as published.
    894         if ( $post_fields['post_status'] === 'future' ) {
     894        if ( 'future' === $post_fields['post_status'] ) {
    895895            $post_fields['post_status'] = 'publish';
    896896        }
     
    12871287         */
    12881288        if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) {
    1289             if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) {
     1289            if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
    12901290                unset( $content_struct['post_date_gmt'] );
    12911291            } else {
     
    14021402                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    14031403            }
    1404             if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) ) {
     1404            if ( get_post_type( $post_data['ID'] ) !== $post_data['post_type'] ) {
    14051405                return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
    14061406            }
     
    14521452        }
    14531453
    1454         if ( isset( $post_data['comment_status'] ) && $post_data['comment_status'] != 'open' && $post_data['comment_status'] != 'closed' ) {
     1454        if ( isset( $post_data['comment_status'] ) && 'open' !== $post_data['comment_status'] && 'closed' !== $post_data['comment_status'] ) {
    14551455            unset( $post_data['comment_status'] );
    14561456        }
    14571457
    1458         if ( isset( $post_data['ping_status'] ) && $post_data['ping_status'] != 'open' && $post_data['ping_status'] != 'closed' ) {
     1458        if ( isset( $post_data['ping_status'] ) && 'open' !== $post_data['ping_status'] && 'closed' !== $post_data['ping_status'] ) {
    14591459            unset( $post_data['ping_status'] );
    14601460        }
     
    14841484        $post_ID = $post_data['ID'];
    14851485
    1486         if ( $post_data['post_type'] == 'post' ) {
     1486        if ( 'post' === $post_data['post_type'] ) {
    14871487            $error = $this->_toggle_sticky( $post_data, $update );
    14881488            if ( $error ) {
     
    17091709         * since _insert_post() will ignore the non-GMT date if the GMT date is set.
    17101710         */
    1711         if ( $post['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) {
     1711        if ( '0000-00-00 00:00:00' === $post['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
    17121712            unset( $post['post_date_gmt'] );
    17131713        } else {
     
    29302930
    29312931        // If we found the page then format the data.
    2932         if ( $page->ID && ( $page->post_type == 'page' ) ) {
     2932        if ( $page->ID && ( 'page' === $page->post_type ) ) {
    29332933            return $this->_prepare_page( $page );
    29342934        } else {
     
    30673067        // make sure it is a page and not a post.
    30683068        $actual_page = get_post( $page_id, ARRAY_A );
    3069         if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) {
     3069        if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
    30703070            return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
    30713071        }
     
    31333133        // Get the page data and make sure it is a page.
    31343134        $actual_page = get_post( $page_id, ARRAY_A );
    3135         if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) {
     3135        if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
    31363136            return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
    31373137        }
     
    42394239            }
    42404240
    4241             if ( $this->blog_options[ $o_name ]['readonly'] == true ) {
     4241            if ( true == $this->blog_options[ $o_name ]['readonly'] ) {
    42424242                continue;
    42434243            }
     
    51155115        $actual_post = get_post( $post_ID, ARRAY_A );
    51165116
    5117         if ( ! $actual_post || $actual_post['post_type'] != 'post' ) {
     5117        if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
    51185118            return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
    51195119        }
     
    51245124            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    51255125        }
    5126         if ( 'publish' == $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
     5126        if ( 'publish' === $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
    51275127            return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
    51285128        }
     
    51895189        $actual_post = get_post( $post_ID, ARRAY_A );
    51905190
    5191         if ( ! $actual_post || $actual_post['post_type'] != 'post' ) {
     5191        if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
    51925192            return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
    51935193        }
     
    52775277        $page_template = '';
    52785278        if ( ! empty( $content_struct['post_type'] ) ) {
    5279             if ( $content_struct['post_type'] == 'page' ) {
     5279            if ( 'page' === $content_struct['post_type'] ) {
    52805280                if ( $publish ) {
    52815281                    $cap = 'publish_pages';
    5282                 } elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) {
     5282                } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) {
    52835283                    $cap = 'publish_pages';
    52845284                } else {
     
    52905290                    $page_template = $content_struct['wp_page_template'];
    52915291                }
    5292             } elseif ( $content_struct['post_type'] == 'post' ) {
     5292            } elseif ( 'post' === $content_struct['post_type'] ) {
    52935293                if ( $publish ) {
    52945294                    $cap = 'publish_posts';
    5295                 } elseif ( isset( $content_struct['post_status'] ) && 'publish' == $content_struct['post_status'] ) {
     5295                } elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
    52965296                    $cap = 'publish_posts';
    52975297                } else {
     
    53075307            if ( $publish ) {
    53085308                $cap = 'publish_posts';
    5309             } elseif ( isset( $content_struct['post_status'] ) && 'publish' == $content_struct['post_status'] ) {
     5309            } elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
    53105310                $cap = 'publish_posts';
    53115311            } else {
     
    55145514
    55155515        // Only posts can be sticky.
    5516         if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
     5516        if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
    55175517            $data           = $postdata;
    55185518            $data['sticky'] = $content_struct['sticky'];
     
    58475847        $tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null;
    58485848
    5849         if ( 'publish' == $post_status || 'private' == $post_status ) {
     5849        if ( 'publish' === $post_status || 'private' === $post_status ) {
    58505850            if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) {
    58515851                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) );
     
    59025902
    59035903        // Only posts can be sticky.
    5904         if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
     5904        if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
    59055905            $data              = $newpost;
    59065906            $data['sticky']    = $content_struct['sticky'];
     
    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'] );
     
    60256025
    60266026            // Consider future posts as published.
    6027             if ( $postdata['post_status'] === 'future' ) {
     6027            if ( 'future' === $postdata['post_status'] ) {
    60286028                $postdata['post_status'] = 'publish';
    60296029            }
     
    60426042            $enclosure = array();
    60436043            foreach ( (array) get_post_custom( $post_ID ) as $key => $val ) {
    6044                 if ( $key == 'enclosure' ) {
     6044                if ( 'enclosure' === $key ) {
    60456045                    foreach ( (array) $val as $enc ) {
    60466046                        $encdata             = explode( "\n", $enc );
     
    61776177
    61786178            // Consider future posts as published.
    6179             if ( $entry['post_status'] === 'future' ) {
     6179            if ( 'future' === $entry['post_status'] ) {
    61806180                $entry['post_status'] = 'publish';
    61816181            }
     
    62146214                'date_modified'          => $post_modified,
    62156215                'date_modified_gmt'      => $post_modified_gmt,
    6216                 'sticky'                 => ( $entry['post_type'] === 'post' && is_sticky( $entry['ID'] ) ),
     6216                'sticky'                 => ( 'post' === $entry['post_type'] && is_sticky( $entry['ID'] ) ),
    62176217                'wp_post_thumbnail'      => get_post_thumbnail_id( $entry['ID'] ),
    62186218            );
     
    68406840        }
    68416841
    6842         if ( $post_ID == url_to_postid( $pagelinkedfrom ) ) {
     6842        if ( url_to_postid( $pagelinkedfrom ) == $post_ID ) {
    68436843            return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) );
    68446844        }
Note: See TracChangeset for help on using the changeset viewer.