Make WordPress Core

Ticket #26600: 26600.2.patch

File 26600.2.patch, 6.1 KB (added by afercia, 10 years ago)

new approach using wp.a11y.speak

  • src/wp-admin/css/themes.css

     
    11401140        font-size: 18px;
    11411141        font-style: normal;
    11421142        margin: 0;
    1143         padding: 100px 0 0;
     1143        padding: 0;
    11441144        text-align: center;
    11451145        display: none;
    11461146}
  • src/wp-admin/js/theme.js

     
    7979
    8080                // Render and append
    8181                this.view.render();
    82                 this.$el.find( '.themes' ).remove();
    83                 this.$el.append( this.view.el ).addClass( 'rendered' );
     82                this.$el.empty().append( this.view.el ).addClass('rendered');
    8483                this.$el.append( '<br class="clear"/>' );
    8584        },
    8685
     
    157156                // Useful for resetting the views when you clean the input
    158157                if ( this.terms === '' ) {
    159158                        this.reset( themes.data.themes );
     159                        $( 'body' ).removeClass( 'no-results' );
    160160                }
    161161
    162162                // Trigger an 'update' event
     
    831831        // The theme count element
    832832        count: $( '.wp-core-ui .theme-count' ),
    833833
     834        // The live themes count
     835        liveThemeCount: 0,
     836
    834837        initialize: function( options ) {
    835838                var self = this;
    836839
     
    854857                this.listenTo( self.collection, 'query:success', function( count ) {
    855858                        if ( _.isNumber( count ) ) {
    856859                                self.count.text( count );
     860                                self.announceSearchResults( count );
    857861                        } else {
    858862                                self.count.text( self.collection.length );
     863                                self.announceSearchResults( self.collection.length );
    859864                        }
    860865                });
    861866
     
    926931                }
    927932
    928933                // Display a live theme count for the collection
    929                 this.count.text( this.collection.count ? this.collection.count : this.collection.length );
     934                this.liveThemeCount = this.collection.count ? this.collection.count : this.collection.length;
     935                this.count.text( this.liveThemeCount );
     936
     937                this.announceSearchResults( this.liveThemeCount );
    930938        },
    931939
    932940        // Iterates through each instance of the collection
     
    10781086                        self.theme.trigger( 'theme:expand', previousModel.cid );
    10791087
    10801088                }
     1089        },
     1090
     1091        // Dispatch audible search results feedback message
     1092        announceSearchResults: function( count ) {
     1093                if ( 0 === count ) {
     1094                        wp.a11y.speak( l10n.noThemesFound );
     1095                } else {
     1096                        wp.a11y.speak( l10n.themesFound + ' ' + count );
     1097                }
    10811098        }
    10821099});
    10831100
  • src/wp-admin/theme-install.php

     
    4444        ),
    4545        'l10n' => array(
    4646                'addNew' => __( 'Add New Theme' ),
    47                 'search'  => __( 'Search Themes' ),
     47                'search' => __( 'Search Themes' ),
    4848                'searchPlaceholder' => __( 'Search themes...' ), // placeholder (no ellipsis)
    4949                'upload' => __( 'Upload Theme' ),
    5050                'back'   => __( 'Back' ),
    51                 'error'  => __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' )
     51                'error'  => __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ),
     52                'themesFound'   => __( 'Number of Themes found:' ),
     53                'noThemesFound' => __( 'No themes found. Try a different search.' ),
    5254        ),
    5355        'installedThemes' => array_keys( $installed_themes ),
    5456) );
     
    166168                        </div>
    167169                </div>
    168170        </div>
    169         <div class="theme-browser content-filterable" aria-live="polite">
    170                 <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
    171         </div>
     171        <div class="theme-browser content-filterable"></div>
    172172        <div class="theme-install-overlay wp-full-overlay expanded"></div>
     173
     174        <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
    173175        <span class="spinner"></span>
    174176
    175177        <br class="clear" />
  • src/wp-admin/themes.php

     
    107107                'adminUrl'      => parse_url( admin_url(), PHP_URL_PATH ),
    108108        ),
    109109        'l10n' => array(
    110                 'addNew' => __( 'Add New Theme' ),
    111                 'search'  => __( 'Search Installed Themes' ),
     110                'addNew'            => __( 'Add New Theme' ),
     111                'search'            => __( 'Search Installed Themes' ),
    112112                'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis)
     113                'themesFound'       => __( 'Number of Themes found:' ),
     114                'noThemesFound'     => __( 'No themes found. Try a different search.' ),
    113115        ),
    114116) );
    115117
     
    198200
    199201?>
    200202
    201 <div class="theme-browser" aria-live="polite">
     203<div class="theme-browser">
    202204        <div class="themes">
    203205
    204206<?php
     
    250252<?php endforeach; ?>
    251253        <br class="clear" />
    252254        </div>
    253         <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
    254255</div>
    255256<div class="theme-overlay"></div>
    256257
     258<p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
     259
    257260<?php
    258261// List broken themes, if any.
    259262if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {
  • src/wp-includes/script-loader.php

     
    496496
    497497                $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
    498498
    499                 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone' ), false, 1 );
     499                $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 );
    500500
    501501                $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), false, 1 );
    502502                did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(