-
Notifications
You must be signed in to change notification settings - Fork 83
Add hide_for method to Comment class #2662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
37a94b4 to
f80d3a5
Compare
This method returns post types whose comments should be hidden in the WordPress admin. Used for filtering comment queries and auto-approving comments on non-public post types like ap_post.
f80d3a5 to
0ccf3fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new get_non_public_post_types() helper method to the Comment class and refactors existing methods to use it. However, the refactoring introduces significant behavioral changes that break backward compatibility.
Key Changes:
- Adds
get_non_public_post_types()method that retrieves all WordPress post types withpublic => false - Refactors
comment_query()to always filter non-public post types instead of only whenactivitypub_create_postsoption is enabled - Refactors
pre_comment_approved()to auto-approve comments on any non-public post type instead of justap_postwhen the option is enabled
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| includes/class-comment.php | Adds new get_non_public_post_types() method and refactors comment_query() and pre_comment_approved() to use it, removing the Posts import and activitypub_create_posts option checks |
| tests/phpunit/tests/includes/class-test-comment.php | Adds basic unit test for the new method and imports Posts class |
| .github/changelog/add-get-non-public-post-types | Adds changelog entry for the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9ed7c81 to
249248b
Compare
This method returns post types whose comments should be hidden in the WordPress admin comments list.
249248b to
19f34f0
Compare
jeherve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and tests well for me. I like the addition of the filter, it should allow third-parties to hook into that logic if necessary.
73b75bb to
19f34f0
Compare
Proposed changes:
hide_for()method to theCommentclass that returns post types whose comments should be hidden in the WordPress admin.comment_query()andpre_comment_approved()methods to use the new helper method.activitypub_hide_comments_forfilter to customize which post types have hidden comments.Other information:
Testing instructions:
npm run env-test -- --filter=test_hide_forap_postis the only post type in the default listChangelog entry
Changelog entry added manually via
composer changelog:add.