diff options
author | Yury German <blueknight@gentoo.org> | 2019-05-22 00:42:33 -0400 |
---|---|---|
committer | Yury German <blueknight@gentoo.org> | 2019-05-22 00:42:33 -0400 |
commit | e89abce1b01dda89efdf230101d1aa3c877b3b6c (patch) | |
tree | cfb27a564c1f4cfff30d18dbf591efd48283b154 /plugins/jetpack/json-endpoints/class.wpcom-json-api-get-autosave-v1-1-endpoint.php | |
parent | Adding Twentyninetten (diff) | |
download | blogs-gentoo-e89abce1b01dda89efdf230101d1aa3c877b3b6c.tar.gz blogs-gentoo-e89abce1b01dda89efdf230101d1aa3c877b3b6c.tar.bz2 blogs-gentoo-e89abce1b01dda89efdf230101d1aa3c877b3b6c.zip |
Updating of Plugins and Themes
List of Plugins updates --
akismet.4.1.2
google-authenticator.0.52
jetpack.7.3.1
List of Themes Updates --
mantra.3.2.0
twentyfifteen.2.5
twentyfourteen.2.7
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-get-autosave-v1-1-endpoint.php')
-rw-r--r-- | plugins/jetpack/json-endpoints/class.wpcom-json-api-get-autosave-v1-1-endpoint.php | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-autosave-v1-1-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-autosave-v1-1-endpoint.php deleted file mode 100644 index 6b58a08d..00000000 --- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-get-autosave-v1-1-endpoint.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -new WPCOM_JSON_API_Get_Autosave_v1_1_Endpoint( array( - 'description' => 'Get the most recent autosave for a post.', - 'group' => '__do_not_document', - 'stat' => 'posts:autosave', - 'min_version' => '1.1', - 'method' => 'GET', - 'path' => '/sites/%s/posts/%d/autosave', - 'path_labels' => array( - '$site' => '(int|string) Site ID or domain', - '$post_ID' => '(int) The post ID', - ), - 'response_format' => array( - 'ID' => '(int) autodraft post ID', - 'post_ID' => '(int) post ID', - 'author_ID' => '(int) author ID', - 'title' => '(HTML) The post title.', - 'content' => '(HTML) The post content.', - 'excerpt' => '(HTML) The post excerpt.', - 'preview_URL' => '(string) preview URL for the post', - 'modified' => '(ISO 8601 datetime) modified time', - ), - - 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/1/autosave', -) ); - -class WPCOM_JSON_API_Get_Autosave_v1_1_Endpoint extends WPCOM_JSON_API_Post_v1_1_Endpoint { - function __construct( $args ) { - parent::__construct( $args ); - } - - // /sites/%s/posts/%d/autosave -> $blog_id, $post_id - function callback( $path = '', $blog_id = 0, $post_id = 0 ) { - - $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); - if ( is_wp_error( $blog_id ) ) { - return $blog_id; - } - - $post = get_post( $post_id ); - - if ( ! $post || is_wp_error( $post ) ) { - return new WP_Error( 'unknown_post', 'Unknown post', 404 ); - } - - if ( ! current_user_can( 'edit_post', $post->ID ) ) { - return new WP_Error( 'unauthorized', 'User cannot edit post', 403 ); - } - - $autosave = wp_get_post_autosave( $post->ID ); - - if ( $autosave ) { - $preview_url = add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ); - $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); - $preview_url = add_query_arg( array( 'preview_id' => $auto_ID, 'preview_nonce' => $nonce ), $preview_url ); - - return array( - 'ID' => $autosave->ID, - 'author_ID' => $autosave->post_author, - 'post_ID' => $autosave->post_parent, - 'title' => $autosave->post_title, - 'content' => $autosave->post_content, - 'excerpt' => $autosave->post_excerpt, - 'preview_URL' => $preview_url, - 'modified' => $this->format_date( $autosave->post_modified ) - ); - } else { - return new WP_Error( 'not_found', 'No autosaves exist for this post', 404 ); - } - } -} |