o2 Posting Access: Apply the pending review status on all post creation paths - #749
Closed
obenland wants to merge 1 commit into
Closed
o2 Posting Access: Apply the pending review status on all post creation paths#749obenland wants to merge 1 commit into
obenland wants to merge 1 commit into
Conversation
…on paths. The plugin grants non-members `publish_posts`, `edit_posts` and `edit_published_posts` so o2's front end renders its post form for them, and then holds their submissions for review. That second step was attached only to o2's own `o2_create_post` filter, so it applied to the front end editor but not to the other ways a post can be created. Move the status handling to `wp_insert_post_data`, which every creation path runs through. The filter only touches posts a logged-in user is authoring for themselves, leaving editorial, cron and WP-CLI inserts alone, and exempts statuses that are not publicly visible so o2's auto-draft step is unaffected. Also correct two checks in the capability filter: the `in_array()` short-circuit searched the values of a `cap => bool` map rather than its keys and so never matched, and the guard consulted the current user instead of the user the filter was called for. Adds a PHPUnit suite for the plugin, along with a `make` wp-env environment for the make.wordpress.org plugins to run it in. The suite runs as multisite, since `is_user_member_of_blog()` short-circuits to true otherwise and none of this code would be exercised. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
The plugin grants non-members
publish_posts,edit_postsandedit_published_postsso o2's front end renders its post form for them, and then holds their submissions for review. That second step is attached only to o2's owno2_create_postfilter, so it applies to the front end editor but not to the other ways a post can be created.Changes
wp_insert_post_data, which every creation path runs through. The filter only touches posts a logged-in user is authoring for themselves, so editorial, cron and WP-CLI inserts are left alone, and it exempts statuses that are not publicly visible so o2's auto-draft step is unaffected.add_post_capabilities(). Thein_array()short-circuit searched the values of acap => boolmap rather than its keys, so it never matched; and the guard consulted the current user rather than the user the filter was called for.Tests
Adds a PHPUnit suite covering the plugin's posting access behaviour: the capability grant,
user_can_publish()(including themoderation_keysand filter branches), the review status across creation paths, and how a post awaiting review is presented.The suite runs as multisite.
is_user_member_of_blog()returns true unconditionally when! is_multisite(), which makes both the capability grant anduser_can_publish()no-ops, so on single site the assertions would pass without exercising any of this code.WP_TESTS_MULTISITEis defined in the plugin's bootstrap rather than via wp-env'smultisiteoption, which conflicts with the test suite's own network install.Also adds a
makewp-env environment for the make.wordpress.org plugins to run it in, and a matching CI job.