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:
parent
9b51769311
commit
c161ae3d7d
@ -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";
|
||||
|
@ -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 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user