Skip to content

fix(admin-ui): apply page hooks to the admin_page_ fallback prefix - #52622

Merged
LiamSarsfield merged 5 commits into
trunkfrom
fm/admin-ui-fallback-page-hooks
Oct 1, 2026
Merged

LiamSarsfield merged 5 commits into
trunkfrom
fm/admin-ui-fallback-page-hooks

Conversation

@LiamSarsfield

@LiamSarsfield LiamSarsfield commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

  • Admin_Menu::add_menu() now registers each page's hooks under both jetpack_page_<slug> and admin_page_<slug>. WordPress uses the admin_page_ name when a user can open the page but has no Jetpack top-level menu, for example an editor on a site that is not connected yet while the Jetpack plugin is active. The core-notice hiding and the design-tokens stylesheet now load on that page too. The return value of add_menu() is unchanged.
  • The My Jetpack load hook is handled separately in fix(my-jetpack): fix page loading for editors on unconnected sites #52614; this change covers Admin_Menu's own hooks.
  • Adds one PHPUnit test for the admin_page_ hook.

Bundles that change (every plugin that includes admin-ui): agents-manager, automattic-for-agencies-client, backup, beta, boost, classic-theme-helper-plugin, inspect, jetpack, mu-wpcom-plugin, paypal-payment-buttons, premium-analytics, protect, search, social, starter-plugin, stats, videopress, wpcloud-sso, wpcomsh.

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • Activate the Jetpack plugin on a site that is not connected and not in offline mode.
  • As an editor, open wp-admin/admin.php?page=my-jetpack. The body class is admin_page_my-jetpack. Before this change, neither jetpack-admin-ui-design-tokens-css nor jetpack-admin-ui-hide-core-notices-inline-css is in the page; after it, both are.
  • As an administrator, open the same page. It uses jetpack_page_my-jetpack and has both styles before and after; screenshots are byte-identical.

When the user has no Jetpack top-level menu, WordPress registers an
Admin_Menu page as admin_page_<slug>, so the core-notice hiding and the
design-tokens stylesheet, both keyed on jetpack_page_<slug>, never ran.
Register both prefixes.
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the fm/admin-ui-fallback-page-hooks branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fm/admin-ui-fallback-page-hooks
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fm/admin-ui-fallback-page-hooks

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Package] Admin Ui [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Sep 22, 2026
@jp-launch-control

jp-launch-control Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/admin-ui/src/class-admin-menu.php 246/276 (89.13%) 0.40% -1 💚

Full summary · PHP report · JS report

Mention offline mode in the Jetpack changelog entry too.
@LiamSarsfield
LiamSarsfield marked this pull request as ready for review September 22, 2026 15:58
@LiamSarsfield LiamSarsfield removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Sep 22, 2026
@LiamSarsfield
LiamSarsfield requested review from a team and xavier-lc September 22, 2026 15:58
LiamSarsfield added a commit that referenced this pull request Sep 22, 2026
LiamSarsfield added a commit that referenced this pull request Sep 22, 2026

@xavier-lc xavier-lc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks right to me: admin_page_ is only used when the Jetpack plugin skips its top-level menu for a non-admin, which covers both the disconnected and offline cases, so adding the changelog entry to the Jetpack plugin alone is correct. I have two small test cleanups inline and nothing blocking.

Comment on lines +206 to +208
// test_page_suffix_matches leaves a `jetpack` entry behind, which would give core's jetpack_page_ name.
global $admin_page_hooks;
unset( $admin_page_hooks['jetpack'] );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on which tests ran first. setUp() already resets $menu, $submenu, $_parent_pages and $_registered_pages. Adding $admin_page_hooks = array(); there would let you drop this unset and the comment that names another test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I moved the $admin_page_hooks reset into setUp() and dropped the unset and its comment. Once the hooks reset for every test, test_page_suffix_matches also needed the menu registered per data set, so that's in 5e489d3 too.

Comment on lines +209 to +218
wp_set_current_user(
wp_insert_user(
array(
'user_login' => 'fallback_editor',
'user_pass' => 'pass',
'role' => 'editor',
)
)
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This user is never deleted. wp_set_current_user( self::$editor_user_id ); reuses the class's editor, the same way the neighbouring tests do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, it now uses self::$editor_user_id like the neighbouring tests.

@xavier-lc xavier-lc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, both addressed. LGTM.

@LiamSarsfield
LiamSarsfield merged commit ffee571 into trunk Oct 1, 2026
124 checks passed
@LiamSarsfield
LiamSarsfield deleted the fm/admin-ui-fallback-page-hooks branch October 1, 2026 08:23
@github-actions github-actions Bot added this to the jetpack/16.3 milestone Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Admin Ui [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants