Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Forms: remove related-posts from API calls
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ protected function __construct() {
// Add to REST API post type allowed list.
add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_feedback_rest_api_type' ) );

// Don't let related posts hook into feedback post type.
add_filter( 'jetpack_related_posts_allowed_post_types', array( $this, 'remove_from_related_posts_allowed_post_types' ) );

// Add "spam" as a post status
register_post_status(
'spam',
Expand Down Expand Up @@ -351,6 +354,16 @@ protected function __construct() {
}
}

/**
* Remove feedback post type from the allowed post types for related posts.
*
* @param array $post_types The allowed post types.
* @return array The allowed post types.
*/
public static function remove_from_related_posts_allowed_post_types( $post_types ) {
return array_diff( $post_types, array( 'feedback' ) );
}

/**
* Prevent 'jp-forms-view' script from being concatenated.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Forms: remove related-posts from API calls
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,16 @@ protected function allow_feature_toggle() {
public function rest_register_related_posts() {
/** This filter is already documented in class.json-api-endpoints.php */
$post_types = apply_filters( 'rest_api_allowed_post_types', array( 'post', 'page', 'revision' ) );

/**
* Filter the post types that are allowed to have related posts.
*
* @since $$next-version$$
*
* @param array $post_types The post types that are allowed to have related posts.
*/
$post_types = apply_filters( 'jetpack_related_posts_allowed_post_types', $post_types );
Copy link
Member Author

@simison simison Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking if the filter should mention rest_api somewhere, e.g. jetpack_related_posts_rest_api_allowed_post_types


foreach ( $post_types as $post_type ) {
register_rest_field(
$post_type,
Expand Down
Loading