Docs: Improve documentation for meta capability filters.

Remove self-references, correct parameter names and descriptions.

Props milana_cap, ocean90, SergeyBiryukov.
Fixes #43504.

git-svn-id: https://develop.svn.wordpress.org/trunk@42809 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2018-03-08 23:18:35 +00:00
parent 453ef7f1c6
commit 70f795bc74

View File

@ -314,45 +314,43 @@ function map_meta_cap( $cap, $user_id ) {
if ( $meta_key && $has_filter ) { if ( $meta_key && $has_filter ) {
/** /**
* Filters whether the user is allowed to edit meta. * Filters whether the user is allowed to edit meta for specific object types.
* *
* Use the {@see auth_post_$object_type_meta_$meta_key} filter to modify capabilities for * Return true to have the mapped meta caps from `edit_{$object_type}` apply.
* specific object types. Return true to have the mapped meta caps from edit_{$object_type} apply.
* *
* The dynamic portion of the hook name, `$object_type` refers to the object type being filtered. * The dynamic portion of the hook name, `$object_type` refers to the object type being filtered.
* The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap(). * The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap().
* *
* @since 3.3.0 As 'auth_post_meta_{$meta_key}'. * @since 3.3.0 As `auth_post_meta_{$meta_key}`.
* @since 4.6.0 * @since 4.6.0
* *
* @param bool $allowed Whether the user can add the post meta. Default false. * @param bool $allowed Whether the user can add the object meta. Default false.
* @param string $meta_key The meta key. * @param string $meta_key The meta key.
* @param int $post_id Post ID. * @param int $object_id Object ID.
* @param int $user_id User ID. * @param int $user_id User ID.
* @param string $cap Capability name. * @param string $cap Capability name.
* @param array $caps User capabilities. * @param array $caps User capabilities.
*/ */
$allowed = apply_filters( "auth_{$object_type}_meta_{$meta_key}", false, $meta_key, $object_id, $user_id, $cap, $caps ); $allowed = apply_filters( "auth_{$object_type}_meta_{$meta_key}", false, $meta_key, $object_id, $user_id, $cap, $caps );
/** /**
* Filters whether the user is allowed to add post meta to a post of a given type. * Filters whether the user is allowed to edit meta for specific object types/subtypes.
* *
* Use the {@see auth_$object_type_$sub_type_meta_$meta_key} filter to modify capabilities for * Return true to have the mapped meta caps from `edit_{$object_type}` apply.
* specific object types/subtypes. Return true to have the mapped meta caps from edit_{$object_type} apply.
* *
* The dynamic portion of the hook name, `$object_type` refers to the object type being filtered. * The dynamic portion of the hook name, `$object_type` refers to the object type being filtered.
* The dynamic portion of the hook name, `$sub_type` refers to the object subtype being filtered. * The dynamic portion of the hook name, `$sub_type` refers to the object subtype being filtered.
* The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap(). * The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap().
* *
* @since 4.6.0 As 'auth_post_{$post_type}_meta_{$meta_key}'. * @since 4.6.0 As `auth_post_{$post_type}_meta_{$meta_key}`.
* @since 4.7.0 * @since 4.7.0
* *
* @param bool $allowed Whether the user can add the post meta. Default false. * @param bool $allowed Whether the user can add the object meta. Default false.
* @param string $meta_key The meta key. * @param string $meta_key The meta key.
* @param int $post_id Post ID. * @param int $object_id Object ID.
* @param int $user_id User ID. * @param int $user_id User ID.
* @param string $cap Capability name. * @param string $cap Capability name.
* @param array $caps User capabilities. * @param array $caps User capabilities.
*/ */
$allowed = apply_filters( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps ); $allowed = apply_filters( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps );