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



Built from https://develop.svn.wordpress.org/trunk@31982


git-svn-id: http://core.svn.wordpress.org/trunk@31961 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2015-04-02 05:31:26 +00:00
parent d7fec56e26
commit 3ac2f91922
5 changed files with 33 additions and 20 deletions

View File

@ -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[] = '<a class="install-now button" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';
$action_links[] = '<a class="install-now button" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Install Now' ) . '</a>';
}
break;
case 'update_available':
if ( $status['url'] ) {
/* translators: 1: Plugin name and version */
$action_links[] = '<a class="update-now button" data-plugin="' . esc_attr( $status['file'] ) . '" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '">' . __( 'Update Now' ) . '</a>';
$action_links[] = '<a class="update-now button" data-plugin="' . esc_attr( $status['file'] ) . '" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Update Now' ) . '</a>';
}
break;

View File

@ -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 );

File diff suppressed because one or more lines are too long

View File

@ -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.' ),
)
) );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta3-31981';
$wp_version = '4.2-beta3-31982';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.