Skip to content
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

add support for post_types to rest api #59

Merged
merged 4 commits into from
Sep 18, 2023
Merged

Conversation

mogmarsh
Copy link
Collaborator

add support for post_types to rest api and allow wp_curate_deduplication on all post types.
handles #54 and sort of #56 (could be handled better)

Comment on lines +28 to +41
/**
* Add post_type to rest post query if the type param is set.
*
* @param array<array<int, string>|string> $query_args The existing query args.
* @param \WP_REST_Request $request The REST request.
* @return array<array<int, string>|string>
*/
public function add_type_param( $query_args, $request ): array { // @phpstan-ignore-line
if ( ! empty( $request->get_param( 'type' ) ) && is_string( $request->get_param( 'type' ) ) ) {
$types = explode( ',', $request->get_param( 'type' ) );
$types = array_filter( $types, 'post_type_exists' );
$query_args['post_type'] = $types;
}
return $query_args;
Copy link
Member

Choose a reason for hiding this comment

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

I get where this is coming from, but I'm concerned that it's not really the correct use of the REST API. It will cause the API to try to apply the schema for the post post type to posts from any post type, which might have unpredictable results. The search endpoint is more annoying to use but might be more correct for this case.

Copy link
Contributor

@kaitlinbolling kaitlinbolling left a comment

Choose a reason for hiding this comment

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

👍 Looks like most of the changes in this PR were rolled back, but approving the small change to post-meta.json.

@mogmarsh mogmarsh merged commit 4800d34 into develop Sep 18, 2023
@mogmarsh mogmarsh deleted the fix/implementation-fixes branch September 18, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants