Make WordPress Core

Changeset 34891


Ignore:
Timestamp:
10/07/2015 01:27:01 AM (11 years ago)
Author:
wonderboymusic
Message:

List Tables/WP_Screen: in WP_Screen, add methods to store, retrieve, and render screen reader text, primarily used by list table screens.

These additions are based on an audit and recommendations by the Accessibility team. #a11y'all

Props afercia.
Fixes #32147.

Location:
trunk/src
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-comments.php

    r34504 r34891  
    166166);
    167167
     168get_current_screen()->set_screen_reader_content( array(
     169        'heading_views'      => __( 'Filter comments list' ),
     170        'heading_pagination' => __( 'Comments list navigation' ),
     171        'heading_list'       => __( 'Comments list' ),
     172) );
     173
    168174require_once( ABSPATH . 'wp-admin/admin-header.php' );
    169175?>
  • trunk/src/wp-admin/edit-tags.php

    r34359 r34891  
    5454
    5555add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) );
     56
     57get_current_screen()->set_screen_reader_content( array(
     58        'heading_pagination' => $tax->labels->pagination,
     59        'heading_list'       => $tax->labels->list,
     60) );
    5661
    5762$location = false;
  • trunk/src/wp-admin/edit.php

    r34177 r34891  
    246246        '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    247247        );
    248 }
     248
     249}
     250
     251get_current_screen()->set_screen_reader_content( array(
     252        'heading_views'      => $post_type_object->labels->views,
     253        'heading_pagination' => $post_type_object->labels->pagination,
     254        'heading_list'       => $post_type_object->labels->list,
     255) );
    249256
    250257add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r34508 r34891  
    444444                $this->display_tablenav( 'top' );
    445445
     446                $this->screen->render_screen_reader_content( 'heading_list' );
     447
    446448?>
    447449<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r34728 r34891  
    382382                if ( empty( $views ) )
    383383                        return;
     384
     385                $this->screen->render_screen_reader_content( 'heading_views' );
    384386
    385387                echo "<ul class='subsubsub'>\n";
     
    735737                }
    736738
     739                if ( 'top' === $which && $total_pages > 1 ) {
     740                        $this->screen->render_screen_reader_content( 'heading_pagination' );
     741                }
     742
    737743                $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
    738744
     
    11181124
    11191125                $this->display_tablenav( 'top' );
     1126
     1127                $this->screen->render_screen_reader_content( 'heading_list' );
    11201128?>
    11211129<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r34839 r34891  
    218218
    219219                $views = $this->get_views();
     220
     221                $this->screen->render_screen_reader_content( 'heading_views' );
    220222?>
    221223<div class="wp-filter">
  • trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php

    r34760 r34891  
    259259                $views = apply_filters( "views_{$this->screen->id}", $views );
    260260
     261                $this->screen->render_screen_reader_content( 'heading_views' );
    261262?>
    262263<div class="wp-filter">
     
    293294?>
    294295<div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
    295 
     296<?php
     297        $this->screen->render_screen_reader_content( 'heading_list' );
     298?>
    296299        <div id="the-list"<?php echo $data_attr; ?>>
    297300                <?php $this->display_rows_or_placeholder(); ?>
  • trunk/src/wp-admin/includes/class-wp-screen.php

    r34422 r34891  
    142142         */
    143143        private $_help_sidebar = '';
     144
     145        /**
     146         * The accessible hidden headings and text associated with the screen, if any.
     147         *
     148         * @since 4.4.0
     149         * @access private
     150         * @var array
     151         */
     152        private $_screen_reader_content = array();
    144153
    145154        /**
     
    643652        public function get_columns() {
    644653                return $this->columns;
     654        }
     655
     656        /**
     657         * Get the accessible hidden headings and text used in the screen.
     658         *
     659         * @since 4.4.0
     660         *
     661         * @see set_screen_reader_content() For more information on the array format.
     662         *
     663         * @return array An associative array of screen reader text strings.
     664         */
     665        public function get_screen_reader_content() {
     666                return $this->_screen_reader_content;
     667        }
     668
     669        /**
     670         * Get a screen reader text string.
     671         *
     672         * @since 4.4.0
     673         *
     674         * @param string $key Screen reader text array named key.
     675         * @return string Screen reader text string.
     676         */
     677        public function get_screen_reader_text( $key ) {
     678                if ( ! isset( $this->_screen_reader_content[ $key ] ) ) {
     679                        return null;
     680                }
     681                return $this->_screen_reader_content[ $key ];
     682        }
     683
     684        /**
     685         * Add accessible hidden headings and text for the screen.
     686         *
     687         * @since 4.4.0
     688         *
     689         * @param array $content {
     690         *     An associative array of screen reader text strings.
     691         *
     692         *     @type string $heading_views      Screen reader text for the filter links heading.
     693         *                                      Default 'Filter items list'.
     694         *     @type string $heading_pagination Screen reader text for the pagination heading.
     695         *                                      Default 'Items list navigation'.
     696         *     @type string heading_list        Screen reader text for the items list heading.
     697         *                                      Default 'Items list'.
     698         * }
     699         */
     700        public function set_screen_reader_content( $content = array() ) {
     701                $defaults = array(
     702                        'heading_views'      => __( 'Filter items list' ),
     703                        'heading_pagination' => __( 'Items list navigation' ),
     704                        'heading_list'       => __( 'Items list' ),
     705                );
     706                $content = wp_parse_args( $content, $defaults );
     707
     708                $this->_screen_reader_content = $content;
     709        }
     710
     711        /**
     712         * Remove all the accessible hidden headings and text for the screen.
     713         *
     714         * @since 4.4.0
     715         */
     716        public function remove_screen_reader_content() {
     717                $this->_screen_reader_content = array();
    645718        }
    646719
     
    10651138                <?php
    10661139        }
     1140
     1141        /**
     1142         * Render screen reader text.
     1143         *
     1144         * @since 4.4.0
     1145         *
     1146         * @param string $key The screen reader text array named key.
     1147         * @param string $tag Optional. The HTML tag to wrap the screen reader text. Default h2.
     1148         */
     1149        public function render_screen_reader_content( $key = '', $tag = 'h2' ) {
     1150
     1151                if ( ! isset( $this->_screen_reader_content[ $key ] ) ) {
     1152                        return;
     1153                }
     1154                echo "<$tag class='screen-reader-text'>" . $this->_screen_reader_content[ $key ] . "</$tag>";
     1155        }
    10671156}
  • trunk/src/wp-admin/link-manager.php

    r33067 r34891  
    6262);
    6363
     64get_current_screen()->set_screen_reader_content( array(
     65        'heading_list' => __( 'Links list' ),
     66) );
     67
    6468include_once( ABSPATH . 'wp-admin/admin-header.php' );
    6569
  • trunk/src/wp-admin/network/site-themes.php

    r33921 r34891  
    3333        '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
    3434);
     35
     36get_current_screen()->set_screen_reader_content( array(
     37        'heading_views'      => __( 'Filter site themes list' ),
     38        'heading_pagination' => __( 'Site themes list navigation' ),
     39        'heading_list'       => __( 'Site themes list' ),
     40) );
    3541
    3642$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
  • trunk/src/wp-admin/network/site-users.php

    r34742 r34891  
    3636        '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
    3737);
     38
     39get_current_screen()->set_screen_reader_content( array(
     40        'heading_views'      => __( 'Filter site users list' ),
     41        'heading_pagination' => __( 'Site users list navigation' ),
     42        'heading_list'       => __( 'Site users list' ),
     43) );
    3844
    3945$_SERVER['REQUEST_URI'] = remove_query_arg( 'update', $_SERVER['REQUEST_URI'] );
  • trunk/src/wp-admin/network/sites.php

    r33194 r34891  
    4646        '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
    4747);
     48
     49get_current_screen()->set_screen_reader_content( array(
     50        'heading_pagination' => __( 'Sites list navigation' ),
     51        'heading_list'       => __( 'Sites list' ),
     52) );
    4853
    4954$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
  • trunk/src/wp-admin/network/themes.php

    r34778 r34891  
    252252);
    253253
     254get_current_screen()->set_screen_reader_content( array(
     255        'heading_views'      => __( 'Filter themes list' ),
     256        'heading_pagination' => __( 'Themes list navigation' ),
     257        'heading_list'       => __( 'Themes list' ),
     258) );
     259
    254260$title = __('Themes');
    255261$parent_file = 'themes.php';
  • trunk/src/wp-admin/network/users.php

    r34265 r34891  
    173173);
    174174
     175get_current_screen()->set_screen_reader_content( array(
     176        'heading_views'      => __( 'Filter users list' ),
     177        'heading_pagination' => __( 'Users list navigation' ),
     178        'heading_list'       => __( 'Users list' ),
     179) );
     180
    175181require_once( ABSPATH . 'wp-admin/admin-header.php' );
    176182
  • trunk/src/wp-admin/plugin-install.php

    r33067 r34891  
    8989);
    9090
     91get_current_screen()->set_screen_reader_content( array(
     92        'heading_views'      => __( 'Filter plugins list' ),
     93        'heading_pagination' => __( 'Plugins list navigation' ),
     94        'heading_list'       => __( 'Plugins list' ),
     95) );
     96
    9197/**
    9298 * WordPress Administration Template Header.
  • trunk/src/wp-admin/plugins.php

    r34778 r34891  
    427427);
    428428
     429get_current_screen()->set_screen_reader_content( array(
     430        'heading_views'      => __( 'Filter plugins list' ),
     431        'heading_pagination' => __( 'Plugins list navigation' ),
     432        'heading_list'       => __( 'Plugins list' ),
     433) );
     434
    429435$title = __('Plugins');
    430436$parent_file = 'plugins.php';
  • trunk/src/wp-admin/theme-install.php

    r34086 r34891  
    128128        <?php install_themes_upload(); ?>
    129129        </div>
     130
     131        <h2 class="screen-reader-text"><?php _e( 'Filter themes list' ); ?></h2>
    130132
    131133        <div class="wp-filter">
     
    172174                </div>
    173175        </div>
     176        <h2 class="screen-reader-text"><?php _e( 'Themes list' ); ?></h2>
    174177        <div class="theme-browser content-filterable"></div>
    175178        <div class="theme-install-overlay wp-full-overlay expanded"></div>
  • trunk/src/wp-admin/upload.php

    r34797 r34891  
    205205);
    206206
     207get_current_screen()->set_screen_reader_content( array(
     208        'heading_views'      => __( 'Filter media items list' ),
     209        'heading_pagination' => __( 'Media items list navigation' ),
     210        'heading_list'       => __( 'Media items list' ),
     211) );
     212
    207213require_once( ABSPATH . 'wp-admin/admin-header.php' );
    208214?>
  • trunk/src/wp-admin/users.php

    r34636 r34891  
    6868    '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    6969);
     70
     71get_current_screen()->set_screen_reader_content( array(
     72        'heading_views'      => __( 'Filter users list' ),
     73        'heading_pagination' => __( 'Users list navigation' ),
     74        'heading_list'       => __( 'Users list' ),
     75) );
    7076
    7177if ( empty($_REQUEST) ) {
  • trunk/src/wp-includes/post-functions.php

    r34886 r34891  
    13231323 * - use_featured_image - Default is Use as featured image.
    13241324 * - menu_name - Default is the same as `name`.
     1325 * - views - String for the table views hidden heading.
     1326 * - pagination - String for the table pagination hidden heading.
     1327 * - list - String for the table hidden heading.
    13251328 *
    13261329 * Above, the first default value is for non-hierarchical post types (like posts)
     
    13571360                'remove_featured_image' => array( __( 'Remove featured image' ), __( 'Remove featured image' ) ),
    13581361                'use_featured_image' => array( __( 'Use as featured image' ), __( 'Use as featured image' ) ),
     1362                'views' => array( __( 'Filter posts list' ), __( 'Filter pages list' ) ),
     1363                'pagination' => array( __( 'Posts list navigation' ), __( 'Pages list navigation' ) ),
     1364                'list' => array( __( 'Posts list' ), __( 'Pages list' ) ),
    13591365        );
    13601366        $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
  • trunk/src/wp-includes/taxonomy-functions.php

    r34884 r34891  
    496496 * - not_found - Default is "No tags found"/"No categories found", used in the meta box and taxonomy list table.
    497497 * - no_terms - Default is "No tags"/"No categories", used in the posts and media list tables.
     498 * - pagination - String for the table pagination hidden heading.
     499 * - list - String for the table hidden heading.
    498500 *
    499501 * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories).
     
    535537                'not_found' => array( __( 'No tags found.' ), __( 'No categories found.' ) ),
    536538                'no_terms' => array( __( 'No tags' ), __( 'No categories' ) ),
     539                'pagination' => array( __( 'Tags list navigation' ), __( 'Categories list navigation' ) ),
     540                'list' => array( __( 'Tags list' ), __( 'Categories list' ) ),
    537541        );
    538542        $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
Note: See TracChangeset for help on using the changeset viewer.