Make WordPress Core

Changeset 53124


Ignore:
Timestamp:
04/11/2022 04:49:29 AM (4 years ago)
Author:
peterwilsoncc
Message:

Plugins: Update item count when plugin deleted.

Update the item count, "N items", on the plugin list when a plugin is deleted. This matches the live updating of various other counts on the screen.

Props mitogh, costdev, azouamauriac, swissspidy, kebbet.
Fixes #55316.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/updates.js

    r52139 r53124  
    3535                _x = wp.i18n._x,
    3636                _n = wp.i18n._n,
     37                _nx = wp.i18n._nx,
    3738                sprintf = wp.i18n.sprintf;
    3839
    … …  
    971972                                $views           = $( '.subsubsub' ),
    972973                                $pluginRow       = $( this ),
     974                                $currentView     = $views.find( '[aria-current="page"]' ),
     975                                $itemsCount      = $( '.displaying-num' ),
    973976                                columnCount      = $form.find( 'thead th:not(.hidden), thead td' ).length,
    974977                                pluginDeletedRow = wp.template( 'item-deleted-row' ),
    … …  
    978981                                 * @type {Object}
    979982                                 */
    980                                 plugins          = settings.plugins;
     983                                plugins          = settings.plugins,
     984                                remainingCount;
    981985
    982986                        // Add a success message after deleting a plugin.
    … …  
    10571061                                        $form.find( '#the-list' ).append( '<tr class="no-items"><td class="colspanchange" colspan="' + columnCount + '">' + __( 'No plugins are currently available.' ) + '</td></tr>' );
    10581062                                }
     1063                        }
     1064
     1065                        if ( $itemsCount.length && $currentView.length ) {
     1066                                remainingCount = plugins[ $currentView.parent( 'li' ).attr('class') ].length;
     1067                                $itemsCount.text(
     1068                                        sprintf(
     1069                                                /* translators: %s: The remaining number of plugins. */
     1070                                                _nx( '%s item', '%s items', 'plugin/plugins', remainingCount ),
     1071                                                remainingCount
     1072                                        )
     1073                                );
    10591074                        }
    10601075                } );
  • trunk/src/wp-includes/script-loader.php

    r53103 r53124  
    13411341                $scripts->set_translations( 'privacy-tools' );
    13421342
    1343                 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'common', 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
     1343                $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'common', 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize', 'wp-i18n' ), false, 1 );
    13441344                $scripts->set_translations( 'updates' );
    13451345                did_action( 'init' ) && $scripts->localize(
Note: See TracChangeset for help on using the changeset viewer.