WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#17005 new enhancement

Replace cryptic bitwise check with proper post type checks

Reported by: nacin Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

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 (3)

comment:1 duck_3 years ago

[17574]

Updating the check for all post types with an editor and adding a check for comment keyboard shortcuts still not done.

comment:2 jane3 years ago

Punting, no patch and past freeze.

comment:3 nacin3 years ago

  • Milestone changed from 3.2 to Future Release

Punt. Initial bitwise is gone. Still considering the supports bits.

Note: See TracTickets for help on using tickets.