[wp-trac] [WordPress Trac] #31020: Introduce discrete capability for managing widgets

WordPress Trac noreply at wordpress.org
Thu Jan 15 23:05:26 UTC 2015


#31020: Introduce discrete capability for managing widgets
------------------------------------+-----------------------------
 Reporter:  westonruter             |       Owner:  ocean90
     Type:  enhancement             |      Status:  reviewing
 Priority:  normal                  |   Milestone:  4.2
Component:  Widgets                 |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:  administration
------------------------------------+-----------------------------
Changes (by westonruter):

 * keywords:  needs-patch => has-patch dev-feedback
 * owner:  westonruter => ocean90
 * status:  assigned => reviewing
 * milestone:  Future Release => 4.2


Comment:

 In [attachment:31020.diff]:

 * Incorporate latest patch from #29213
 * Add `manage_widgets` cap, use instead of `edit_theme_options` where
 needed:
  * Ajax request to save a widget
  * Accessing the Widgets admin page
  * Showing the link to the widgets admin page in the admin menu
  * Showing Customizer panel, sections, and controls for Widgets and their
 settings.
  * Admin bar link to Widgets
 * Update `wp_welcome_panel` to show widgets & menus links if has caps
 * Show 3.9 pointer for Widget Customizer if user can `manage_widgets`
 * Also block access to `nav-menus.php` if user cannot `manage_widgets` and
 the theme does not support menus

 here is a sample plugin which grants access to `manage_menus` for a user
 who can `edit_posts`:

 {{{#!php
 <?php
 function allow_users_who_can_edit_posts_to_manage_widgets( $caps, $cap,
 $user_id ) {
         $required_cap = 'edit_posts';
         if ( 'manage_widgets' === $cap && user_can( $user_id,
 $required_cap ) ) {
                 $caps = array( $required_cap );
         }
         return $caps;
 }
 add_filter( 'map_meta_cap',
 'allow_users_who_can_edit_posts_to_manage_widgets', 10, 3 );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31020#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list