fix(posts): add 'published' action for post status transitions#1933
Open
faisalahammad wants to merge 2 commits into
Open
fix(posts): add 'published' action for post status transitions#1933faisalahammad wants to merge 2 commits into
faisalahammad wants to merge 2 commits into
Conversation
Add a new 'published' action value to the Posts connector so that any post transitioning to the 'publish' status is logged with action 'published' instead of the coarse 'updated' or 'created'. This enables users to create alerts filtered by the published action. - Add 'published' label in get_action_labels(). - Set action='published' in callback_transition_post_status() when new_status is 'publish', including draft→publish, new→publish, and future→publish. - Guard the 'created' fallback so it doesn't override 'published' for brand-new posts that go straight to publish. - Update PHPUnit expectations for all publish-transition rows. Fixes xwp#1813
Add a new 'published' action value to the Posts connector so that any post transitioning to the 'publish' status is logged with action 'published' instead of the coarse 'updated' or 'created'. This enables users to create alerts filtered by the published action. - Add 'published' label in get_action_labels(). - Set action='published' in callback_transition_post_status() when new_status is 'publish', including draft→publish, new→publish, and future→publish. - Guard the 'created' fallback so it doesn't override 'published' for brand-new posts that go straight to publish. - Update PHPUnit expectations for all publish-transition rows. Fixes xwp#1813
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.
Summary
Add a
publishedaction value to the Posts connector so users can alert on, filter by, and surface post-publish events specifically — instead of lumping them under the genericupdatedorcreatedactions.Fixes #1813
Changes
connectors/class-connector-posts.php
Before:
get_action_labels()returned onlyupdated,created,trashed,untrashed,deleted. The callback summary said “X published” but the logged action wasupdatedorcreated.After: Added
publishedlabel and setaction = 'published'whenever the new status ispublish(draft→publish, new→publish, future→publish). Thecreatedfallback is now guarded so it does not overridepublishedfor brand-new posts that go straight to publish.tests/phpunit/connectors/test-class-connector-posts.php
Updated every
new_status = 'publish'expectation intest_callback_transition_post_statusto assert the newpublishedaction. All other transitions unchanged.Testing
npm run test-one -- --filter Test_WP_Stream_Connector_Posts— expect OK.plugin-fix-1813.zipto a WP 6.9+/PHP 7.4+ site, activate."Hello World" Post published.Changelog