From b4ffaa70e5b5113c87080599a19622e84642e765 Mon Sep 17 00:00:00 2001 From: devinwalker Date: Wed, 14 Oct 2026 21:54:17 -0700 Subject: [PATCH 1/2] Upgrade/Install: Refresh update counts in the folded admin menu. Top-level admin menu items repeat their update count in the submenu header, which is what shows when the menu is folded, either from "Collapse Menu" or automatically on screens 783 to 960 pixels wide. `wp.updates.refreshCount()` only updated the count in the menu link, so after an in-page update the folded menu kept showing the old count until the page was reloaded. This affected the Plugins menu, and the Themes menu in the network admin. This adds the submenu header counts for the Plugins and Appearance menus to the elements `refreshCount()` updates. See #66315. --- src/js/_enqueues/wp/updates.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/_enqueues/wp/updates.js b/src/js/_enqueues/wp/updates.js index 6fb48411c52bd..62f5c6fce6091 100644 --- a/src/js/_enqueues/wp/updates.js +++ b/src/js/_enqueues/wp/updates.js @@ -356,13 +356,17 @@ /** * Refreshes update counts everywhere on the screen. * + * Top-level menu items repeat their count in the submenu header, + * which is shown when the admin menu is folded. + * * @since 4.7.0 + * @since 7.2.0 Also refreshes the counts in folded menu submenu headers. */ wp.updates.refreshCount = function() { var $adminBarUpdates = $( '#wp-admin-bar-updates' ), $dashboardNavMenuUpdateCount = $( 'a[href="update-core.php"] .update-plugins' ), - $pluginsNavMenuUpdateCount = $( 'a[href="plugins.php"] .update-plugins' ), - $appearanceNavMenuUpdateCount = $( 'a[href="themes.php"] .update-plugins' ), + $pluginsNavMenuUpdateCount = $( 'a[href="plugins.php"] .update-plugins, #menu-plugins .wp-submenu-head .update-plugins' ), + $appearanceNavMenuUpdateCount = $( 'a[href="themes.php"] .update-plugins, #menu-appearance .wp-submenu-head .update-plugins' ), itemCount; $adminBarUpdates.find( '.ab-label' ).text( settings.totals.counts.total ); From 5d78028977c56d3766ee264e0dc079afb2fb1b23 Mon Sep 17 00:00:00 2001 From: devinwalker Date: Tue, 20 Oct 2026 12:46:53 -0700 Subject: [PATCH 2/2] Upgrade/Install: Test the update counts in the folded admin menu. Adds assertions to the `decrementCount()` QUnit test for the count in the Plugins submenu header, which is what shows when the admin menu is folded, and for removing both counts when no updates remain. Props robelsust. See #66315. --- tests/qunit/wp-admin/js/updates.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/qunit/wp-admin/js/updates.js b/tests/qunit/wp-admin/js/updates.js index 9d3948811abfd..26e7f5dc1ec06 100644 --- a/tests/qunit/wp-admin/js/updates.js +++ b/tests/qunit/wp-admin/js/updates.js @@ -15,9 +15,11 @@ jQuery( function( $ ) { var menuItemCount = $( '#menu-plugins' ).find( '.plugin-count' ).eq( 0 ).text(); var screenReaderItemCount = $( '#wp-admin-bar-updates' ).find( '.screen-reader-text' ).text(); var adminItemCount = $( '#wp-admin-bar-updates' ).find( '.ab-label' ).text(); + var submenuHeadCount = $( '#menu-plugins .wp-submenu-head' ).find( '.plugin-count' ).text(); assert.equal( menuItemCount, 2, 'Initial value is correct' ); assert.equal( screenReaderItemCount, '2 Plugin Updates', 'Initial value is correct' ); assert.equal( adminItemCount, 2, 'Initial value is correct' ); + assert.equal( submenuHeadCount, 2, 'Initial submenu header value is correct' ); wp.updates.decrementCount( 'plugin' ); @@ -25,12 +27,20 @@ jQuery( function( $ ) { menuItemCount = $( '#menu-plugins' ).find( '.plugin-count' ).eq( 0 ).text(); screenReaderItemCount = $( '#wp-admin-bar-updates' ).find( '.screen-reader-text' ).text(); adminItemCount = $( '#wp-admin-bar-updates' ).find( '.ab-label' ).text(); + submenuHeadCount = $( '#menu-plugins .wp-submenu-head' ).find( '.plugin-count' ).text(); assert.equal( menuItemCount, 1 ); // @todo: Update screen reader count. // Should the screenReader count change? Is that announced to the user? // assert.equal( screenReaderItemCount, '1 Plugin Update' ); assert.equal( adminItemCount, 1 ); + + // The submenu header shows the count when the admin menu is folded. + assert.equal( submenuHeadCount, 1, 'Submenu header count is updated' ); + + // With no updates left, the count is removed from the menu item and its submenu header. + wp.updates.decrementCount( 'plugin' ); + assert.equal( $( '#menu-plugins' ).find( '.plugin-count' ).length, 0, 'Both counts are removed when no updates remain' ); }); QUnit.test( '`beforeunload` should only fire when locked', function( assert ) {