Repository navigation
Upgrade/Install: Refresh update counts in the folded admin menu - #14290
DevinWalker wants to merge 1 commit into
Conversation
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.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Testing FeedbackI tested this both in the PR Playground instance and with DOM unit testing:
Suggested Test AdditionIn // 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' ); |
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":
Testing Instructions
npm run env:cli -- plugin install classic-editor --version=1.6.3 --forceandnpm run env:cli -- plugin install classic-widgets --version=0.2 --force.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.