Advertisements

get_post_type_capabilities

Definition:
function get_post_type_capabilities( $args ) {}

Builds an object with all post type capabilities out of a post type object
Post type capabilities use the ‘capability_type’ argument as a base, if the capability is not set in the ‘capabilities’ argument array or if the ‘capabilities’ argument is not supplied.

Parameters

  • object $args: Post type registration arguments

Return values

returns:with all the capabilities as member variables

Source code

function get_post_type_capabilities( $args ) {

	if ( ! is_array( $args->capability_type ) )

		$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );



	// Singular base for meta capabilities, plural base for primitive capabilities.

	list( $singular_base, $plural_base ) = $args->capability_type;



	$default_capabilities = array(

		// Meta capabilities

		'edit_post'          => 'edit_'         . $singular_base,

		'read_post'          => 'read_'         . $singular_base,

		'delete_post'        => 'delete_'       . $singular_base,

		// Primitive capabilities used outside of map_meta_cap():

		'edit_posts'         => 'edit_'         . $plural_base,

		'edit_others_posts'  => 'edit_others_'  . $plural_base,

		'publish_posts'      => 'publish_'      . $plural_base,

		'read_private_posts' => 'read_private_' . $plural_base,

	);



	// Primitive capabilities used within map_meta_cap():

	if ( $args->map_meta_cap ) {

		$default_capabilities_for_mapping = array(

			'read'                   => 'read',

			'delete_posts'           => 'delete_'           . $plural_base,

			'delete_private_posts'   => 'delete_private_'   . $plural_base,

			'delete_published_posts' => 'delete_published_' . $plural_base,

			'delete_others_posts'    => 'delete_others_'    . $plural_base,

			'edit_private_posts'     => 'edit_private_'     . $plural_base,

			'edit_published_posts'   => 'edit_published_'   . $plural_base,

		);

		$default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );

	}



	$capabilities = array_merge( $default_capabilities, $args->capabilities );



	// Remember meta capabilities for future reference.

	if ( $args->map_meta_cap )

		_post_type_meta_capabilities( $capabilities );



	return (object) $capabilities;

}

1628

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: