|
8 | 8 | namespace Activitypub; |
9 | 9 |
|
10 | 10 | use Activitypub\Collection\Actors; |
11 | | -use Activitypub\Collection\Posts; |
12 | 11 |
|
13 | 12 | /** |
14 | 13 | * ActivityPub Comment Class. |
@@ -704,9 +703,7 @@ public static function comment_query( $query ) { |
704 | 703 |
|
705 | 704 | // Do only exclude interactions of `ap_post` post type. |
706 | 705 | if ( \is_admin() ) { |
707 | | - if ( \get_option( 'activitypub_create_posts', false ) ) { |
708 | | - $query->query_vars['post_type'] = array_diff( \get_post_types_by_support( 'comments' ), array( Posts::POST_TYPE ) ); |
709 | | - } |
| 706 | + $query->query_vars['post_type'] = array_diff( \get_post_types_by_support( 'comments' ), self::get_non_public_post_types() ); |
710 | 707 | return; |
711 | 708 | } |
712 | 709 |
|
@@ -767,14 +764,11 @@ public static function pre_comment_approved( $approved, $comment_data ) { |
767 | 764 | return 1; |
768 | 765 | } |
769 | 766 |
|
770 | | - // Auto approve reactions to an `ap_post`. |
771 | | - if ( \get_option( 'activitypub_create_posts', false ) ) { |
772 | | - $post_id = $comment_data['comment_post_ID']; |
773 | | - $post = \get_post( $post_id ); |
| 767 | + $post_id = $comment_data['comment_post_ID']; |
| 768 | + $post = \get_post( $post_id ); |
774 | 769 |
|
775 | | - if ( $post && Posts::POST_TYPE === $post->post_type ) { |
776 | | - return 1; |
777 | | - } |
| 770 | + if ( $post && in_array( $post->post_type, self::get_non_public_post_types(), true ) ) { |
| 771 | + return 1; |
778 | 772 | } |
779 | 773 |
|
780 | 774 | return $approved; |
@@ -827,4 +821,20 @@ public static function pre_wp_update_comment_count_now( $new_count, $old_count, |
827 | 821 | public static function is_comment_type_enabled( $comment_type ) { |
828 | 822 | return '1' === get_option( "activitypub_allow_{$comment_type}s", '1' ); |
829 | 823 | } |
| 824 | + |
| 825 | + /** |
| 826 | + * Get all post types that are not public. |
| 827 | + * |
| 828 | + * @return string[] Array of non-public post type names. |
| 829 | + */ |
| 830 | + public static function get_non_public_post_types() { |
| 831 | + $post_types = \get_post_types( array( 'public' => false ), 'names' ); |
| 832 | + |
| 833 | + /** |
| 834 | + * Filters the list of non-public post types. |
| 835 | + * |
| 836 | + * @param string[] $post_types Array of non-public post type names. |
| 837 | + */ |
| 838 | + return \apply_filters( 'activitypub_non_public_post_types', $post_types ); |
| 839 | + } |
830 | 840 | } |
0 commit comments