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/capabilities.php

    r47550 r47808  
    5555        case 'edit_users':
    5656            // Allow user to edit themselves.
    57             if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) {
     57            if ( 'edit_user' === $cap && isset( $args[0] ) && $user_id == $args[0] ) {
    5858                break;
    5959            }
     
    7474            }
    7575
    76             if ( 'revision' == $post->post_type ) {
     76            if ( 'revision' === $post->post_type ) {
    7777                $caps[] = 'do_not_allow';
    7878                break;
     
    9595                $caps[] = $post_type->cap->$cap;
    9696                // Prior to 3.1 we would re-call map_meta_cap here.
    97                 if ( 'delete_post' == $cap ) {
     97                if ( 'delete_post' === $cap ) {
    9898                    $cap = $post_type->cap->$cap;
    9999                }
     
    106106                if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
    107107                    $caps[] = $post_type->cap->delete_published_posts;
    108                 } elseif ( 'trash' == $post->post_status ) {
     108                } elseif ( 'trash' === $post->post_status ) {
    109109                    $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
    110110                    if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
     
    123123                if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
    124124                    $caps[] = $post_type->cap->delete_published_posts;
    125                 } elseif ( 'private' == $post->post_status ) {
     125                } elseif ( 'private' === $post->post_status ) {
    126126                    $caps[] = $post_type->cap->delete_private_posts;
    127127                }
     
    147147            }
    148148
    149             if ( 'revision' == $post->post_type ) {
     149            if ( 'revision' === $post->post_type ) {
    150150                $post = get_post( $post->post_parent );
    151151                if ( ! $post ) {
     
    166166                $caps[] = $post_type->cap->$cap;
    167167                // Prior to 3.1 we would re-call map_meta_cap here.
    168                 if ( 'edit_post' == $cap ) {
     168                if ( 'edit_post' === $cap ) {
    169169                    $cap = $post_type->cap->$cap;
    170170                }
     
    177177                if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
    178178                    $caps[] = $post_type->cap->edit_published_posts;
    179                 } elseif ( 'trash' == $post->post_status ) {
     179                } elseif ( 'trash' === $post->post_status ) {
    180180                    $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
    181181                    if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
     
    194194                if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
    195195                    $caps[] = $post_type->cap->edit_published_posts;
    196                 } elseif ( 'private' == $post->post_status ) {
     196                } elseif ( 'private' === $post->post_status ) {
    197197                    $caps[] = $post_type->cap->edit_private_posts;
    198198                }
     
    216216            }
    217217
    218             if ( 'revision' == $post->post_type ) {
     218            if ( 'revision' === $post->post_type ) {
    219219                $post = get_post( $post->post_parent );
    220220                if ( ! $post ) {
     
    235235                $caps[] = $post_type->cap->$cap;
    236236                // Prior to 3.1 we would re-call map_meta_cap here.
    237                 if ( 'read_post' == $cap ) {
     237                if ( 'read_post' === $cap ) {
    238238                    $cap = $post_type->cap->$cap;
    239239                }
Note: See TracChangeset for help on using the changeset viewer.