summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2019-05-22 01:01:36 -0400
committerYury German <blueknight@gentoo.org>2019-05-22 01:01:36 -0400
commit0914c92da22824025992c368c745546e41fbeb84 (patch)
tree965f6adf3b725e56d559fe4a93eff02281499dcc /plugins/jetpack/json-endpoints/class.wpcom-json-api-bulk-restore-post-endpoint.php
parentDeleting plugins for update (diff)
downloadblogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.tar.gz
blogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.tar.bz2
blogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.zip
Adding Plugins
Updating the following akismet.4.1.2, google-authenticator.0.52, jetpack.7.3.1 Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-bulk-restore-post-endpoint.php')
-rw-r--r--plugins/jetpack/json-endpoints/class.wpcom-json-api-bulk-restore-post-endpoint.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-bulk-restore-post-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-bulk-restore-post-endpoint.php
new file mode 100644
index 00000000..2e59cc1e
--- /dev/null
+++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-bulk-restore-post-endpoint.php
@@ -0,0 +1,69 @@
+<?php
+
+new WPCOM_JSON_API_Bulk_Restore_Post_Endpoint( array(
+ 'description' => 'Restore multiple posts.',
+ 'group' => 'posts',
+ 'stat' => 'posts:1:bulk-restore',
+ 'min_version' => '1.1',
+ 'max_version' => '1.1',
+ 'method' => 'POST',
+ 'path' => '/sites/%s/posts/restore',
+ 'path_labels' => array(
+ '$site' => '(int|string) Site ID or domain',
+ ),
+ 'request_format' => array(
+ 'post_ids' => '(array|string) An array, or comma-separated list, of Post IDs to restore.',
+ ),
+
+ 'response_format' => array(
+ 'results' => '(object) An object containing results, '
+ ),
+
+ 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/restore',
+
+ 'example_request_data' => array(
+ 'headers' => array(
+ 'authorization' => 'Bearer YOUR_API_TOKEN'
+ ),
+
+ 'body' => array(
+ 'post_ids' => array( 881, 882 ),
+ ),
+
+ )
+) );
+
+class WPCOM_JSON_API_Bulk_Restore_Post_Endpoint extends WPCOM_JSON_API_Update_Post_v1_1_Endpoint {
+ // /sites/%s/posts/restore
+ // The unused $object parameter is for making the method signature compatible with its parent class method.
+ function callback( $path = '', $blog_id = 0, $object = null ) {
+ $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;
+ }
+
+ $input = $this->input();
+
+ if ( is_array( $input['post_ids'] ) ) {
+ $post_ids = (array) $input['post_ids'];
+ } else if ( ! empty( $input['post_ids'] ) ) {
+ $post_ids = explode( ',', $input['post_ids'] );
+ } else {
+ $post_ids = array();
+ }
+
+ if ( count( $post_ids ) < 1 ) {
+ return new WP_Error( 'empty_post_ids', 'The request must include post_ids' );
+ }
+
+ $result = array(
+ 'results' => array(),
+ );
+
+ foreach( $post_ids as $post_id ) {
+ $result['results'][ $post_id ] = $this->restore_post( $path, $blog_id, $post_id );
+ }
+
+ return $result;
+ }
+}