WordPress.org

Make WordPress Core

Changeset 41800


Ignore:
Timestamp:
10/09/17 19:13:43 (2 months ago)
Author:
adamsilverstein
Message:

Docs: add docs for meta authorization filters.

Add filter documentation for auth_{$object_type}_meta_{$meta_key} and auth_{$object_type}_{$sub_type}_meta_{$meta_key}.

Props ericlewis, johneckman, DrewAPicture.
Fixes #36319.

File:
1 edited

Legend:

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

    r41322 r41800  
    309309        $has_filter = has_filter( "auth_{$object_type}_meta_{$meta_key}" ) || has_filter( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}" ); 
    310310        if ( $meta_key && $has_filter ) { 
    311             /** This filter is documented in wp-includes/meta.php */ 
     311 
     312            /** 
     313             * Filters whether the user is allowed to edit meta. 
     314             * 
     315             * Use the {@see auth_post_$object_type_meta_$meta_key} filter to modify capabilities for 
     316             * specific object types. Return true to have the mapped meta caps from edit_{$object_type} apply. 
     317             * 
     318             * The dynamic portion of the hook name, `$object_type` refers to the object type being filtered. 
     319             * The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap(). 
     320             * 
     321             * @since 3.3.0 As 'auth_post_meta_{$meta_key}'. 
     322             * @since 4.6.0 
     323             * 
     324             * @param bool   $allowed  Whether the user can add the post meta. Default false. 
     325             * @param string $meta_key The meta key. 
     326             * @param int    $post_id  Post ID. 
     327             * @param int    $user_id  User ID. 
     328             * @param string $cap      Capability name. 
     329             * @param array  $caps     User capabilities. 
     330             */ 
    312331            $allowed = apply_filters( "auth_{$object_type}_meta_{$meta_key}", false, $meta_key, $object_id, $user_id, $cap, $caps ); 
    313332 
    314             /** This filter is documented in wp-includes/meta.php */ 
     333            /** 
     334             * Filters whether the user is allowed to add post meta to a post of a given type. 
     335             * 
     336             * Use the {@see auth_$object_type_$sub_type_meta_$meta_key} filter to modify capabilities for 
     337             * specific object types/subtypes. Return true to have the mapped meta caps from edit_{$object_type} apply. 
     338             * 
     339             * The dynamic portion of the hook name, `$object_type` refers to the object type being filtered. 
     340             * The dynamic portion of the hook name, `$sub_type` refers to the object subtype being filtered. 
     341             * The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap(). 
     342             * 
     343             * @since 4.6.0 As 'auth_post_{$post_type}_meta_{$meta_key}'. 
     344             * @since 4.7.0 
     345             * 
     346             * @param bool   $allowed  Whether the user can add the post meta. Default false. 
     347             * @param string $meta_key The meta key. 
     348             * @param int    $post_id  Post ID. 
     349             * @param int    $user_id  User ID. 
     350             * @param string $cap      Capability name. 
     351             * @param array  $caps     User capabilities. 
     352             */ 
    315353            $allowed = apply_filters( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps ); 
    316354 
Note: See TracChangeset for help on using the changeset viewer.