[wp-trac] [WordPress Trac] #23226: Always use meta caps directly instead of going through the post_type_object->caps array

WordPress Trac noreply at wordpress.org
Thu Jan 17 17:14:43 UTC 2013


#23226: Always use meta caps directly instead of going through the
post_type_object->caps array
-------------------------+-----------------------------
 Reporter:  markjaquith  |       Type:  defect (bug)
   Status:  new          |   Priority:  normal
Milestone:  3.6          |  Component:  Role/Capability
  Version:               |   Severity:  normal
 Keywords:               |
-------------------------+-----------------------------
 When using post-related meta caps in core, we should use their meta cap
 name instead of manually digging into the post object looking for the cap.

 e.g.

 Do this:

 {{{
 if ( ! current_user_can( 'edit_post', $post_id ) ) {
   // ...
 }
 }}}

 Instead of this:

 {{{
 $post_type = get_post_type_object( get_post_type( $post_id ) );
 if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
   // ...
 }
 }}}

 Our meta caps resolve custom caps for the meta caps (if someone has been
 foolish enough to use them), and we should be consistent about doing it
 that way so people know that's the right way to do it.

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


More information about the wp-trac mailing list