[wp-trac] [WordPress Trac] #38636: Allow data attributes to be added to WP Admin Bar menu items

WordPress Trac noreply at wordpress.org
Mon Mar 5 18:40:18 UTC 2018


#38636: Allow data attributes to be added to WP Admin Bar menu items
-----------------------------------------+-----------------------------
 Reporter:  keraweb                      |       Owner:
     Type:  enhancement                  |      Status:  new
 Priority:  normal                       |   Milestone:  Future Release
Component:  Toolbar                      |     Version:
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:  accessibility
-----------------------------------------+-----------------------------

Comment (by pbiron):

 I personally have never had any uses; but the nodes I've added to the
 admin bar have always been VERY simple.

 The [[https://wordpress.org/plugins/view-admin-as/|View Admin As]] plugin
 (written by the OP) arguably has a good use case for `@aria-describedby`.


 [[Image(vaa.png)]]

 For example, the following is a simplification of the code used in VAA to
 generate the node circled in red in the above image:

 {{{
 #!php
 <?php
 $admin_bar->add_node( array(
         'id' => 'vaa-modules-role-defaults-enable',
         'parent' => $parent,
         'title' => "<label><input name='vaa_modules_role_defaults_enable'
 type='checkbox' />Enable role defaults</label>" .
                 "<p class='ab-item description'>Set default screen
 settings for roles and apply them on users through various bulk and
 automatic actions</p>",
 ) );
 }}}

 The above '''might''' be cleaner if it were written as follows (this is
 just my opinion, I haven't discussed this with the OP and don't know
 whether he'd agree):

 {{{
 #!php
 <?php
 $admin_bar->add_node( array(
         'id' => 'vaa-modules-role-defaults-enable',
         'parent' => $parent,
         'title' => "<label><input name='vaa_modules_role_defaults_enable'
 type='checkbox' />Enable role defaults</label>",
         'meta' => array( 'aria-describedby' => 'wp-admin-bar-vaa-modules-
 role-defaults-enable-description' ),
 ) );
 $admin_bar->add_node( array(
         'id' => 'vaa-modules-role-defaults-enable-description',
         'parent' => $parent,
         'title' => 'Set default screen settings for roles and apply them
 on users through various bulk and automatic actions',
 ) );
 }}}

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


More information about the wp-trac mailing list