Make WordPress Core

Changeset 60294


Ignore:
Timestamp:
06/09/2025 06:49:44 PM (6 weeks ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Remove redundant empty() checks in map_meta_cap().

There is already a check for empty( $object_subtype ) that exits the current case branch a few lines earlier.

Follow-up to [39179], [43378].

Props justlevine.
See #63268.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/capabilities.php

    r59239 r60294  
    471471                $allowed = ! is_protected_meta( $meta_key, $object_type );
    472472
    473                 if ( ! empty( $object_subtype ) && has_filter( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}" ) ) {
     473                if ( has_filter( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}" ) ) {
    474474
    475475                    /**
     
    513513                }
    514514
    515                 if ( ! empty( $object_subtype ) ) {
    516 
    517                     /**
    518                      * Filters whether the user is allowed to edit meta for specific object types/subtypes.
    519                      *
    520                      * Return true to have the mapped meta caps from `edit_{$object_type}` apply.
    521                      *
    522                      * The dynamic portion of the hook name, `$object_type` refers to the object type being filtered.
    523                      * The dynamic portion of the hook name, `$object_subtype` refers to the object subtype being filtered.
    524                      * The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap().
    525                      *
    526                      * @since 4.6.0 As `auth_post_{$post_type}_meta_{$meta_key}`.
    527                      * @since 4.7.0 Renamed from `auth_post_{$post_type}_meta_{$meta_key}` to
    528                      *              `auth_{$object_type}_{$object_subtype}_meta_{$meta_key}`.
    529                      * @deprecated 4.9.8 Use {@see 'auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}'} instead.
    530                      *
    531                      * @param bool     $allowed   Whether the user can add the object meta. Default false.
    532                      * @param string   $meta_key  The meta key.
    533                      * @param int      $object_id Object ID.
    534                      * @param int      $user_id   User ID.
    535                      * @param string   $cap       Capability name.
    536                      * @param string[] $caps      Array of the user's capabilities.
    537                      */
    538                     $allowed = apply_filters_deprecated(
    539                         "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}",
    540                         array( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ),
    541                         '4.9.8',
    542                         "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}"
    543                     );
    544                 }
     515                /**
     516                 * Filters whether the user is allowed to edit meta for specific object types/subtypes.
     517                 *
     518                 * Return true to have the mapped meta caps from `edit_{$object_type}` apply.
     519                 *
     520                 * The dynamic portion of the hook name, `$object_type` refers to the object type being filtered.
     521                 * The dynamic portion of the hook name, `$object_subtype` refers to the object subtype being filtered.
     522                 * The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap().
     523                 *
     524                 * @since 4.6.0 As `auth_post_{$post_type}_meta_{$meta_key}`.
     525                 * @since 4.7.0 Renamed from `auth_post_{$post_type}_meta_{$meta_key}` to
     526                 *              `auth_{$object_type}_{$object_subtype}_meta_{$meta_key}`.
     527                 * @deprecated 4.9.8 Use {@see 'auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}'} instead.
     528                 *
     529                 * @param bool     $allowed   Whether the user can add the object meta. Default false.
     530                 * @param string   $meta_key  The meta key.
     531                 * @param int      $object_id Object ID.
     532                 * @param int      $user_id   User ID.
     533                 * @param string   $cap       Capability name.
     534                 * @param string[] $caps      Array of the user's capabilities.
     535                 */
     536                $allowed = apply_filters_deprecated(
     537                    "auth_{$object_type}_{$object_subtype}_meta_{$meta_key}",
     538                    array( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ),
     539                    '4.9.8',
     540                    "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}"
     541                );
    545542
    546543                if ( ! $allowed ) {
Note: See TracChangeset for help on using the changeset viewer.