Make WordPress Core

Opened 14 years ago

Closed 9 years ago

Last modified 9 years ago

#17005 closed enhancement (fixed)

Replace cryptic bitwise check with proper post type checks

Reported by: nacin's profile nacin Owned by:
Milestone: 3.2 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: needs-patch
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 (6)

#1 @duck_
14 years ago

[17574]

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

#2 @jane
14 years ago

Punting, no patch and past freeze.

#3 @nacin
14 years ago

  • Milestone changed from 3.2 to Future Release

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

#4 @chriscct7
10 years ago

  • Keywords needs-patch added

Any update on this @nacin?

#5 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from new to closed

[17574] Marking as fixed

#6 @helen
9 years ago

  • Milestone changed from Future Release to 3.2
Note: See TracTickets for help on using tickets.