Make WordPress Core


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

Coding Standards: Use Yoda conditions where appropriate.

See #49222.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r47198 r47219  
    150150     * ensure it's a non-negative, non-zero integer.
    151151     */
    152     if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ) {
     152    if ( ( 0 == $term_search_min_chars ) || ( strlen( $s ) < $term_search_min_chars ) ) {
    153153        wp_die();
    154154    }
     
    296296    }
    297297
    298     $include_blog_users = ( $type == 'search' ? get_users(
     298    $include_blog_users = ( 'search' === $type ? get_users(
    299299        array(
    300300            'blog_id' => $id,
     
    303303    ) : array() );
    304304
    305     $exclude_blog_users = ( $type == 'add' ? get_users(
     305    $exclude_blog_users = ( 'add' === $type ? get_users(
    306306        array(
    307307            'blog_id' => $id,
     
    392392
    393393    $pagenow = $_GET['pagenow'];
    394     if ( $pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard' ) {
     394    if ( 'dashboard-user' === $pagenow || 'dashboard-network' === $pagenow || 'dashboard' === $pagenow ) {
    395395        set_current_screen( $pagenow );
    396396    }
     
    574574    }
    575575
    576     if ( $taxonomy->name == 'category' ) {
     576    if ( 'category' === $taxonomy->name ) {
    577577        $post_category = isset( $_POST['post_category'] ) ? (array) $_POST['post_category'] : array();
    578578    } else {
     
    718718
    719719        // Undo trash, not in trash.
    720         if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) {
     720        if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) {
    721721            $delta = 1;
    722722        }
     
    735735
    736736        // Undo spam, not in spam.
    737         if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) {
     737        if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) {
    738738            $delta = 1;
    739739        }
     
    13191319        $parent = get_comment( $comment_parent );
    13201320
    1321         if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
     1321        if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_ID ) {
    13221322            if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) {
    13231323                wp_die( -1 );
     
    15501550
    15511551        // If the post is an autodraft, save the post as a draft and then attempt to save the meta.
    1552         if ( $post->post_status == 'auto-draft' ) {
     1552        if ( 'auto-draft' === $post->post_status ) {
    15531553            $post_data                = array();
    15541554            $post_data['action']      = 'draft'; // Warning fix.
     
    17211721    $page = isset( $_POST['page'] ) ? $_POST['page'] : '';
    17221722
    1723     if ( $page != sanitize_key( $page ) ) {
     1723    if ( sanitize_key( $page ) != $page ) {
    17241724        wp_die( 0 );
    17251725    }
     
    17521752    $page = isset( $_POST['page'] ) ? $_POST['page'] : '';
    17531753
    1754     if ( $page != sanitize_key( $page ) ) {
     1754    if ( sanitize_key( $page ) != $page ) {
    17551755        wp_die( 0 );
    17561756    }
     
    19011901    $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
    19021902
    1903     if ( $page_columns != 'auto' ) {
     1903    if ( 'auto' !== $page_columns ) {
    19041904        $page_columns = (int) $page_columns;
    19051905    }
     
    19071907    $page = isset( $_POST['page'] ) ? $_POST['page'] : '';
    19081908
    1909     if ( $page != sanitize_key( $page ) ) {
     1909    if ( sanitize_key( $page ) != $page ) {
    19101910        wp_die( 0 );
    19111911    }
     
    20042004        $msg_template = __( 'Saving is disabled: %s is currently editing this post.' );
    20052005
    2006         if ( $_POST['post_type'] == 'page' ) {
     2006        if ( 'page' === $_POST['post_type'] ) {
    20072007            /* translators: %s: User's display name. */
    20082008            $msg_template = __( 'Saving is disabled: %s is currently editing this page.' );
     
    20682068    $wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
    20692069
    2070     $mode = $_POST['post_view'] === 'excerpt' ? 'excerpt' : 'list';
     2070    $mode = 'excerpt' === $_POST['post_view'] ? 'excerpt' : 'list';
    20712071
    20722072    $level = 0;
     
    26402640    }
    26412641
    2642     if ( $thumbnail_id == '-1' ) {
     2642    if ( '-1' == $thumbnail_id ) {
    26432643        if ( delete_post_thumbnail( $post_ID ) ) {
    26442644            $return = _wp_post_thumbnail_html( null, $post_ID );
     
    28202820    $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
    28212821
    2822     if ( $active_lock[1] != get_current_user_id() ) {
     2822    if ( get_current_user_id() != $active_lock[1] ) {
    28232823        wp_die( 0 );
    28242824    }
     
    28452845    $pointer = $_POST['pointer'];
    28462846
    2847     if ( $pointer != sanitize_key( $pointer ) ) {
     2847    if ( sanitize_key( $pointer ) != $pointer ) {
    28482848        wp_die( 0 );
    28492849    }
     
    30233023    if ( isset( $changes['alt'] ) ) {
    30243024        $alt = wp_unslash( $changes['alt'] );
    3025         if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) {
     3025        if ( get_post_meta( $id, '_wp_attachment_image_alt', true ) !== $alt ) {
    30263026            $alt = wp_strip_all_tags( $alt, true );
    30273027            update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
     
    38173817    $sessions = WP_Session_Tokens::get_instance( $user->ID );
    38183818
    3819     if ( $user->ID === get_current_user_id() ) {
     3819    if ( get_current_user_id() === $user->ID ) {
    38203820        $sessions->destroy_others( wp_get_session_token() );
    38213821        $message = __( 'You are now logged out everywhere else.' );
Note: See TracChangeset for help on using the changeset viewer.