WordPress.org

Making WordPress.org

Ticket #1861: 1861.patch

File 1861.patch, 985 bytes (added by keesiemeijer, 5 years ago)

Add screen reader text to the jump to links

  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php

     
    118118                        } else {
    119119                                $first = false;
    120120                        }
    121 
    122                         $replacement .= sprintf( '<%1$s class="toc-heading" id="%2$s" tabindex="-1">%3$s <a href="#%2$s" class="anchor">#</a></%1$s>', $tag, $id, $item[2] );
     121                        $a11y_text = sprintf( '<span class="screen-reader-text">%s</span>', $item[2] );
     122                        $anchor    = sprintf( '<a href="#%1$s" class="anchor"><span aria-hidden="true">#</span>%2$s</a>', $id, $a11y_text );
     123                        $replacement .= sprintf( '<%1$s class="toc-heading" id="%2$s" tabindex="-1">%3$s %4$s</%1$s>', $tag, $id, $item[2], $anchor );
    123124                        $replacements[] = $replacement;
    124125                }
    125126