Preserve scheduled and private status when publishing custom posts#25552
Preserve scheduled and private status when publishing custom posts#25552crazytonyli wants to merge 5 commits into
Conversation
The custom post publish flow flattened the user's selected status to .publish in both the Post Settings and editor-content paths, dropping .future (scheduled) and .private (password/private visibility). The save action now normalizes status only for selections that lack their own publishing semantics (drafts, pending, or unspecified), and preserves .future and .private as the user selected them.
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32293 | |
| Version | PR #25552 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 87b6edd | |
| Installation URL | 628m3njbjbi80 |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32293 | |
| Version | PR #25552 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 87b6edd | |
| Installation URL | 4amo9bcka2kog |
| /// publishing semantics (scheduled, password/private visibility); every | ||
| /// other selection — draft or pending — collapses to `.publish` so the | ||
| /// post is published normally. | ||
| func normalizedPublishStatus() -> PostStatus { |
There was a problem hiding this comment.
What happens if a user without publishing permission goes through this flow? Will it preserve pending?
There was a problem hiding this comment.
Good catch! Addressed in the latest commit.
|
|
||
| case (.newPost(let existing), true): | ||
| var params = settings.makeCreateParameters(from: existing, taxonomies: taxonomies) | ||
| params.status = params.status?.normalizedPublishStatus() ?? .publish |
There was a problem hiding this comment.
Maybe not related to this PR, but can params.status ever be nil?
If not, maybe it doesn't need to be optional and we could flatten this out? Or maybe it should be able to be nil to represent "the user hasn't told us what they want"?
There was a problem hiding this comment.
I'm okay with it being non-optional. We can always give new posts a default "draft" status, which sounds very reasonable to me.
| @@ -0,0 +1,32 @@ | |||
| # Preserve Private Visibility When Publishing a Custom Post | |||
There was a problem hiding this comment.
Should we have one of these for the scheduled case?
There was a problem hiding this comment.
I have included more status in a new test case 87b6edd


Description
The publish path was unconditionally setting
params.status = .publishat four call sites inCustomPostEditorService. It now preserves.futureand.private, and only normalizes drafts/pending/nil to.publish.I have added a test case under
Tests/AgentTests/post-editor/that covers the private case end-to-end.