WordPress.org

Make WordPress Core

Ticket #36319: 36319.patch

File 36319.patch, 2.2 KB (added by johneckman, 5 years ago)

Patch to docs section to clarify filters.

  • src/wp-includes/capabilities.php

     
    251251
    252252                if ( $meta_key && ( has_filter( "auth_post_meta_{$meta_key}" ) || has_filter( "auth_post_{$post_type}_meta_{$meta_key}" ) ) ) {
    253253                        /**
    254                          * Filters whether the user is allowed to add post meta to a post.
     254                         * auth_post_meta_{$meta_key} filters whether the user is allowed to edit post meta.
    255255                         *
     256                         * If the filter is left at false, the capability to add, edit, or delete post meta will
     257                         * be added to the mapped edit_post capabilities.
     258                         *
     259                         * If the filter is set to true, only the mapped meta caps from edit_post will apply.
     260                         *
     261                         * Use the auth_post_{$post_type}_meta_{$meta_key} filter to modify capabilities for
     262                         * specific post types.
     263                         *
    256264                         * The dynamic portion of the hook name, `$meta_key`, refers to the
    257265                         * meta key passed to map_meta_cap().
    258266                         *
     
    268276                        $allowed = apply_filters( "auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps );
    269277
    270278                        /**
    271                          * Filters whether the user is allowed to add post meta to a post of a given type.
     279                         * auth_post_meta_{$meta_key} filters whether the user is allowed to edit post meta for
     280                         * a post of a given type.
    272281                         *
     282                         * If the filter is left at false, the capability to add, edit, or delete post meta will
     283                         * be added to the mapped edit_post capabilities.
     284                         *
     285                         * If the filter is set to true, only the mapped meta caps from edit_post will apply.
     286                         *
     287                         * Use the auth_post_meta_{$meta_key} filter to modify capabilities for all types.
     288                         *
    273289                         * The dynamic portions of the hook name, `$meta_key` and `$post_type`,
    274290                         * refer to the meta key passed to map_meta_cap() and the post type, respectively.
    275291                         *
     
    284300                         */
    285301                        $allowed = apply_filters( "auth_post_{$post_type}_meta_{$meta_key}", $allowed, $meta_key, $post->ID, $user_id, $cap, $caps );
    286302
    287                         if ( ! $allowed )
     303                        if ( ! $allowed ) {
    288304                                $caps[] = $cap;
     305                        }
    289306                } elseif ( $meta_key && is_protected_meta( $meta_key, 'post' ) ) {
    290307                        $caps[] = $cap;
    291308                }