WordPress生成文章类型角色权限函数:get_post_type_capabilities

WordPress函数get_post_type_capabilities用于快速生成文章类型角色权限。

get_post_type_capabilities( object $args )

函数参数

$args

对象

参考register_post_type()函数的参数说明,必须的参数:capability_type、capabilities、map_meta_cap

函数返回值

stdClass Object
(
    [edit_post] => edit_post
    [read_post] => read_post
    [delete_post] => delete_post
    [edit_posts] => edit_posts
    [edit_others_posts] => edit_others_posts
    [delete_posts] => delete_posts
    [publish_posts] => publish_posts
    [read_private_posts] => read_private_posts
    [create_posts] => edit_posts
)

函数使用示例

$args = array(
	'capability_type' => 'post',
	'capabilities' => array(),
	'map_meta_cap' => false
);
print_r(get_post_type_capabilities((object) $args));

扩展阅读

get_post_type_capabilities()函数位于:wp-includes/post.php

相关函数:

Typora