Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (6 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-admin/includes/ajax-actions.php

    r47597 r47808  
    177177        }
    178178
    179         if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' == ini_get( 'output_handler' ) ) {
     179        if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ) {
    180180                update_site_option( 'can_compress_scripts', 0 );
    181181                wp_die( 0 );
     
    210210                        echo $out;
    211211                        wp_die();
    212                 } elseif ( 'no' == $_GET['test'] ) {
     212                } elseif ( 'no' === $_GET['test'] ) {
    213213                        check_ajax_referer( 'update_can_compress_scripts' );
    214214                        update_site_option( 'can_compress_scripts', 0 );
    215                 } elseif ( 'yes' == $_GET['test'] ) {
     215                } elseif ( 'yes' === $_GET['test'] ) {
    216216                        check_ajax_referer( 'update_can_compress_scripts' );
    217217                        update_site_option( 'can_compress_scripts', 1 );
     
    705705
    706706        if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) {
    707                 if ( 'trash' == $status ) {
     707                if ( 'trash' === $status ) {
    708708                        wp_die( time() );
    709709                }
     
    711711                $r = wp_trash_comment( $comment );
    712712        } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) {
    713                 if ( 'trash' != $status ) {
     713                if ( 'trash' !== $status ) {
    714714                        wp_die( time() );
    715715                }
     
    722722                }
    723723        } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) {
    724                 if ( 'spam' == $status ) {
     724                if ( 'spam' === $status ) {
    725725                        wp_die( time() );
    726726                }
     
    728728                $r = wp_spam_comment( $comment );
    729729        } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) {
    730                 if ( 'spam' != $status ) {
     730                if ( 'spam' !== $status ) {
    731731                        wp_die( time() );
    732732                }
     
    884884        }
    885885
    886         if ( 'trash-post' == $action ) {
     886        if ( 'trash-post' === $action ) {
    887887                $done = wp_trash_post( $id );
    888888        } else {
     
    13021302        }
    13031303
    1304         if ( '' == $comment_content ) {
     1304        if ( '' === $comment_content ) {
    13051305                wp_die( __( 'Error: Please type a comment.' ) );
    13061306        }
     
    13451345
    13461346        ob_start();
    1347         if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) {
     1347        if ( isset( $_REQUEST['mode'] ) && 'dashboard' === $_REQUEST['mode'] ) {
    13481348                require_once ABSPATH . 'wp-admin/includes/dashboard.php';
    13491349                _wp_dashboard_recent_comments_row( $comment );
    13501350        } else {
    1351                 if ( isset( $_REQUEST['mode'] ) && 'single' == $_REQUEST['mode'] ) {
     1351                if ( isset( $_REQUEST['mode'] ) && 'single' === $_REQUEST['mode'] ) {
    13521352                        $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
    13531353                } else {
     
    14041404        }
    14051405
    1406         if ( '' == $_POST['content'] ) {
     1406        if ( '' === $_POST['content'] ) {
    14071407                wp_die( __( 'Error: Please type a comment.' ) );
    14081408        }
     
    14621462                if (
    14631463                        ! empty( $menu_item_data['menu-item-type'] ) &&
    1464                         'custom' != $menu_item_data['menu-item-type'] &&
     1464                        'custom' !== $menu_item_data['menu-item-type'] &&
    14651465                        ! empty( $menu_item_data['menu-item-object-id'] )
    14661466                ) {
     
    15451545                }
    15461546
    1547                 if ( isset( $_POST['metakeyselect'] ) && '#NONE#' == $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) {
     1547                if ( isset( $_POST['metakeyselect'] ) && '#NONE#' === $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) {
    15481548                        wp_die( 1 );
    15491549                }
     
    16051605                $value = wp_unslash( $_POST['meta'][ $mid ]['value'] );
    16061606
    1607                 if ( '' == trim( $key ) ) {
     1607                if ( '' === trim( $key ) ) {
    16081608                        wp_die( __( 'Please provide a custom field name.' ) );
    16091609                }
     
    17961796        require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
    17971797
    1798         if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) {
     1798        if ( isset( $_POST['item-type'] ) && 'post_type' === $_POST['item-type'] ) {
    17991799                $type     = 'posttype';
    18001800                $callback = 'wp_nav_menu_item_post_type_meta_box';
    18011801                $items    = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
    1802         } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) {
     1802        } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' === $_POST['item-type'] ) {
    18031803                $type     = 'taxonomy';
    18041804                $callback = 'wp_nav_menu_item_taxonomy_meta_box';
     
    19861986        $post_ID = (int) $_POST['post_ID'];
    19871987
    1988         if ( 'page' == $_POST['post_type'] ) {
     1988        if ( 'page' === $_POST['post_type'] ) {
    19891989                if ( ! current_user_can( 'edit_page', $post_ID ) ) {
    19901990                        wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
     
    20312031
    20322032        // Status.
    2033         if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) {
     2033        if ( isset( $data['keep_private'] ) && 'private' === $data['keep_private'] ) {
    20342034                $data['visibility']  = 'private';
    20352035                $data['post_status'] = 'private';
     
    21812181        foreach ( $posts as $post ) {
    21822182                $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );
    2183                 $alt   = ( 'alternate' == $alt ) ? '' : 'alternate';
     2183                $alt   = ( 'alternate' === $alt ) ? '' : 'alternate';
    21842184
    21852185                switch ( $post->post_status ) {
     
    21992199                }
    22002200
    2201                 if ( '0000-00-00 00:00:00' == $post->post_date ) {
     2201                if ( '0000-00-00 00:00:00' === $post->post_date ) {
    22022202                        $time = '';
    22032203                } else {
     
    28842884        }
    28852885
    2886         if ( 'attachment' != $post->post_type ) {
     2886        if ( 'attachment' !== $post->post_type ) {
    28872887                wp_send_json_error();
    28882888        }
     
    29972997        $post    = get_post( $id, ARRAY_A );
    29982998
    2999         if ( 'attachment' != $post['post_type'] ) {
     2999        if ( 'attachment' !== $post['post_type'] ) {
    30003000                wp_send_json_error();
    30013001        }
     
    30883088        $post = get_post( $id, ARRAY_A );
    30893089
    3090         if ( 'attachment' != $post['post_type'] ) {
     3090        if ( 'attachment' !== $post['post_type'] ) {
    30913091                wp_send_json_error();
    30923092        }
     
    31553155                }
    31563156
    3157                 if ( 'attachment' != $attachment->post_type ) {
     3157                if ( 'attachment' !== $attachment->post_type ) {
    31583158                        continue;
    31593159                }
     
    31913191        }
    31923192
    3193         if ( 'attachment' != $post->post_type ) {
     3193        if ( 'attachment' !== $post->post_type ) {
    31943194                wp_send_json_error();
    31953195        }
     
    33053305        if ( $ext ) {
    33063306                $ext_type = wp_ext2type( $ext );
    3307                 if ( 'audio' == $ext_type || 'video' == $ext_type ) {
     3307                if ( 'audio' === $ext_type || 'video' === $ext_type ) {
    33083308                        $type = $ext_type;
    33093309                }
Note: See TracChangeset for help on using the changeset viewer.