Make WordPress Core

Changeset 31831


Ignore:
Timestamp:
03/19/2015 05:26:00 AM (9 years ago)
Author:
jorbin
Message:

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

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r30679 r31831  
    516516            $class .= ' update';
    517517
    518         echo "<tr id='$id' class='$class'>";
     518        printf( "<tr id='%s' class='%s' data-slug='%s'>",
     519            $id,
     520            $class,
     521            $plugin_data['slug']
     522        );
    519523
    520524        list( $columns, $hidden ) = $this->get_column_info();
  • trunk/src/wp-admin/js/updates.js

    r31811 r31831  
    139139        var $message;
    140140        if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
    141             $message = $( '#' + slug ).next().find( '.update-message' );
     141            $message = $( '[data-slug="' + slug + '"]' ).next().find( '.update-message' );
    142142        } else if ( 'plugin-install' === pagenow ) {
    143143            $message = $( '.plugin-card-' + slug ).find( '.update-now' );
     
    186186     */
    187187    wp.updates.updateSuccess = function( response ) {
    188         var $message;
     188        var $updateMessage;
    189189        if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
    190             $message = $( '#' + response.slug ).next().find( '.update-message' );
    191             $( '#' + response.slug ).addClass( 'updated' ).removeClass( 'update' );
    192             $( '#' + response.slug + '-update' ).addClass( 'updated' ).removeClass( 'update' );
     190            var $pluginRow = $( '[data-slug="' + response.slug + '"]' ).first();
     191            $updateMessage = $pluginRow.next().find( '.update-message' );
     192            $pluginRow.addClass( 'updated' ).removeClass( 'update' );
     193
    193194            // Update the version number in the row.
    194             var newText = $( '#' + response.slug ).find('.plugin-version-author-uri').html().replace( response.oldVersion, response.newVersion );
    195             $( '#' + response.slug ).find('.plugin-version-author-uri').html( newText );
     195            var newText = $pluginRow.find('.plugin-version-author-uri').html().replace( response.oldVersion, response.newVersion );
     196            $pluginRow.find('.plugin-version-author-uri').html( newText );
    196197        } else if ( 'plugin-install' === pagenow ) {
    197             $message = $( '.plugin-card-' + response.slug ).find( '.update-now' );
    198             $message.addClass( 'button-disabled' );
    199         }
    200 
    201         $message.removeClass( 'updating-message' ).addClass( 'updated-message' );
    202         $message.text( wp.updates.l10n.updated );
     198            $updateMessage = $( '.plugin-card-' + response.slug ).find( '.update-now' );
     199            $updateMessage.addClass( 'button-disabled' );
     200        }
     201
     202        $updateMessage.removeClass( 'updating-message' ).addClass( 'updated-message' );
     203        $updateMessage.text( wp.updates.l10n.updated );
    203204        wp.a11y.speak( wp.updates.l10n.updatedMsg );
    204205
     
    230231        }
    231232        if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
    232             $message = $( '#' + response.slug ).next().find( '.update-message' );
     233            $message = $( '[data-slug="' + response.slug + '"]' ).next().find( '.update-message' );
    233234        } else if ( 'plugin-install' === pagenow ) {
    234235            $message = $( '.plugin-card-' + response.slug ).find( '.update-now' );
Note: See TracChangeset for help on using the changeset viewer.