fix(newsletters): activate ads in one step from status toggle#479
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Newspack Newsletters “Newsletter Ad” editor so the Active/Inactive status control becomes a true one-step toggle by immediately persisting the corresponding post_status change (publish/draft) via editPost() + savePost(), avoiding the native Publish flow and its pre-publish vocabulary.
Changes:
- Dispatch
savePost()from the editor status control so toggling Active/Inactive commits immediately. - Keep the editor’s custom status abstraction (Active/Inactive) as the only surfaced status UI while bypassing the native Publish button workflow.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f178317 to
eab5720
Compare
dkoo
left a comment
There was a problem hiding this comment.
Clean, well-scoped change — makes the Newsletter Ad status toggle a true one-step switch. I verified it end-to-end in an isolated env: Active commits to publish and Inactive to draft in a single step with no pre-publish panel (both DB-confirmed), and a past expiration date surfaces the warning Notice at the top of the Ad settings sidebar. No blockers.
The editPost({ status }) + savePost() idiom is correct: @wordpress/data dispatches synchronously, so savePost() persists the just-set status, and this matches the existing disable-auto-ads.js pattern. Two non-blocking notes inline.
Release risk: LOW — single editor-JS file, no PHP/contract/schema surface, verified against a running env.
|
Hey @adekbadek, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
Changes proposed in this Pull Request:
Follow-up to #476 (ad editor Active/Inactive control) and #478 (ads list Quick Edit status), both merged.
1. One-step activation. Review feedback on the editor control: picking Active only set intent — the publisher then had to click WP's native Publish button, which opens the pre-publish confirmation exposing "Visibility: Public / Publish: Immediately". That's the exact WP vocabulary the Active/Inactive control is meant to abstract away, leaking through a two-step flow. This makes the toggle a true on/off switch: selecting Active/Inactive applies and persists the status in one step (
editPost+savePost), the same immediate-commit model as the list Quick Edit. Because activation no longer routes through the native Publish button, the pre-publish panel (and its raw Visibility/Publish wording) never appears.Disabling the pre-publish panel via
disablePublishSidebar()was rejected: that setting lives in the globalcorepreferences scope, so it would suppress pre-publish checks for posts and newsletters too.2. Date advisories moved into the sidebar. Because one-step activation bypasses the native Publish flow, the date advisories that were only rendered in
PluginPrePublishPanel(expiration in the past, expiry before start, or the display-window summary) would otherwise never be seen. They now also render as a Notice at the top of the Ad settings panel, visible during normal editing and activation.How to test the changes in this Pull Request:
post_statusispublish, the list shows Active).draftthe same way.Other information: