[wp-trac] [WordPress Trac] #17005: Replace cryptic bitwise check with proper post type checks

WordPress Trac wp-trac at lists.automattic.com
Thu Mar 31 06:31:58 UTC 2011


#17005: Replace cryptic bitwise check with proper post type checks
-------------------------+-----------------
 Reporter:  nacin        |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  3.2
Component:  Post Types   |    Version:
 Severity:  normal       |   Keywords:
-------------------------+-----------------
 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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17005>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list