Clean up get_post_type_capabilities. Don't bother with new capabilities for edit_others_posts and delete_others_posts if the post type does not support authors.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15892 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c46c3c4637
commit
02440f343c
|
@ -989,8 +989,6 @@ function register_post_type($post_type, $args = array()) {
|
||||||
* @return object object with all the capabilities as member variables
|
* @return object object with all the capabilities as member variables
|
||||||
*/
|
*/
|
||||||
function get_post_type_capabilities( $args ) {
|
function get_post_type_capabilities( $args ) {
|
||||||
global $_post_type_meta_capabilities;
|
|
||||||
|
|
||||||
$default_capabilities = array(
|
$default_capabilities = array(
|
||||||
// Meta capabilities are generally mapped to primitive capabilities depending on the context
|
// Meta capabilities are generally mapped to primitive capabilities depending on the context
|
||||||
// (which would be the post being edited/deleted/read), instead of granted to users or roles:
|
// (which would be the post being edited/deleted/read), instead of granted to users or roles:
|
||||||
|
@ -1003,22 +1001,33 @@ function get_post_type_capabilities( $args ) {
|
||||||
'publish_posts' => 'publish_' . $args->capability_type . 's',
|
'publish_posts' => 'publish_' . $args->capability_type . 's',
|
||||||
'read_private_posts' => 'read_private_' . $args->capability_type . 's',
|
'read_private_posts' => 'read_private_' . $args->capability_type . 's',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Primitive capabilities that are used within map_meta_cap():
|
// Primitive capabilities that are used within map_meta_cap():
|
||||||
if ( $args->map_meta_cap ) {
|
if ( $args->map_meta_cap ) {
|
||||||
$default_capabilities_for_mapping = array(
|
$default_capabilities_for_mapping = array(
|
||||||
'read' => 'read',
|
'read' => 'read',
|
||||||
'delete_posts' => 'delete_' . $args->capability_type . 's',
|
'delete_posts' => 'delete_' . $args->capability_type . 's',
|
||||||
'delete_private_posts' => 'delete_private_' . $args->capability_type . 's',
|
'delete_private_posts' => 'delete_private_' . $args->capability_type . 's',
|
||||||
'delete_published_posts' => 'delete_published_' . $args->capability_type . 's',
|
'delete_published_posts' => 'delete_published_' . $args->capability_type . 's',
|
||||||
'delete_others_posts' => 'delete_others_' . $args->capability_type . 's',
|
'delete_others_posts' => 'delete_others_' . $args->capability_type . 's',
|
||||||
'edit_private_posts' => 'edit_private_' . $args->capability_type . 's',
|
'edit_private_posts' => 'edit_private_' . $args->capability_type . 's',
|
||||||
'edit_published_posts' => 'edit_published_' . $args->capability_type . 's',
|
'edit_published_posts' => 'edit_published_' . $args->capability_type . 's',
|
||||||
);
|
);
|
||||||
$default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );
|
$default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! post_type_supports( $args->name, 'author' ) ) {
|
||||||
|
// While these may be checked in core, users/roles shouldn't need to be granted these.
|
||||||
|
$default_capabilities['edit_others_posts'] = $default_capabilities['edit_posts'];
|
||||||
|
$default_capabilities['delete_others_posts'] = $default_capabilities['delete_posts'];
|
||||||
|
}
|
||||||
|
|
||||||
$capabilities = array_merge( $default_capabilities, $args->capabilities );
|
$capabilities = array_merge( $default_capabilities, $args->capabilities );
|
||||||
|
|
||||||
|
// Remember meta capabilities for future reference.
|
||||||
if ( $args->map_meta_cap )
|
if ( $args->map_meta_cap )
|
||||||
_post_type_meta_capabilities( $capabilities );
|
_post_type_meta_capabilities( $capabilities );
|
||||||
|
|
||||||
return (object) $capabilities;
|
return (object) $capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue