Use $ptype_obj->edit_type_cap instead of 'edit_posts' for custom post_type menu's & edit.php access. Allows for a user to have the capability to edit a post_type irrespective of their Posts access. Props rovo89. Fixes #12691

git-svn-id: http://svn.automattic.com/wordpress/trunk@13841 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-03-27 06:40:59 +00:00
parent 99c832385e
commit 284a6cbc63
2 changed files with 13 additions and 13 deletions

View File

@ -9,17 +9,6 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
if ( !current_user_can('edit_posts') )
wp_die(__('Cheatin’ uh?'));
// Back-compat for viewing comments of an entry
if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) {
wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) );
exit;
} else {
unset( $_redirect );
}
if ( !isset($_GET['post_type']) )
$post_type = 'post';
elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
@ -30,6 +19,17 @@ $_GET['post_type'] = $post_type;
$post_type_object = get_post_type_object($post_type);
if ( !current_user_can($post_type_object->edit_type_cap) )
wp_die(__('Cheatin’ uh?'));
// Back-compat for viewing comments of an entry
if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) {
wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) );
exit;
} else {
unset( $_redirect );
}
if ( 'post' != $post_type ) {
$parent_file = "edit.php?post_type=$post_type";
$submenu_file = "edit.php?post_type=$post_type";

View File

@ -118,9 +118,9 @@ foreach ( (array) get_post_types( array('show_ui' => true) ) as $ptype ) {
$ptype_obj = get_post_type_object($ptype);
$menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-posts', 'menu-' . sanitize_html_class($ptype), 'div');
$submenu["edit.php?post_type=$ptype"][5] = array( __('Edit'), 'edit_posts', "edit.php?post_type=$ptype");
$submenu["edit.php?post_type=$ptype"][5] = array( __('Edit'), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype");
/* translators: add new custom post type */
$submenu["edit.php?post_type=$ptype"][10] = array( _x('Add New', 'post'), 'edit_posts', "post-new.php?post_type=$ptype" );
$submenu["edit.php?post_type=$ptype"][10] = array( _x('Add New', 'post'), $ptype_obj->edit_type_cap, "post-new.php?post_type=$ptype" );
$i = 15;
foreach ( $wp_taxonomies as $tax ) {