Friday, December 23, 2022
HomeWordPress Developmentcustomized publish sorts - Understanding capabilities parameter in register_post_type()

customized publish sorts – Understanding capabilities parameter in register_post_type()


Up to now what I’ve understood:

Capabilities parameter permits the plugin to set edit, learn and delete capabilities for a sure post_type relevant to the all person roles. The primitive capabilities are a by-product of those. For the eight different primitive caps reference by way of map_meta_cap, ought to the coder manually set every of those for every set of roles or are by default set in response to the meta caps?

Additionally why the necessity to specify the capability_type to be used in?:

[cap] => stdClass Object
(
    // Meta capabilities

    [edit_post]      => "edit_{$capability_type}"
    [read_post]      => "read_{$capability_type}"
    [delete_post]        => "delete_{$capability_type}"

    // Primitive capabilities used exterior of map_meta_cap():

    [edit_posts]         => "edit_{$capability_type}s"
    [edit_others_posts]  => "edit_others_{$capability_type}s"
    [publish_posts]      => "publish_{$capability_type}s"
    [read_private_posts]     => "read_private_{$capability_type}s"

    // Primitive capabilities used inside map_meta_cap():

    [read]                   => "learn",
    [delete_posts]           => "delete_{$capability_type}s"
    [delete_private_posts]   => "delete_private_{$capability_type}s"
    [delete_published_posts] => "delete_published_{$capability_type}s"
    [delete_others_posts]    => "delete_others_{$capability_type}s"
    [edit_private_posts]     => "edit_private_{$capability_type}s"
    [edit_published_posts]   => "edit_published_{$capability_type}s"
    [create_posts]           => "edit_{$capability_type}s"
)

Why not simply use the capability_type in index and set boolean values for every? like:

[edit_{$capability_type}] => bool

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments