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

    r47611 r47808  
    174174
    175175    $column    = sanitize_key( $meta_type . '_id' );
    176     $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
     176    $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
    177177
    178178    // expected_slashed ($meta_key)
     
    249249        do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
    250250
    251         if ( 'post' == $meta_type ) {
     251        if ( 'post' === $meta_type ) {
    252252            /**
    253253             * Fires immediately before updating a post's metadata.
     
    288288        do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
    289289
    290         if ( 'post' == $meta_type ) {
     290        if ( 'post' === $meta_type ) {
    291291            /**
    292292             * Fires immediately after updating a post's metadata.
     
    347347
    348348    $type_column = sanitize_key( $meta_type . '_id' );
    349     $id_column   = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
     349    $id_column   = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
     350
    350351    // expected_slashed ($meta_key)
    351352    $meta_key   = wp_unslash( $meta_key );
     
    416417
    417418    // Old-style action.
    418     if ( 'post' == $meta_type ) {
     419    if ( 'post' === $meta_type ) {
    419420        /**
    420421         * Fires immediately before deleting metadata for a post.
     
    459460
    460461    // Old-style action.
    461     if ( 'post' == $meta_type ) {
     462    if ( 'post' === $meta_type ) {
    462463        /**
    463464         * Fires immediately after deleting metadata for a post.
     
    621622    }
    622623
    623     $id_column = ( 'user' == $meta_type ) ? 'umeta_id' : 'meta_id';
     624    $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
    624625
    625626    /**
     
    686687
    687688    $column    = sanitize_key( $meta_type . '_id' );
    688     $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
     689    $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
    689690
    690691    /**
     
    741742        do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
    742743
    743         if ( 'post' == $meta_type ) {
     744        if ( 'post' === $meta_type ) {
    744745            /** This action is documented in wp-includes/meta.php */
    745746            do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
     
    758759        do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
    759760
    760         if ( 'post' == $meta_type ) {
     761        if ( 'post' === $meta_type ) {
    761762            /** This action is documented in wp-includes/meta.php */
    762763            do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
     
    802803    // Object and ID columns.
    803804    $column    = sanitize_key( $meta_type . '_id' );
    804     $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
     805    $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
    805806
    806807    /**
     
    830831
    831832        // Old-style action.
    832         if ( 'post' == $meta_type || 'comment' == $meta_type ) {
     833        if ( 'post' === $meta_type || 'comment' === $meta_type ) {
    833834            /**
    834835             * Fires immediately before deleting post or comment metadata of a specific type.
     
    854855
    855856        // Old-style action.
    856         if ( 'post' == $meta_type || 'comment' == $meta_type ) {
     857        if ( 'post' === $meta_type || 'comment' === $meta_type ) {
    857858            /**
    858859             * Fires immediately after deleting post or comment metadata of a specific type.
     
    944945    // Get meta info.
    945946    $id_list   = join( ',', $ids );
    946     $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
     947    $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';
     948
    947949    $meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A );
    948950
     
    10461048 */
    10471049function is_protected_meta( $meta_key, $meta_type = '' ) {
    1048     $protected = ( '_' == $meta_key[0] );
     1050    $protected = ( '_' === $meta_key[0] );
    10491051
    10501052    /**
Note: See TracChangeset for help on using the changeset viewer.