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 terms to return value in existing Post backup endpoint #12696

Merged
merged 1 commit into from
Jun 19, 2019
Merged
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
Expand Up @@ -17,14 +17,22 @@ function validate_input( $post_id ) {
}

protected function result() {
global $wpdb;

$post = get_post( $this->post_id );
if ( empty( $post ) ) {
return new WP_Error( 'post_not_found', __( 'Post not found', 'jetpack' ), 404 );
}

// Fetch terms associated with this post object
$terms = $wpdb->get_results( $wpdb->prepare(
"SELECT term_taxonomy_id, term_order FROM {$wpdb->term_relationships} WHERE object_id = %d;", $post->ID
) );

return array(
'post' => (array)$post,
'meta' => get_post_meta( $post->ID ),
'post' => (array)$post,
'meta' => get_post_meta( $post->ID ),
'terms' => (array)$terms,
);
}

Expand Down
5 changes: 3 additions & 2 deletions json-endpoints/jetpack/json-api-jetpack-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -1061,8 +1061,9 @@
'$post' => '(int) The post ID',
),
'response_format' => array(
'post' => '(array) Post table row',
'meta' => '(array) Associative array of key/value postmeta data',
'post' => '(array) Post table row',
'meta' => '(array) Associative array of key/value postmeta data',
'terms' => '(array) List of terms attached to the post object',
),
'example_request_data' => array(
'headers' => array(
Expand Down