Dock: keep off-site admin menus out, and put the wp-admin originals back - #645
Merged
Conversation
A host can extend the admin menu with links to its own control panel, and can repoint Core entries at its own versions of those screens. Nothing on another host loads in a window, so those tiles could only ever escape to a browser tab. The builder now drops off-site entries, honours the hide-if-js class, and restores a hidden wp-admin row when the off-site row that displaced it is dropped. A menu with no page of its own and no child left to open is dropped too. Icons are sampled across admin_menu so art moved into a stylesheet mid-hook still reaches the dock. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adopting a surviving child's URL moved only the URL. Everything keyed off the menu's slug still read the off-site one, so a rescued Plugins tile reported isCore false, sorted into the plugin cohort at the end of the dock, and picked up whoever registered the replacement as its owning plugin. The openstation_dock_item filter saw the off-site slug too, which would have made openstation_inject_appearance_tabs() skip a rescued Appearance menu. Identity now travels with the URL. Renames the submenu row flag from external to offSite. The window's tab strip already uses data-kind="external" for plugin-opened sub-iframes, which are on-site, and the two meanings sat a few lines apart. The constellation's "opens in a new tab" note moves from an aria-label on the row to a visually hidden span, so it extends the accessible name instead of replacing it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…pcom-admin-menu-af82c2
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…y label or fallback Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
offSiteand marked with an outbound glyph in the constellation flyout. It never becomes a tab in the window's tab strip, because the iframe can't load it.isCore,multi,placement,pluginFileand the slug passed toopenstation_dock_itemall come from the adopted child.hide-if-jsclass are dropped. They are out of the classic sidebar, so they were only ever duplicates in the dock.add_menu_page()accepts a null callback, andadmin.phpanswers such a slug with "Cannot load ."admin_menuand recorded write-once, so art moved into a stylesheet mid-hook still reaches the dock. The live value still wins whenever there is one.New filter:
openstation_menu_item_is_external( bool $external, string $url ).The submenu flag is
offSite, notexternal, because the tab strip already usesdata-kind="external"for plugin-opened sub-iframes, which are on-site.Note the scope: a plugin that registers its top-level menu as a link to its own hosted service loses its dock tile on any site, not just on WordPress.com. Before this it opened a browser tab. Children are the exception, top-level entries are not, because a tile that can never open a window lies about what a dock click does. Covered in the testing steps below.
Why are these changes being made?
On WordPress.com, a large part of the admin menu points at wordpress.com. My Home, Theme Showcase, Hosting and Upgrades are wordpress.com URLs, and Jetpack repoints Themes, Add Plugin and All Users at their Calypso versions. The shell was sending all of them to a new browser tab, one click at a time.
Jetpack does the repointing by keeping the wp-admin row and marking it
hide-if-js, then appending a duplicate beside it. That is also why some submenus showed twice: the dock was rendering both copies. Reading the class gives us both fixes, and reading it in the right order gives us the wp-admin URL for free.Jetpack's
override_svg_icons()moves every SVG-data-URI icon into an inline stylesheet and blanks the menu array, which is why Jetpack and MailPoet were wearing generic cogs.None of this is host-specific. The rules read the menu arrays, not the host: URL host against
admin_url()andhome_url(),pluginFilefor the plugin exception, thehide-if-jsclass, andhas_action()on the page hook.Testing instructions
Needs a WordPress.com site (Simple or Atomic) with the admin interface set to the default WordPress.com style, and OpenStation enabled for your user. Jetpack, and ideally MailPoet, active.
The dock
plugins.php, not the installer and not wordpress.com.The restored entries
themes.phpin a window.plugin-install.php.users.php.The plugin exception
An off-site top-level plugin menu
No regressions off WordPress.com
?page=wc-adminrather than the broken top-level slug.