[wp-trac] [WordPress Trac] #51072: Add action hook after theme skip links

WordPress Trac noreply at wordpress.org
Thu Aug 20 01:48:13 UTC 2020


#51072: Add action hook after theme skip links
-------------------------------------------------+-------------------------
 Reporter:  alexstine                            |      Owner:  (none)
     Type:  feature request                      |     Status:  new
 Priority:  normal                               |  Milestone:  Awaiting
                                                 |  Review
Component:  Themes                               |    Version:  5.5
 Severity:  normal                               |   Keywords:
  Focuses:  ui, accessibility, template,         |
  multisite, coding-standards                    |
-------------------------------------------------+-------------------------
 Not sure if this is the right place. My feature request is to add a
 default hook in themes that is after skip links. I was recently working on
 a code project where I had a widget loaded in wp_footer but had no idea
 how to dynamically add a trigger link in the header for screen readers. If
 I used jQuery to add it before the first link, it could come before skip
 links and this is bad UX. If I added it after the first link, there could
 be multiple skip links creating a mess or maybe the theme doesn't have
 skip links, it could insert after a logo. There are also themes with top
 navigation, etc. that makes this rather difficult to figure out how to
 dynamically insert a trigger link.

 If theme guidelines were updated to require a hook after skip links, I
 could simply add my trigger link like this.

 {{{#!php
 <?php
 add_action( 'theme_after_skip_links', function() {
 echo '<a href="#" class="my-trigger screen-reader-text">Trigger Link</a>';
 }); ?>
 }}}

 In the header.php file, it might look something like this.

 {{{#!php
 <?php
 // header.php code
 echo '<a href="#main" class="screen-reader-text skip-link">Skip to main
 content</a>';
 do_action( 'theme_after_skip_links' );
 ?>
 }}}

 Hopefully others will agree that there are situations this could be really
 useful to plugin and even child theme developers.

 Thanks.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51072>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list