#17005 closed enhancement (fixed)
Replace cryptic bitwise check with proper post type checks
| Reported by: | nacin | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.2 |
| Component: | Posts, Post Types | Version: | |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | Focuses: |
Description
wp-admin/user-edit.php:54:
$all_post_caps = array('posts', 'pages');
$user_can_edit = false;
foreach ( $all_post_caps as $post_cap )
$user_can_edit |= current_user_can("edit_$post_cap");
Could become:
$user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
It could also become:
$show_ui_post_types = get_post_types( ( 'show_ui' => true ) );
$user_can_edit = false;
foreach ( $show_ui_post_types as $pt ) {
if ( current_user_can( $pt->cap->edit_posts ) ) {
$user_can_edit = true;
break;
}
}
unset( $show_ui_post_types, $pt );
Taking it further, show_ui might not be the right check, since $user_can_edit is also used for comment moderation keyboard shortcuts. So perhaps we need two results, one that checks show_ui and post_type_supports (for editor), and another that simply checks whether any post type supports comments.
Change History (6)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
[17574]
Updating the check for all post types with an editor and adding a check for comment keyboard shortcuts still not done.