From f8f60ac01b7fd37592bbcf22edb73f83945df6b8 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 27 Sep 2012 15:33:19 +0000 Subject: [PATCH] Introduce create_posts meta capability. Props scribu, nacin, casben79. see #16714 git-svn-id: http://core.svn.wordpress.org/trunk@22060 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/menu.php | 2 +- wp-includes/capabilities.php | 8 ++++++++ wp-includes/post.php | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 26e8eabbc3..d57136de22 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -49,7 +49,7 @@ $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'none' ); $submenu['edit.php'][5] = array( __('All Posts'), 'edit_posts', 'edit.php' ); /* translators: add new post */ - $submenu['edit.php'][10] = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' ); + $submenu['edit.php'][10] = array( _x('Add New', 'post'), 'create_posts', 'post-new.php' ); $i = 15; foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 3f0a9ce816..e629cf4441 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -1046,6 +1046,14 @@ function map_meta_cap( $cap, $user_id ) { $caps[] = $post_type->cap->delete_private_posts; } break; + // current_user_can( 'create_posts', $post_type ) + case 'create_posts': + $post_type = isset( $args[0] ) ? $args[0] : 'post'; + $post_type_object = get_post_type_object( $post_type ); + + $caps[] = $post_type_object->cap->create_posts; + + break; // edit_post breaks down to edit_posts, edit_published_posts, or // edit_others_posts case 'edit_post': diff --git a/wp-includes/post.php b/wp-includes/post.php index ddf78ab625..376132ea08 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1296,6 +1296,8 @@ function get_post_type_capabilities( $args ) { 'edit_others_posts' => 'edit_others_' . $plural_base, 'publish_posts' => 'publish_' . $plural_base, 'read_private_posts' => 'read_private_' . $plural_base, + // Post creation capability simply maps to edit_posts by default: + 'create_posts' => 'edit_' . $plural_base, ); // Primitive capabilities used within map_meta_cap():