Make WordPress Core

Changeset 35924


Ignore:
Timestamp:
12/14/2015 04:06:55 PM (9 years ago)
Author:
afercia
Message:

Accessibility: Remove title attributes from the Network Themes list table.

Title attributes in the "Themes" screen and in the "Edit Site" screen Themes tab
are now replaced with aria-label attributes. Also, replaces string
concatenation with add_query_arg() and sprintf() to allow translator
comments to be properly parsed and for better code readability.

Props SergeyBiryukov, afercia.
Fixes #35051.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r35241 r35924  
    400400        if ( ! $allowed ) {
    401401            if ( ! $theme->errors() ) {
    402                 $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
     402                $url = add_query_arg( array(
     403                    'action' => 'enable',
     404                    'theme'  => $theme_key,
     405                    'paged'  => $page,
     406                    's'      => $s,
     407                ), $url );
     408
     409                if ( $this->is_site_themes ) {
     410                    /* translators: %s: theme name */
     411                    $aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) );
     412                } else {
     413                    /* translators: %s: theme name */
     414                    $aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) );
     415                }
     416
     417                $actions['enable'] = sprintf( '<a href="%s" class="edit" aria-label="%s">%s</a>',
     418                    esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ),
     419                    esc_attr( $aria_label ),
     420                    ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) )
     421                );
    403422            }
    404423        } else {
    405             $actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
     424            $url = add_query_arg( array(
     425                'action' => 'disable',
     426                'theme'  => $theme_key,
     427                'paged'  => $page,
     428                's'      => $s,
     429            ), $url );
     430
     431            if ( $this->is_site_themes ) {
     432                /* translators: %s: theme name */
     433                $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) );
     434            } else {
     435                /* translators: %s: theme name */
     436                $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) );
     437            }
     438
     439            $actions['disable'] = sprintf( '<a href="%s" aria-label="%s">%s</a>',
     440                esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ),
     441                esc_attr( $aria_label ),
     442                ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) )
     443            );
    406444        }
    407445
    408446        if ( current_user_can('edit_themes') ) {
    409             $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
     447            $url = add_query_arg( array(
     448                'theme' => $theme_key,
     449            ), 'theme-editor.php' );
     450
     451            /* translators: %s: theme name */
     452            $aria_label = sprintf( __( 'Open %s in the Theme Editor' ), $theme->display( 'Name' ) );
     453
     454            $actions['edit'] = sprintf( '<a href="%s" class="edit" aria-label="%s">%s</a>',
     455                esc_url( $url ),
     456                esc_attr( $aria_label ),
     457                __( 'Edit' )
     458            );
    410459        }
    411460
    412461        if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) {
    413             $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&amp;checked[]=' . $theme_key . '&amp;theme_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
     462            $url = add_query_arg( array(
     463                'action'       => 'delete-selected',
     464                'checked[]'    => $theme_key,
     465                'theme_status' => $context,
     466                'paged'        => $page,
     467                's'            => $s,
     468            ), 'themes.php' );
     469
     470            /* translators: %s: theme name */
     471            $aria_label = sprintf( __( 'Delete %s' ), $theme->display( 'Name' ) );
     472
     473            $actions['delete'] = sprintf( '<a href="%s" class="delete" aria-label="%s">%s</a>',
     474                esc_url( wp_nonce_url( $url, 'bulk-themes' ) ),
     475                esc_attr( $aria_label ),
     476                __( 'Delete' )
     477            );
    414478        }
    415479        /**
     
    496560
    497561        if ( $theme->get('ThemeURI') ) {
    498             $theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
     562            /* translators: %s: theme name */
     563            $aria_label = sprintf( __( 'Visit %s homepage' ), $theme->display( 'Name' ) );
     564
     565            $theme_meta[] = sprintf( '<a href="%s" aria-label="%s">%s</a>',
     566                $theme->display( 'ThemeURI' ),
     567                esc_attr( $aria_label ),
     568                __( 'Visit Theme Site' )
     569            );
    499570        }
    500571        /**
Note: See TracChangeset for help on using the changeset viewer.