From 795ab6d0f3f9eebd219ba5934e5af1324676d705 Mon Sep 17 00:00:00 2001 From: nacin Date: Wed, 10 Nov 2010 14:50:14 +0000 Subject: [PATCH] Cripple capability_type. Produced inconsistent, janky meta cap mapping; now only acts as a capability base. see #14122. git-svn-id: http://svn.automattic.com/wordpress/trunk@16273 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/capabilities.php | 18 +++++++++--------- wp-includes/post.php | 5 +---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index b5eb1491f..70d651ff5 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -826,9 +826,9 @@ function map_meta_cap( $cap, $user_id ) { $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); - if ( 'delete_post' == $cap && $post_type && 'post' != $post_type->capability_type && ! $post_type->map_meta_cap ) { - $args = array_merge( array( $post_type->cap->delete_post, $user_id ), $args ); - return call_user_func_array( 'map_meta_cap', $args ); + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + break; } if ( '' != $post->post_author && post_type_supports( $post_type->name, 'author' ) ) { @@ -869,9 +869,9 @@ function map_meta_cap( $cap, $user_id ) { $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); - if ( 'edit_post' == $cap && $post_type && 'post' != $post_type->capability_type && ! $post_type->map_meta_cap ) { - $args = array_merge( array( $post_type->cap->edit_post, $user_id ), $args ); - return call_user_func_array( 'map_meta_cap', $args ); + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + break; } if ( '' != $post->post_author && post_type_supports( $post_type->name, 'author' ) ) { @@ -911,9 +911,9 @@ function map_meta_cap( $cap, $user_id ) { $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); - if ( 'read_post' == $cap && $post_type && 'post' != $post_type->capability_type && ! $post_type->map_meta_cap ) { - $args = array_merge( array( $post_type->cap->read_post, $user_id ), $args ); - return call_user_func_array( 'map_meta_cap', $args ); + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + break; } if ( 'private' != $post->post_status ) { diff --git a/wp-includes/post.php b/wp-includes/post.php index 8286d88f3..08c8c2bd1 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -842,7 +842,7 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) * show_ui must be true. * - menu_position - The position in the menu order the post type should appear. Defaults to the bottom. * - menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon. - * - capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to 'post'. + * - capability_type - The string to use to build the read, edit, and delete capabilities. Defaults to 'post'. * May be passed as an array to allow for alternative plurals when using this argument as a base to construct the * capabilities, e.g. array('story', 'stories'). * - capabilities - Array of capabilities for this post type. By default the capability_type is used @@ -917,9 +917,6 @@ function register_post_type($post_type, $args = array()) { if ( null === $args->exclude_from_search ) $args->exclude_from_search = !$args->public; - if ( empty($args->capability_type) ) - $args->capability_type = 'post'; - $args->cap = get_post_type_capabilities( $args ); unset($args->capabilities);