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 git-svn-id: https://develop.svn.wordpress.org/trunk@31831 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1392d272c2
commit
cc0e582a67
@ -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();
|
||||
|
||||
|
@ -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' );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user