Skip to content

Commit

Permalink
Themes: Remove title attributes from theme list tables.
Browse files Browse the repository at this point in the history
This changeset updates the old list tables for themes and theme installation to remove `title` attributes or replace them with a more acessible implementation:
- Removes `title` attributes from `span` elements
- Replaces `title` with `aria-label` for links whose visible text starts with the same word, consistently with links on the "Add Plugins" screen
- Reuses the `$preview_title` variable to keep ARIA labels consistent for both Preview links

Follow-up to [22439], [27548], [31513], [32991], [50804], [53414].

Props karlgroves, sabernhardt, audrasjb, alh0319.
Fixes #62834.
See #24766.




git-svn-id: https://develop.svn.wordpress.org/trunk@59675 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
audrasjb committed Jan 21, 2025
1 parent 396f6fb commit 61b7b97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions src/wp-admin/includes/class-wp-theme-install-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public function single_row( $theme ) {
switch ( $status ) {
case 'update_available':
$actions[] = sprintf(
'<a class="install-now" href="%s" title="%s">%s</a>',
'<a class="install-now" href="%s" aria-label="%s">%s</a>',
esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ),
/* translators: %s: Theme version. */
esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ),
Expand All @@ -325,15 +325,14 @@ public function single_row( $theme ) {
case 'newer_installed':
case 'latest_installed':
$actions[] = sprintf(
'<span class="install-now" title="%s">%s</span>',
esc_attr__( 'This theme is already installed and is up to date' ),
'<span class="install-now">%s</span>',
_x( 'Installed', 'theme' )
);
break;
case 'install':
default:
$actions[] = sprintf(
'<a class="install-now" href="%s" title="%s">%s</a>',
'<a class="install-now" href="%s" aria-label="%s">%s</a>',
esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ),
/* translators: %s: Theme name. */
esc_attr( sprintf( _x( 'Install %s', 'theme' ), $name ) ),
Expand All @@ -343,10 +342,9 @@ public function single_row( $theme ) {
}

$actions[] = sprintf(
'<a class="install-theme-preview" href="%s" title="%s">%s</a>',
'<a class="install-theme-preview" href="%s" aria-label="%s">%s</a>',
esc_url( $preview_url ),
/* translators: %s: Theme name. */
esc_attr( sprintf( __( 'Preview %s' ), $name ) ),
esc_attr( $preview_title ),
__( 'Preview' )
);

Expand All @@ -363,7 +361,7 @@ public function single_row( $theme ) {
$actions = apply_filters( 'theme_install_actions', $actions, $theme );

?>
<a class="screenshot install-theme-preview" href="<?php echo esc_url( $preview_url ); ?>" title="<?php echo esc_attr( $preview_title ); ?>">
<a class="screenshot install-theme-preview" href="<?php echo esc_url( $preview_url ); ?>" aria-label="<?php echo esc_attr( $preview_title ); ?>">
<img src="<?php echo esc_url( $theme->screenshot_url . '?ver=' . $theme->version ); ?>" width="150" alt="" />
</a>

Expand Down Expand Up @@ -474,7 +472,7 @@ public function install_theme_info( $theme ) {
switch ( $status ) {
case 'update_available':
printf(
'<a class="theme-install button button-primary" href="%s" title="%s">%s</a>',
'<a class="theme-install button button-primary" href="%s" aria-label="%s">%s</a>',
esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ),
/* translators: %s: Theme version. */
esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ),
Expand All @@ -484,8 +482,7 @@ public function install_theme_info( $theme ) {
case 'newer_installed':
case 'latest_installed':
printf(
'<span class="theme-install" title="%s">%s</span>',
esc_attr__( 'This theme is already installed and is up to date' ),
'<span class="theme-install">%s</span>',
_x( 'Installed', 'theme' )
);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-themes-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function display_rows() {

$actions = array();
$actions['activate'] = sprintf(
'<a href="%s" class="activatelink" title="%s">%s</a>',
'<a href="%s" class="activatelink" aria-label="%s">%s</a>',
$activate_link,
/* translators: %s: Theme name. */
esc_attr( sprintf( _x( 'Activate &#8220;%s&#8221;', 'theme' ), $title ) ),
Expand Down

0 comments on commit 61b7b97

Please sign in to comment.