From dc502287ef01469a4c28de6b599b0127bd1301f7 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Thu, 2 Apr 2015 05:30:13 +0000 Subject: [PATCH] Update aria-label when doing a shiny plugin update Also updates it again when the shiny plugin update is finished. Also updates it if the shiny update fails props mehulkaklotar, afercia Fixes #31722 git-svn-id: https://develop.svn.wordpress.org/trunk@31982 602fd350-edb4-49c9-b593-d223f7449a82 --- .../class-wp-plugin-install-list-table.php | 4 +-- src/wp-admin/js/updates.js | 27 ++++++++++++------- src/wp-includes/script-loader.php | 18 ++++++++----- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/wp-admin/includes/class-wp-plugin-install-list-table.php b/src/wp-admin/includes/class-wp-plugin-install-list-table.php index 5df06f48fc..bcb2ff6cc7 100644 --- a/src/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/src/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -402,14 +402,14 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { case 'install': if ( $status['url'] ) { /* translators: 1: Plugin name and version. */ - $action_links[] = '' . __( 'Install Now' ) . ''; + $action_links[] = '' . __( 'Install Now' ) . ''; } break; case 'update_available': if ( $status['url'] ) { /* translators: 1: Plugin name and version */ - $action_links[] = '' . __( 'Update Now' ) . ''; + $action_links[] = '' . __( 'Update Now' ) . ''; } break; diff --git a/src/wp-admin/js/updates.js b/src/wp-admin/js/updates.js index 1540193967..7f5f3b413d 100644 --- a/src/wp-admin/js/updates.js +++ b/src/wp-admin/js/updates.js @@ -33,7 +33,7 @@ window.wp = window.wp || {}; /** * Filesystem credentials to be packaged along with the request. * - * @since 4.2.0 + * @since 4.2.0 * * @var object */ @@ -96,10 +96,10 @@ window.wp = window.wp || {}; */ wp.updates.decrementCount = function( upgradeType ) { var count, - pluginCount, - $adminBarUpdateCount = $( '#wp-admin-bar-updates .ab-label' ), - $dashboardNavMenuUpdateCount = $( 'a[href="update-core.php"] .update-plugins' ), - $pluginsMenuItem = $( '#menu-plugins' ); + pluginCount, + $adminBarUpdateCount = $( '#wp-admin-bar-updates .ab-label' ), + $dashboardNavMenuUpdateCount = $( 'a[href="update-core.php"] .update-plugins' ), + $pluginsMenuItem = $( '#menu-plugins' ); count = $adminBarUpdateCount.text(); @@ -145,11 +145,13 @@ window.wp = window.wp || {}; * @param {string} slug */ wp.updates.updatePlugin = function( plugin, slug ) { - var $message; + var $message, name; if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { $message = $( '[data-slug="' + slug + '"]' ).next().find( '.update-message' ); } else if ( 'plugin-install' === pagenow ) { $message = $( '.plugin-card-' + slug ).find( '.update-now' ); + name = $message.data( 'name' ); + $message.attr( 'aria-label', wp.updates.l10n.updatingLabel.replace( '%s', name ) ); } $message.addClass( 'updating-message' ); @@ -198,14 +200,14 @@ window.wp = window.wp || {}; * @param {object} response */ wp.updates.updateSuccess = function( response ) { - var $updateMessage; + var $updateMessage, name, $pluginRow, newText; if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { - var $pluginRow = $( '[data-slug="' + response.slug + '"]' ).first(); + $pluginRow = $( '[data-slug="' + response.slug + '"]' ).first(); $updateMessage = $pluginRow.next().find( '.update-message' ); $pluginRow.addClass( 'updated' ).removeClass( 'update' ); // Update the version number in the row. - var newText = $pluginRow.find('.plugin-version-author-uri').html().replace( response.oldVersion, response.newVersion ); + newText = $pluginRow.find('.plugin-version-author-uri').html().replace( response.oldVersion, response.newVersion ); $pluginRow.find('.plugin-version-author-uri').html( newText ); // Add updated class to update message parent tr @@ -213,6 +215,8 @@ window.wp = window.wp || {}; } else if ( 'plugin-install' === pagenow ) { $updateMessage = $( '.plugin-card-' + response.slug ).find( '.update-now' ); $updateMessage.addClass( 'button-disabled' ); + name = $updateMessage.data( 'name' ); + $updateMessage.attr( 'aria-label', wp.updates.l10n.updatedLabel.replace( '%s', name ) ); } $updateMessage.removeClass( 'updating-message' ).addClass( 'updated-message' ); @@ -240,7 +244,7 @@ window.wp = window.wp || {}; * @param {object} response */ wp.updates.updateError = function( response ) { - var $message; + var $message, name; wp.updates.updateDoneSuccessfully = false; if ( response.errorCode && response.errorCode == 'unable_to_connect_to_filesystem' ) { wp.updates.credentialError( response, 'update-plugin' ); @@ -250,6 +254,9 @@ window.wp = window.wp || {}; $message = $( '[data-slug="' + response.slug + '"]' ).next().find( '.update-message' ); } else if ( 'plugin-install' === pagenow ) { $message = $( '.plugin-card-' + response.slug ).find( '.update-now' ); + + name = $message.data( 'name' ); + $message.attr( 'aria-label', wp.updates.l10n.updateFailedLabel.replace( '%s', name ) ); } $message.removeClass( 'updating-message' ); $message.text( wp.updates.l10n.updateFailed ); diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 29a3cdf204..883eadd0e5 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -525,12 +525,18 @@ function wp_default_scripts( &$scripts ) { did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array( 'ajax_nonce' => wp_create_nonce( 'updates' ), 'l10n' => array( - 'updating' => __( 'Updating...' ), - 'updated' => __( 'Updated!' ), - 'updateFailed' => __( 'Update failed.' ), - 'updatingMsg' => __( 'Updating... please wait.' ), - 'updatedMsg' => __( 'Update completed successfully.' ), - 'updateCancel' => __( 'Update canceled' ), + 'updating' => __( 'Updating...' ), + 'updated' => __( 'Updated!' ), + 'updateFailed' => __( 'Update Failed' ), + /* translators: Plugin Name */ + 'updatingLabel' => __( 'Updating %s...' ), + /* translators: Plugin Name */ + 'updatedLabel' => __( '%s updated!' ), + /* translators: Plugin Name */ + 'updateFailedLabel' => __( '%s update failed' ), + 'updatingMsg' => __( 'Updating... please wait.' ), + 'updatedMsg' => __( 'Update completed successfully.' ), + 'updateCancel' => __( 'Update canceled.' ), ) ) );