Skip to content

Commit 9ed7c81

Browse files
committed
Refactor comment post type hiding logic
Renamed get_post_types_to_hide_comments_for() to hide_for() and updated its implementation to use Posts::POST_TYPE. Updated all references to use the new method, simplifying and clarifying the logic for determining which post types to hide comments for.
1 parent 0ccf3fe commit 9ed7c81

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

includes/class-comment.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Activitypub;
99

1010
use Activitypub\Collection\Actors;
11+
use Activitypub\Collection\Posts;
1112

1213
/**
1314
* ActivityPub Comment Class.
@@ -703,7 +704,7 @@ public static function comment_query( $query ) {
703704

704705
// Do only exclude interactions of `ap_post` post type.
705706
if ( \is_admin() ) {
706-
$query->query_vars['post_type'] = array_diff( \get_post_types_by_support( 'comments' ), self::get_post_types_to_hide_comments_for() );
707+
$query->query_vars['post_type'] = array_diff( \get_post_types_by_support( 'comments' ), self::hide_for() );
707708
return;
708709
}
709710

@@ -767,7 +768,7 @@ public static function pre_comment_approved( $approved, $comment_data ) {
767768
$post_id = $comment_data['comment_post_ID'];
768769
$post = \get_post( $post_id );
769770

770-
if ( $post && in_array( $post->post_type, self::get_post_types_to_hide_comments_for(), true ) ) {
771+
if ( $post && in_array( $post->post_type, self::hide_for(), true ) ) {
771772
return 1;
772773
}
773774

@@ -830,8 +831,8 @@ public static function is_comment_type_enabled( $comment_type ) {
830831
*
831832
* @return string[] Array of post type names to hide comments for.
832833
*/
833-
public static function get_post_types_to_hide_comments_for() {
834-
$post_types = \get_post_types( array( 'public' => false ), 'names' );
834+
public static function hide_for() {
835+
$post_types = array( Posts::POST_TYPE );
835836

836837
/**
837838
* Filters the list of post types to hide comments for.

0 commit comments

Comments
 (0)