GC_Customize_Manager::grant_edit_post_capability_for_changeset()
最后更新于:2021-11-27 01:01:09
GC_Customize_Manager::grant_edit_post_capability_for_changeset( string[]$caps, string$cap, int$user_id, array$args)Re-map ‘edit_post’ meta cap for a customize_changeset post to be the same as ‘customize’ maps.
参数
- $caps
-
(string[]) (Required) Array of the user’s capabilities.
- $cap
-
(string) (Required) Capability name.
- $user_id
-
(int) (Required) The user ID.
- $args
-
(array) (Required) Adds the context to the cap. Typically the object ID.
响应
(array) Capabilities.
源文件
文件: gc-includes/class-gc-customize-manager.php
public function grant_edit_post_capability_for_changeset( $caps, $cap, $user_id, $args ) {
if ( 'edit_post' === $cap && ! empty( $args[0] ) && 'customize_changeset' === get_post_type( $args[0] ) ) {
$post_type_obj = get_post_type_object( 'customize_changeset' );
$caps = map_meta_cap( $post_type_obj->cap->$cap, $user_id );
}
return $caps;
}