Ensure that we target the correct plugin row for update updates

The DOM traversal of the plugins list table was less than ideal. By switching to data attributes, we can better target the DOM elements we want to update.

Props ericlewis
Fixes #31621



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


git-svn-id: http://core.svn.wordpress.org/trunk@31813 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2015-03-19 05:26:28 +00:00
parent 55fd3fa791
commit a836a32fb4
4 changed files with 20 additions and 15 deletions

View File

@ -515,7 +515,11 @@ class WP_Plugins_List_Table extends WP_List_Table {
if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
$class .= ' update';
echo "<tr id='$id' class='$class'>";
printf( "<tr id='%s' class='%s' data-slug='%s'>",
$id,
$class,
$plugin_data['slug']
);
list( $columns, $hidden ) = $this->get_column_info();

View File

@ -138,7 +138,7 @@ window.wp = window.wp || {};
wp.updates.updatePlugin = function( plugin, slug ) {
var $message;
if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
$message = $( '#' + slug ).next().find( '.update-message' );
$message = $( '[data-slug="' + slug + '"]' ).next().find( '.update-message' );
} else if ( 'plugin-install' === pagenow ) {
$message = $( '.plugin-card-' + slug ).find( '.update-now' );
}
@ -185,21 +185,22 @@ window.wp = window.wp || {};
* @param {object} response
*/
wp.updates.updateSuccess = function( response ) {
var $message;
var $updateMessage;
if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
$message = $( '#' + response.slug ).next().find( '.update-message' );
$( '#' + response.slug ).addClass( 'updated' ).removeClass( 'update' );
$( '#' + response.slug + '-update' ).addClass( 'updated' ).removeClass( 'update' );
var $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 = $( '#' + response.slug ).find('.plugin-version-author-uri').html().replace( response.oldVersion, response.newVersion );
$( '#' + response.slug ).find('.plugin-version-author-uri').html( newText );
var newText = $pluginRow.find('.plugin-version-author-uri').html().replace( response.oldVersion, response.newVersion );
$pluginRow.find('.plugin-version-author-uri').html( newText );
} else if ( 'plugin-install' === pagenow ) {
$message = $( '.plugin-card-' + response.slug ).find( '.update-now' );
$message.addClass( 'button-disabled' );
$updateMessage = $( '.plugin-card-' + response.slug ).find( '.update-now' );
$updateMessage.addClass( 'button-disabled' );
}
$message.removeClass( 'updating-message' ).addClass( 'updated-message' );
$message.text( wp.updates.l10n.updated );
$updateMessage.removeClass( 'updating-message' ).addClass( 'updated-message' );
$updateMessage.text( wp.updates.l10n.updated );
wp.a11y.speak( wp.updates.l10n.updatedMsg );
wp.updates.decrementCount( 'plugin' );
@ -229,7 +230,7 @@ window.wp = window.wp || {};
return;
}
if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
$message = $( '#' + response.slug ).next().find( '.update-message' );
$message = $( '[data-slug="' + response.slug + '"]' ).next().find( '.update-message' );
} else if ( 'plugin-install' === pagenow ) {
$message = $( '.plugin-card-' + response.slug ).find( '.update-now' );
}

File diff suppressed because one or more lines are too long

View File

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