Skip to content

Commit

Permalink
Footnotes: Add aria-label to return links (#54843)
Browse files Browse the repository at this point in the history
* Add aria-label to footnotes front-end links.

* Add visual output. Fix PHPCS errors.

* Remove visual changes, fix in follow-up.
  • Loading branch information
alexstine authored and mikachan committed Sep 29, 2023
1 parent 3375dbc commit 9949351
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/block-library/src/footnotes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,20 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
}

$wrapper_attributes = get_block_wrapper_attributes();
$footnote_index = 1;

$block_content = '';

foreach ( $footnotes as $footnote ) {
// Translators: %d: Integer representing the number of return links on the page.
$aria_label = sprintf( __( 'Jump to footnote reference %1$d' ), $footnote_index );
$block_content .= sprintf(
'<li id="%1$s">%2$s <a href="#%1$s-link">↩︎</a></li>',
'<li id="%1$s">%2$s <a href="#%1$s-link" aria-label="%3$s">↩︎</a></li>',
$footnote['id'],
$footnote['content']
$footnote['content'],
$aria_label
);
++$footnote_index;
}

return sprintf(
Expand Down

0 comments on commit 9949351

Please sign in to comment.