mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
Accessibility: Add aria-current to the Archives, Categories, and Recent Posts widgets output.
The `aria-current` attribute is a simple, effective, way to help assistive technology users orientate themselves within a list of items. Continues the introduction in core of the `aria-current` attribute after [41359] and following changes. Props audrasjb, melchoyce. Fixes #47094. git-svn-id: https://develop.svn.wordpress.org/trunk@46163 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -93,11 +93,16 @@ class WP_Widget_Recent_Posts extends WP_Widget {
|
||||
<ul>
|
||||
<?php foreach ( $r->posts as $recent_post ) : ?>
|
||||
<?php
|
||||
$post_title = get_the_title( $recent_post->ID );
|
||||
$title = ( ! empty( $post_title ) ) ? $post_title : __( '(no title)' );
|
||||
$post_title = get_the_title( $recent_post->ID );
|
||||
$title = ( ! empty( $post_title ) ) ? $post_title : __( '(no title)' );
|
||||
$aria_current = '';
|
||||
|
||||
if ( get_queried_object_id() === $recent_post->ID ) {
|
||||
$aria_current = ' aria-current="page"';
|
||||
}
|
||||
?>
|
||||
<li>
|
||||
<a href="<?php the_permalink( $recent_post->ID ); ?>"><?php echo $title; ?></a>
|
||||
<a href="<?php the_permalink( $recent_post->ID ); ?>"<?php echo $aria_current; ?>><?php echo $title; ?></a>
|
||||
<?php if ( $show_date ) : ?>
|
||||
<span class="post-date"><?php echo get_the_date( '', $recent_post->ID ); ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user