Skip to content

Upgrade/Install: Refresh update counts in the folded admin menu - #14290

Open
DevinWalker wants to merge 1 commit into
WordPress:trunkfrom
DevinWalker:66315-folded-menu-update-count
Open

DevinWalker wants to merge 1 commit into
WordPress:trunkfrom
DevinWalker:66315-folded-menu-update-count

Conversation

@DevinWalker

@DevinWalker DevinWalker commented Oct 15, 2026 •

Copy link
Copy Markdown

When the admin menu is folded, the update count next to "Plugins" doesn't change after an in-page update. It keeps the old number until the page is reloaded.

The admin menu prints each top-level item's update count twice: once in the menu link, and once in the submenu header (.wp-submenu-head). The submenu header is what shows when the menu is folded, either after clicking "Collapse Menu" or automatically on screens between 783 and 960 pixels wide. wp.updates.refreshCount() only updated the copy in the menu link.

This adds the submenu header counts for the Plugins and Appearance menus to the elements refreshCount() updates. Appearance matters in the network admin, where "Themes" is a top-level item with its own count. On a single site the theme count is on the "Themes" submenu item, which has no submenu header copy.

Trac ticket: https://core.trac.wordpress.org/ticket/66315

Before and after

Folded menu at 900 pixels, two plugin updates pending, hovering "Plugins" after each inline "update now":

Before: the folded Plugins menu still shows 2 after one and after both updates. After: it shows 1, then no count.

Testing Instructions

  1. Have two plugins with updates available, for example npm run env:cli -- plugin install classic-editor --version=1.6.3 --force and npm run env:cli -- plugin install classic-widgets --version=0.2 --force.
  2. Make the browser window about 900 pixels wide, or click "Collapse Menu".
  3. Go to "Plugins > Installed Plugins" and click "update now" for one plugin.
  4. Hover over "Plugins" in the admin menu. Before: 2. After: 1.
  5. Update the other plugin and hover again. Before: still 2. After: no count.
  6. On multisite, repeat in "Network Admin > Plugins", and with an outdated theme in "Network Admin > Themes" (for example npm run env:cli -- theme install twentytwentyfour --version=1.0 --force).

I tested this on single site and multisite, with the menu folded automatically at 900 pixels and with "Collapse Menu" at 1280 pixels. Found while testing #62212.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Finding the cause, writing the patch, and scripted browser testing (Playwright) against a local wordpress-develop environment. I reviewed the code and the test results before submitting.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

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.
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dlocc, therssoftware.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@robelsust

Copy link
Copy Markdown

Testing Feedback

I tested this both in the PR Playground instance and with DOM unit testing:

  • Before the patch:

    • When the admin menu is collapsed/folded, hovering over Plugins displays the submenu flyout with .wp-submenu-head.
    • Calling wp.updates.decrementCount( 'plugin' ) decrements the top-level link count from 2 to 1, but .wp-submenu-head .plugin-count remains stuck at 2.
    • When reaching 0 updates, the top-level badge disappears, but .wp-submenu-head continues to display the stale badge until a full page reload.
  • After the patch:

    • wp.updates.decrementCount( 'plugin' ) decrements both a[href="plugins.php"] .plugin-count and #menu-plugins .wp-submenu-head .plugin-count synchronously from 2 to 1.
    • Decrementing to 0 cleanly removes .update-plugins from both the top-level link and the submenu header.
    • The same fix applies to #menu-appearance .wp-submenu-head .update-plugins for Multisite Network Admin.

Suggested Test Addition

In tests/qunit/wp-admin/js/updates.js, the fixture already provides the .wp-submenu-head HTML markup for #menu-plugins. We can add assertions to decrementCount to prevent future regressions:

// In tests/qunit/wp-admin/js/updates.js -> QUnit.test( 'decrementCount correctly decreases the update number' ):
var submenuHeadCount = $( '#menu-plugins .wp-submenu-head' ).find( '.plugin-count' ).text();
assert.equal( submenuHeadCount, 2, 'Initial submenu head value is correct' );

wp.updates.decrementCount( 'plugin' );

submenuHeadCount = $( '#menu-plugins .wp-submenu-head' ).find( '.plugin-count' ).text();
assert.equal( submenuHeadCount, 1, 'Submenu head count is updated when menu is folded' );

// Decrement to zero and verify both copies are removed.
wp.updates.decrementCount( 'plugin' );
assert.equal( $( '#menu-plugins' ).find( '.plugin-count' ).length, 0, 'Both menu and submenu head counts removed when zero updates remain' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants