Skip to content

Commit

Permalink
Revert "Improve screen reader experience on site meta lists"
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwoodnz authored Oct 11, 2023
1 parent 787ce24 commit 33aaaa0
Showing 1 changed file with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,29 +96,15 @@ function( $field ) use ( $attributes ) {
}

foreach ( $meta_fields as $field ) {
list('type' => $type, 'key' => $key, 'label' => $label) = $field;
$value = get_value( $type, $key, $block->context['postId'] );
$aria_label = $label . ': ' . wp_strip_all_tags( $value );

// Hide these from values from screen readers as they do not contain links.
$aria_hide_value = in_array( $key, array( 'country', 'published' ) )
? ' aria-hidden="true"'
: '';

$html_label = $show_label
? sprintf( '<strong aria-hidden="true">%1$s</strong>', $label )
: '';
$value = get_value( $field['type'], $field['key'], $block->context['postId'] );

if ( ! empty( $value ) ) {
$list_items[] = sprintf(
'<li class="is-meta-%1$s" aria-label="%2$s">
%3$s<span%4$s>%5$s</span>
</li>',
$key,
$aria_label,
wp_kses_post( $html_label ),
$aria_hide_value,
wp_kses_post( $value ),
'<li class="is-meta-%1$s"><strong%2$s>%3$s</strong> <span>%4$s</span></li>',
$field['key'],
$show_label ? '' : ' class="screen-reader-text"',
$field['label'],
wp_kses_post( $value )
);
}
}
Expand Down

0 comments on commit 33aaaa0

Please sign in to comment.