[wp-trac] [WordPress Trac] #17528: Comments menu has sub-menu despite only having one item

WordPress Trac wp-trac at lists.automattic.com
Thu Jun 23 17:21:01 UTC 2011


#17528: Comments menu has sub-menu despite only having one item
-------------------------------+-----------------------
 Reporter:  kawauso            |       Owner:  ryan
     Type:  defect (bug)       |      Status:  reopened
 Priority:  normal             |   Milestone:  3.2
Component:  Administration     |     Version:  3.2
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |
-------------------------------+-----------------------

Comment (by kevinB):

 Here's a paraphrase of what said plugin does if the logged user has been
 granted editing capabilities for certain posts, but not post creation
 capability:

 {{{
 // Remove "Add New" submenu items if user can only edit existing posts.
 // This executes on the 'admin_init' action.
 global $submenu;

 foreach ( get_post_types() as $type ) {
    $edit_key = 'edit.php';
    $add_key = 'post-new.php';

    if ( 'post' != $type ) {
       $edit_key .= "?post_type=$type";
       $add_key .= "?post_type=$type";
    }

    if ( isset($submenu[$edit_key]) ) {
       foreach ( $submenu[$edit_key] as $key => $arr ) {
          if ( isset($arr['2']) && ( $add_key == $arr['2'] ) ) {
             if ( ! plugin_func_user_can_add_posts( $type ) )
                unset( $submenu[$edit_key][$key] );
          }
       }
    }
 }
 }}}

 I remember some discussion of core support for a "create_posts"
 capability, so this may not be just a plugin issue.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17528#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list