Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/js/_enqueues/wp/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ window.wp = window.wp || {};
( function($) {

// Set up our namespace...
var themes, l10n;
var themes;
themes = wp.themes = wp.themes || {};

// Store the theme data and settings for organized and quick access.
// themes.data.settings, themes.data.themes, themes.data.l10n.
// themes.data.settings, themes.data.themes.
themes.data = _wpThemeSettings;
l10n = themes.data.l10n;

/**
* Announces to screen readers the theme shown after previous/next navigation.
Expand All @@ -37,7 +36,7 @@ themes.announceThemeDebounced = _.debounce( function( model ) {
return;
}

wp.a11y.speak( l10n.themeViewed.replace( '%s', name ) );
wp.a11y.speak( wp.i18n.sprintf( wp.i18n.__( 'Theme details: %s' ), name ) );
}, 500 );

// Shortcut for isInstall check.
Expand Down Expand Up @@ -143,7 +142,7 @@ themes.view.Appearance = wp.Backbone.View.extend({
view.render();
this.searchContainer
.find( '.search-box' )
.append( $.parseHTML( '<label for="wp-filter-search-input">' + l10n.search + '</label>' ) )
.append( $.parseHTML( '<label for="wp-filter-search-input">' + ( themes.isInstall ? wp.i18n.__( 'Search Themes' ) : wp.i18n.__( 'Search installed themes' ) ) + '</label>' ) )
.append( view.el );

this.searchContainer.on( 'submit', function( event ) {
Expand Down Expand Up @@ -1011,9 +1010,9 @@ themes.view.Preview = themes.view.Details.extend({
collapse: function( event ) {
var $button = $( event.currentTarget );
if ( 'true' === $button.attr( 'aria-expanded' ) ) {
$button.attr({ 'aria-expanded': 'false', 'aria-label': l10n.expandSidebar });
$button.attr({ 'aria-expanded': 'false', 'aria-label': wp.i18n.__( 'Expand Sidebar' ) });
} else {
$button.attr({ 'aria-expanded': 'true', 'aria-label': l10n.collapseSidebar });
$button.attr({ 'aria-expanded': 'true', 'aria-label': wp.i18n.__( 'Collapse Sidebar' ) });
}

this.$el.toggleClass( 'collapsed' ).toggleClass( 'expanded' );
Expand Down Expand Up @@ -1263,7 +1262,7 @@ themes.view.Themes = wp.Backbone.View.extend({

// 'Add new theme' element shown at the end of the grid.
if ( ! themes.isInstall && themes.data.settings.canInstall ) {
this.$el.append( '<div class="theme add-new-theme"><a href="' + themes.data.settings.installURI + '"><div class="theme-screenshot"><span aria-hidden="true"></span></div><h2 class="theme-name">' + l10n.addNew + '</h2></a></div>' );
this.$el.append( '<div class="theme add-new-theme"><a href="' + themes.data.settings.installURI + '"><div class="theme-screenshot"><span aria-hidden="true"></span></div><h2 class="theme-name">' + wp.i18n.__( 'Add Theme' ) + '</h2></a></div>' );
}

this.parent.page++;
Expand Down Expand Up @@ -1319,7 +1318,7 @@ themes.view.Themes = wp.Backbone.View.extend({
$modal.find( '.notice-warning' )
.removeClass( 'notice-large' )
.addClass( 'updating-message' )
.find( 'p' ).text( wp.updates.l10n.updating );
.find( 'p' ).text( wp.i18n.__( 'Updating...' ) );
} else if ( $card.find( '.notice-error' ).length ) {
$modal.find( '.notice-warning' ).remove();
}
Expand Down Expand Up @@ -1410,9 +1409,10 @@ themes.view.Themes = wp.Backbone.View.extend({
// Dispatch audible search results feedback message.
announceSearchResults: function( count ) {
if ( 0 === count ) {
wp.a11y.speak( l10n.noThemesFound );
wp.a11y.speak( wp.i18n.__( 'No themes found. Try a different search.' ) );
} else {
wp.a11y.speak( l10n.themesFound.replace( '%d', count ) );
/* translators: %d: Number of themes. */
wp.a11y.speak( wp.i18n.sprintf( wp.i18n.__( 'Number of Themes found: %d' ), count ) );
}
}
});
Expand Down Expand Up @@ -1730,7 +1730,8 @@ themes.view.Installer = themes.view.Appearance.extend({
this.listenTo( this.collection, 'query:fail', function() {
$( 'body' ).removeClass( 'loading-content' );
$( '.theme-browser' ).find( 'div.error' ).remove();
$( '.theme-browser' ).find( 'div.themes' ).before( '<div class="notice notice-error"><p>' + l10n.error + '</p><p><button class="button try-again">' + l10n.tryAgain + '</button></p></div>' );
/* translators: %s: Support forums URL. */
$( '.theme-browser' ).find( 'div.themes' ).before( '<div class="notice notice-error"><p>' + wp.i18n.sprintf( wp.i18n.__( '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="%s">support forums</a>.' ), wp.i18n.__( 'https://wordpress.org/support/forums/' ) ) + '</p><p><button class="button try-again">' + wp.i18n.__( 'Try Again' ) + '</button></p></div>' );
$( '.theme-browser .error .try-again' ).on( 'click', function( e ) {
e.preventDefault();
$( 'input.wp-filter-search' ).trigger( 'input' );
Expand Down Expand Up @@ -1862,7 +1863,8 @@ themes.view.Installer = themes.view.Appearance.extend({
}

if ( ! tags ) {
wp.a11y.speak( l10n.selectFeatureFilter );
/* translators: Hidden accessibility text. */
wp.a11y.speak( wp.i18n.__( 'Select one or more Theme features to filter by' ) );
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1453,6 +1453,7 @@ function wp_default_scripts( $scripts ) {
$scripts->add( 'custom-html-widgets', "/wp-admin/js/widgets/custom-html-widgets$suffix.js", array( 'jquery', 'backbone', 'wp-util', 'jquery-ui-core', 'wp-a11y' ) );

$scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 );
$scripts->set_translations( 'theme' );

$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 );
$scripts->set_translations( 'inline-edit-post' );
Expand Down
Loading