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': case 'install':
if ( $status['url'] ) { if ( $status['url'] ) {
/* translators: 1: Plugin name and version. */ /* 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; break;
case 'update_available': case 'update_available':
if ( $status['url'] ) { if ( $status['url'] ) {
/* translators: 1: Plugin name and version */ /* 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; break;

View File

@ -145,11 +145,13 @@ window.wp = window.wp || {};
* @param {string} slug * @param {string} slug
*/ */
wp.updates.updatePlugin = function( plugin, slug ) { wp.updates.updatePlugin = function( plugin, slug ) {
var $message; var $message, name;
if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
$message = $( '[data-slug="' + slug + '"]' ).next().find( '.update-message' ); $message = $( '[data-slug="' + slug + '"]' ).next().find( '.update-message' );
} else if ( 'plugin-install' === pagenow ) { } else if ( 'plugin-install' === pagenow ) {
$message = $( '.plugin-card-' + slug ).find( '.update-now' ); $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' ); $message.addClass( 'updating-message' );
@ -198,14 +200,14 @@ window.wp = window.wp || {};
* @param {object} response * @param {object} response
*/ */
wp.updates.updateSuccess = function( response ) { wp.updates.updateSuccess = function( response ) {
var $updateMessage; var $updateMessage, name, $pluginRow, newText;
if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { 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' ); $updateMessage = $pluginRow.next().find( '.update-message' );
$pluginRow.addClass( 'updated' ).removeClass( 'update' ); $pluginRow.addClass( 'updated' ).removeClass( 'update' );
// Update the version number in the row. // 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 ); $pluginRow.find('.plugin-version-author-uri').html( newText );
// Add updated class to update message parent tr // Add updated class to update message parent tr
@ -213,6 +215,8 @@ window.wp = window.wp || {};
} else if ( 'plugin-install' === pagenow ) { } else if ( 'plugin-install' === pagenow ) {
$updateMessage = $( '.plugin-card-' + response.slug ).find( '.update-now' ); $updateMessage = $( '.plugin-card-' + response.slug ).find( '.update-now' );
$updateMessage.addClass( 'button-disabled' ); $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' ); $updateMessage.removeClass( 'updating-message' ).addClass( 'updated-message' );
@ -240,7 +244,7 @@ window.wp = window.wp || {};
* @param {object} response * @param {object} response
*/ */
wp.updates.updateError = function( response ) { wp.updates.updateError = function( response ) {
var $message; var $message, name;
wp.updates.updateDoneSuccessfully = false; wp.updates.updateDoneSuccessfully = false;
if ( response.errorCode && response.errorCode == 'unable_to_connect_to_filesystem' ) { if ( response.errorCode && response.errorCode == 'unable_to_connect_to_filesystem' ) {
wp.updates.credentialError( response, 'update-plugin' ); wp.updates.credentialError( response, 'update-plugin' );
@ -250,6 +254,9 @@ window.wp = window.wp || {};
$message = $( '[data-slug="' + response.slug + '"]' ).next().find( '.update-message' ); $message = $( '[data-slug="' + response.slug + '"]' ).next().find( '.update-message' );
} else if ( 'plugin-install' === pagenow ) { } else if ( 'plugin-install' === pagenow ) {
$message = $( '.plugin-card-' + response.slug ).find( '.update-now' ); $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.removeClass( 'updating-message' );
$message.text( wp.updates.l10n.updateFailed ); $message.text( wp.updates.l10n.updateFailed );

File diff suppressed because one or more lines are too long

View File

@ -527,10 +527,16 @@ function wp_default_scripts( &$scripts ) {
'l10n' => array( 'l10n' => array(
'updating' => __( 'Updating...' ), 'updating' => __( 'Updating...' ),
'updated' => __( 'Updated!' ), 'updated' => __( 'Updated!' ),
'updateFailed' => __( 'Update failed.' ), '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.' ), 'updatingMsg' => __( 'Updating... please wait.' ),
'updatedMsg' => __( 'Update completed successfully.' ), 'updatedMsg' => __( 'Update completed successfully.' ),
'updateCancel' => __( 'Update canceled' ), 'updateCancel' => __( 'Update canceled.' ),
) )
) ); ) );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.