WordPress.org

Make WordPress Core

Changeset 49802


Ignore:
Timestamp:
12/15/2020 10:16:03 PM (10 months ago)
Author:
johnbillion
Message:

Docs: Correct the documentation for the map_meta_cap() function and its filter.

See #51800

File:
1 edited

Legend:

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

    r48665 r49802  
    88
    99/**
    10  * Maps meta capabilities to primitive capabilities.
     10 * Maps a capability to the primitive capabilities required of the given user to
     11 * satisfy the capability being checked.
    1112 *
    1213 * This function also accepts an ID of an object to map against if the capability is a meta capability. Meta
    1314 * capabilities such as `edit_post` and `edit_user` are capabilities used by this function to map to primitive
    14  * capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`.
     15 * capabilities that a user or role requires, such as `edit_posts` and `edit_others_posts`.
    1516 *
    1617 * Example usage:
     
    2021 *     map_meta_cap( 'edit_post_meta', $user->ID, $post->ID, $meta_key );
    2122 *
    22  * This does not actually compare whether the user ID has the actual capability,
    23  * just what the capability or capabilities are. Meta capability list value can
    24  * be 'delete_user', 'edit_user', 'remove_user', 'promote_user', 'delete_post',
    25  * 'delete_page', 'edit_post', 'edit_page', 'read_post', or 'read_page'.
     23 * This function does not check whether the user has the required capabilities,
     24 * it just returns what the required capabilities are.
    2625 *
    2726 * @since 2.0.0
     
    3130 * @global array $post_type_meta_caps Used to get post type meta capabilities.
    3231 *
    33  * @param string $cap     Capability name.
     32 * @param string $cap     Capability being checked.
    3433 * @param int    $user_id User ID.
    3534 * @param mixed  ...$args Optional further parameters, typically starting with an object ID.
    36  * @return string[] Actual capabilities for meta capability.
     35 * @return string[] Primitive capabilities required of the user.
    3736 */
    3837function map_meta_cap( $cap, $user_id, ...$args ) {
     
    623622
    624623    /**
    625      * Filters a user's capabilities depending on specific context and/or privilege.
     624     * Filters the primitive capabilities required of the given user to satisfy the
     625     * capability being checked.
    626626     *
    627627     * @since 2.8.0
    628628     *
    629      * @param string[] $caps    Array of the user's capabilities.
    630      * @param string   $cap     Capability name.
     629     * @param string[] $caps    Primitive capabilities required of the user.
     630     * @param string   $cap     Capability being checked.
    631631     * @param int      $user_id The user ID.
    632      * @param array    $args    Adds the context to the cap. Typically the object ID.
     632     * @param array    $args    Adds context to the capability check, typically
     633     *                          starting with an object ID.
    633634     */
    634635    return apply_filters( 'map_meta_cap', $caps, $cap, $user_id, $args );
Note: See TracChangeset for help on using the changeset viewer.