summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php')
-rw-r--r--plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php
index b5f3cf8e..30783d14 100644
--- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php
+++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php
@@ -50,6 +50,7 @@ abstract class WPCOM_JSON_API_Post_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint
'metadata' => '(array) Array of post metadata keys and values. All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with access. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.',
'meta' => '(object) API result meta data',
'capabilities' => '(object) List of post-specific permissions for the user; publish_post, edit_post, delete_post',
+ 'revisions' => '(array) List of post revision IDs. Only available for posts retrieved with context=edit.',
'other_URLs' => '(object) List of URLs for this post. Permalink and slug suggestions.',
);
@@ -299,13 +300,13 @@ abstract class WPCOM_JSON_API_Post_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint
$response[$key] = (int) $this->api->post_like_count( $blog_id, $post->ID );
break;
case 'i_like' :
- $response[$key] = (int) $this->api->is_liked( $blog_id, $post->ID );
+ $response[$key] = (bool) $this->api->is_liked( $blog_id, $post->ID );
break;
case 'is_reblogged':
- $response[$key] = (int) $this->api->is_reblogged( $blog_id, $post->ID );
+ $response[$key] = (bool) $this->api->is_reblogged( $blog_id, $post->ID );
break;
case 'is_following':
- $response[$key] = (int) $this->api->is_following( $blog_id );
+ $response[$key] = (bool) $this->api->is_following( $blog_id );
break;
case 'global_ID':
$response[$key] = (string) $this->api->add_global_ID( $blog_id, $post->ID );
@@ -475,6 +476,20 @@ abstract class WPCOM_JSON_API_Post_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint
case 'capabilities' :
$response[$key] = $capabilities;
break;
+ case 'revisions' :
+ if ( 'edit' !== $context ) {
+ continue;
+ }
+ $revisions = array();
+ $post_revisions = wp_get_post_revisions( $post->ID );
+
+ foreach ( $post_revisions as $_post ) {
+ $revisions[] = $_post->ID;
+ }
+
+ $response[$key] = $revisions;
+
+ break;
case 'other_URLs' :
$other_urls = array();
@@ -651,8 +666,8 @@ abstract class WPCOM_JSON_API_Post_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint
/**
* Get extra post permalink suggestions
- * @param int $postID
- * @param string $title
+ * @param int $postID
+ * @param string $title
* @return array array of permalink suggestions: 'permalink_URL', 'suggested_slug'
*/
function get_post_permalink_suggestions( $postID, $title ) {