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: https://develop.svn.wordpress.org/trunk@13841 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse
2010-03-27 06:40:59 +00:00
parent 9b51769311
commit c161ae3d7d
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";