feat(handoff): add URL-based handoff with customizable banner text#4603
Open
thomasguillot wants to merge 2 commits intotrunkfrom
Open
feat(handoff): add URL-based handoff with customizable banner text#4603thomasguillot wants to merge 2 commits intotrunkfrom
thomasguillot wants to merge 2 commits intotrunkfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds URL-based “handoff” navigation (beyond managed plugins) and expands the return-banner UX so users can get back to their originating Newspack screen, including on wizard pages where the banner must be server-rendered.
Changes:
- Add URL-based handoff support (new component props + new
POST /newspack/v1/handoffendpoint). - Allow customizable banner body/button text across Handoff + ActionCard.
- Redesign and re-position the handoff banner (including wizard-page static rendering and admin layout offsets).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/wizards/handoff-banner/style.scss | Updates banner styling to new primary/white design and spacing vars. |
| src/wizards/handoff-banner/index.js | Adds layout offset logic (sidebar + WooCommerce header) and supports banner text/button text via dataset. |
| src/wizards/componentsDemo/index.js | Updates demo to exercise URL-based handoff and banner customization. |
| packages/components/src/handoff/index.js | Adds url, bannerText, bannerButtonText props and URL-handling flow. |
| packages/components/src/handoff/README.md | Documents new URL-based handoff and banner customization options. |
| packages/components/src/action-card/index.js | Adds handoffUrl plus banner text props passthrough to Handoff. |
| includes/wizards/class-wizard.php | Introduces newspack_before_wizard_content hook for wizard-page pre-content output. |
| includes/class-handoff-banner.php | Adds server-rendered wizard banner, adjusts enqueueing, and expands stored options. |
| includes/api/class-plugins-controller.php | Registers new /handoff REST endpoint and passes banner text options through plugin handoff. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
All Submissions:
Context:
The handoff feature appears to have been broken on
trunkfor some time — the return banner doesn't seem to render at all when testing via the Components Demo. On top of that, the old implementation had become quite dated: the JS banner was embedding the old Newspack logo as a hardcoded inline SVG in CSS. This PR fixes the breakage, removes the logo entirely, and modernises the banner design and the component's API.Changes proposed in this Pull Request:
Extends the Handoff component and ActionCard to support handing off to any arbitrary WordPress admin URL, not just Newspack-managed plugins. Previously, handoff was only possible when a managed plugin slug was available.
Key changes:
urlprop onHandoffcomponent for URL-based navigation (no plugin required)handoffUrlprop onActionCardas a convenience wrapperbannerTextandbannerButtonTextprops on both components for customizing the return banner messagePOST /newspack/v1/handoffREST endpoint that stores the destination URL and banner options; validates that the URL is same-site to prevent open-redirect attacksinsert_handoff_banner_static) for Newspack wizard pages where the JS banner can't render, hooked via a newnewspack_before_wizard_contentactionneeds_handoff_return_ui()gate no longer requires setup to be incomplete — the banner now shows whenever a handoff is activeclear_handoff_url()extended to also clear on non-Newspack screens when a destination page was registered, preventing the banner from lingering on unrelated admin pagesregister_handoff_for_plugin()now resetsNEWSPACK_HANDOFF_DESTINATION_PAGEto prevent stale state from a prior URL-based handoff affecting subsequent plugin-based handoffsHow to test the changes in this Pull Request:
bannerText/bannerButtonTextwhen passed.Other information: