Skip to content

Commit

Permalink
Add terms to return value in existing Post backup endpoint (#12696)
Browse files Browse the repository at this point in the history
  • Loading branch information
thingalon authored and jeherve committed Jun 27, 2019
1 parent 523ba0e commit a91891f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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

0 comments on commit a91891f

Please sign in to comment.