Skip to content

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Dec 18, 2025

Proposed changes:

  • Add new hide_for() method to the Comment class that returns post types whose comments should be hidden in the WordPress admin.
  • Refactor comment_query() and pre_comment_approved() methods to use the new helper method.
  • Add activitypub_hide_comments_for filter to customize which post types have hidden comments.
  • Add comprehensive unit tests for the new functionality and filter behavior.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Run the test suite: npm run env-test -- --filter=test_hide_for
  • Verify the tests pass and confirm:
    • ap_post is the only post type in the default list
    • The filter can add/remove post types
    • The filter affects both comment visibility and auto-approval

Changelog entry

Changelog entry added manually via composer changelog:add.

Copilot AI review requested due to automatic review settings December 18, 2025 08:45
@pfefferle pfefferle self-assigned this Dec 18, 2025
@pfefferle pfefferle requested a review from a team December 18, 2025 08:45
@pfefferle pfefferle force-pushed the add/get-non-public-post-types branch from 37a94b4 to f80d3a5 Compare December 18, 2025 08:51
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.
@pfefferle pfefferle force-pushed the add/get-non-public-post-types branch from f80d3a5 to 0ccf3fe Compare December 18, 2025 08:51
@pfefferle pfefferle changed the title Add get_non_public_post_types method to Comment class Add get_post_types_to_hide_comments_for method to Comment class Dec 18, 2025
Copy link

Copilot AI left a 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 with public => false
  • Refactors comment_query() to always filter non-public post types instead of only when activitypub_create_posts option is enabled
  • Refactors pre_comment_approved() to auto-approve comments on any non-public post type instead of just ap_post when 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.

@pfefferle pfefferle force-pushed the add/get-non-public-post-types branch from 9ed7c81 to 249248b Compare December 18, 2025 09:05
@pfefferle pfefferle changed the title Add get_post_types_to_hide_comments_for method to Comment class Add hide_for method to Comment class Dec 18, 2025
This method returns post types whose comments should be hidden in the
WordPress admin comments list.
@pfefferle pfefferle force-pushed the add/get-non-public-post-types branch from 249248b to 19f34f0 Compare December 18, 2025 09:14
@pfefferle pfefferle requested a review from jeherve December 18, 2025 09:14
jeherve
jeherve previously approved these changes Dec 18, 2025
Copy link
Member

@jeherve jeherve left a 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.

@pfefferle pfefferle merged commit bfc5210 into trunk Dec 18, 2025
10 checks passed
@pfefferle pfefferle deleted the add/get-non-public-post-types branch December 18, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants