-
Notifications
You must be signed in to change notification settings - Fork 843
Command Palette: Add site switcher command #46342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Command Palette: Add site switcher command #46342
Conversation
This command allows the user to search for and switch any of their WordPress.com connected sites.
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
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:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage SummaryCoverage changed in 1 file.
2 files are newly checked for coverage.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a site switcher feature to the WordPress Command Palette (WordPress 6.9+), allowing users to quickly switch between their WordPress.com connected sites directly from wp-admin. The implementation includes a REST API proxy endpoint, client-side caching via localStorage, and search filtering capabilities.
Key Changes:
- New REST API endpoint
/jetpack/v4/sites/compactthat proxies requests to WordPress.com's/me/sites/compactAPI to fetch the user's site list - Client-side JavaScript that integrates with WordPress Command Palette using
useCommandLoaderhook, with 1-hour localStorage caching - Script enqueuing logic that loads the site switcher on all admin pages
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
projects/plugins/jetpack/load-jetpack.php |
Includes the new site-switcher.php file in the plugin bootstrap |
projects/plugins/jetpack/changelog/switch-sites-command-palette |
Changelog entry documenting the enhancement |
projects/plugins/jetpack/_inc/site-switcher.php |
REST endpoint registration, script enqueuing, and user ID injection for cache namespacing |
projects/plugins/jetpack/_inc/site-switcher.js |
React-based command loader with search filtering, localStorage caching, and site navigation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 13 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Command palette introduced in WP 6.3.
|
Couple clarifying Qs:
|
Good question, it was just showing the current site. I've made a change to exclude the current site
If you're not connected then it will try to get your sites and fail (it's an authenticated endpoint), this means it won't offer you any sites to switch to. If you are connected, but the Jetpack site connection owner is someone else, then it'll use your connection and show you just the sites you have access to.
There are no similar core commands at this time, at least not that I was able to find. |
Cool; there's a helper method that returns the connection status, and that would help avoid firing API request that we know would fail. |
Fixes DOTCOM-15345
Proposed changes:
/jetpack/v4/sites/compactto fetch user's WordPress.com sites via the user's Jetpack connectionImplementation details:
_inc/site-switcher-endpoint.php: REST endpoint for Jetpack sites that proxies the public-api endpoint_inc/site-switcher.php: JS enqueueing, and config_inc/site-switcher.js: React hooks-based command loader with search filtering and cachingOther information:
_inc/*.jsfiles)Jetpack product discussion
Does this pull request change what data or activity we track or use?
Not really. This feature only fetches existing site data through the established Jetpack connection API.
Testing instructions:
Prerequisites:
Testing steps:
On Simple you need to also apply 198424-ghe-Automattic/wpcom
Cmd + KCtrl + KExpected behavior:
compactrequest for 1 hour)Cache testing:
/jetpack/v4/sites/compactScreen.Recording.2025-12-18.at.11.48.56.mov