summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2016-09-11 07:55:30 -0400
committerAnthony G. Basile <blueness@gentoo.org>2016-09-11 07:55:30 -0400
commit665c15ca32b65c69491c564860f89d932ef774ec (patch)
treec65975754c261f1e99cd987e1095b2b27e702d87 /plugins/jetpack/json-endpoints
parentUpdate theme mantra to 2.6.0 (diff)
downloadblogs-gentoo-665c15ca32b65c69491c564860f89d932ef774ec.tar.gz
blogs-gentoo-665c15ca32b65c69491c564860f89d932ef774ec.tar.bz2
blogs-gentoo-665c15ca32b65c69491c564860f89d932ef774ec.zip
Update plugin jetpack to 4.3.1
Diffstat (limited to 'plugins/jetpack/json-endpoints')
-rw-r--r--plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php4
-rw-r--r--plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-sync-endpoint.php66
-rw-r--r--plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-themes-endpoint.php2
-rw-r--r--plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php39
4 files changed, 102 insertions, 9 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php
index 6acef29b..9b8a771a 100644
--- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php
+++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php
@@ -192,6 +192,10 @@ class WPCOM_JSON_API_Update_Post_v1_2_Endpoint extends WPCOM_JSON_API_Update_Pos
* Note: A category named "0" will not work right.
* https://core.trac.wordpress.org/ticket/9059
*/
+ if ( ! is_string( $term ) ) {
+ continue;
+ }
+
$term_info = get_term_by( 'name', $term, $taxonomy, ARRAY_A );
if ( ! $term_info ) {
diff --git a/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-sync-endpoint.php b/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-sync-endpoint.php
index d26ce645..a01947ef 100644
--- a/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-sync-endpoint.php
+++ b/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-sync-endpoint.php
@@ -41,8 +41,8 @@ class Jetpack_JSON_API_Sync_Endpoint extends Jetpack_JSON_API_Endpoint {
// GET /sites/%s/sync/status
class Jetpack_JSON_API_Sync_Status_Endpoint extends Jetpack_JSON_API_Sync_Endpoint {
protected function result() {
- require_once dirname( __FILE__ ) . '/../../sync/class.jetpack-sync-modules.php';
- require_once dirname( __FILE__ ) . '/../../sync/class.jetpack-sync-sender.php';
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-modules.php';
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
$sync_module = Jetpack_Sync_Modules::get_module( 'full-sync' );
$sender = Jetpack_Sync_Sender::get_instance();
@@ -65,7 +65,7 @@ class Jetpack_JSON_API_Sync_Status_Endpoint extends Jetpack_JSON_API_Sync_Endpoi
// GET /sites/%s/data-check
class Jetpack_JSON_API_Sync_Check_Endpoint extends Jetpack_JSON_API_Sync_Endpoint {
protected function result() {
- require_once dirname( __FILE__ ) . '/../../sync/class.jetpack-sync-sender.php';
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
$sender = Jetpack_Sync_Sender::get_instance();
$sync_queue = $sender->get_sync_queue();
@@ -85,7 +85,7 @@ class Jetpack_JSON_API_Sync_Check_Endpoint extends Jetpack_JSON_API_Sync_Endpoin
return $result;
}
- require_once dirname( __FILE__ ) . '/../../sync/class.jetpack-sync-wp-replicastore.php';
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-wp-replicastore.php';
$store = new Jetpack_Sync_WP_Replicastore();
@@ -101,7 +101,7 @@ class Jetpack_JSON_API_Sync_Check_Endpoint extends Jetpack_JSON_API_Sync_Endpoin
// GET /sites/%s/data-histogram
class Jetpack_JSON_API_Sync_Histogram_Endpoint extends Jetpack_JSON_API_Sync_Endpoint {
protected function result() {
- require_once dirname( __FILE__ ) . '/../../sync/class.jetpack-sync-sender.php';
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
$sender = Jetpack_Sync_Sender::get_instance();
$sync_queue = $sender->get_sync_queue();
@@ -129,7 +129,7 @@ class Jetpack_JSON_API_Sync_Histogram_Endpoint extends Jetpack_JSON_API_Sync_End
$columns = null; // go with defaults
}
- require_once dirname( __FILE__ ) . '/../../sync/class.jetpack-sync-wp-replicastore.php';
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-wp-replicastore.php';
$store = new Jetpack_Sync_WP_Replicastore();
@@ -147,7 +147,7 @@ class Jetpack_JSON_API_Sync_Modify_Settings_Endpoint extends Jetpack_JSON_API_Sy
protected function result() {
$args = $this->input();
- require_once dirname( __FILE__ ) . '/../../sync/class.jetpack-sync-settings.php';
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-settings.php';
$sync_settings = Jetpack_Sync_Settings::get_settings();
@@ -176,8 +176,58 @@ class Jetpack_JSON_API_Sync_Modify_Settings_Endpoint extends Jetpack_JSON_API_Sy
// GET /sites/%s/sync/settings
class Jetpack_JSON_API_Sync_Get_Settings_Endpoint extends Jetpack_JSON_API_Sync_Endpoint {
protected function result() {
- require_once dirname( __FILE__ ) . '/../../sync/class.jetpack-sync-settings.php';
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-settings.php';
return Jetpack_Sync_Settings::get_settings();
}
}
+
+// GET /sites/%s/sync/object
+class Jetpack_JSON_API_Sync_Object extends Jetpack_JSON_API_Sync_Endpoint {
+ protected function result() {
+ $args = $this->query_args();
+
+ $module_name = $args['module_name'];
+
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-modules.php';
+
+ if ( ! $sync_module = Jetpack_Sync_Modules::get_module( $module_name ) ) {
+ return new WP_Error( 'invalid_module', 'You specified an invalid sync module' );
+ }
+
+ $object_type = $args['object_type'];
+ $object_ids = $args['object_ids'];
+
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
+ $codec = Jetpack_Sync_Sender::get_instance()->get_codec();
+
+ return array(
+ 'objects' => $codec->encode( $sync_module->get_objects_by_id( $object_type, $object_ids ) )
+ );
+ }
+}
+
+class Jetpack_JSON_API_Sync_Now_Endpoint extends Jetpack_JSON_API_Sync_Endpoint {
+ protected function result() {
+ $args = $this->input();
+
+ if ( ! isset( $args['queue'] ) ) {
+ return new WP_Error( 'invalid_queue', 'Queue name is required', 400 );
+ }
+
+ if ( ! in_array( $args['queue'], array( 'sync', 'full_sync' ) ) ) {
+ return new WP_Error( 'invalid_queue', 'Queue name should be sync or full_sync', 400 );
+ }
+
+ $queue_name = $args['queue'];
+
+ require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
+
+ $sender = Jetpack_Sync_Sender::get_instance();
+ $response = $sender->do_sync_for_queue( new Jetpack_Sync_Queue( $queue_name ) );
+
+ return array(
+ 'response' => $response
+ );
+ }
+}
diff --git a/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-themes-endpoint.php b/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-themes-endpoint.php
index 4e6cf42e..37a20800 100644
--- a/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-themes-endpoint.php
+++ b/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-themes-endpoint.php
@@ -64,7 +64,7 @@ abstract class Jetpack_JSON_API_Themes_Endpoint extends Jetpack_JSON_API_Endpoin
}
if ( is_wp_error( $error = $this->validate_themes() ) ) {
- return error;
+ return $error;
}
return parent::validate_input( $theme );
diff --git a/plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php b/plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php
index 027b730f..c1fb138c 100644
--- a/plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php
+++ b/plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php
@@ -697,6 +697,45 @@ new Jetpack_JSON_API_Sync_Modify_Settings_Endpoint( array(
'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/settings'
) );
+// GET /sites/%s/sync/object
+new Jetpack_JSON_API_Sync_Object( array(
+ 'description' => 'Get an object by ID from one of the sync modules, in the format it would be synced in',
+ 'group' => '__do_not_document',
+ 'method' => 'GET',
+ 'path' => '/sites/%s/sync/object',
+ 'stat' => 'sync-object',
+ 'path_labels' => array(
+ '$site' => '(int|string) The site ID, The site domain'
+ ),
+ 'query_parameters' => array(
+ 'module_name' => '(string) The sync module ID, e.g. "posts"',
+ 'object_type' => '(string) An identified for the object type, e.g. "post"',
+ 'object_ids' => '(array) The IDs of the objects',
+ ),
+ 'response_format' => array(
+ 'objects' => '(string) The encoded objects'
+ ),
+ 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/object?module_name=posts&object_type=post&object_ids[]=1&object_ids[]=2&object_ids[]=3'
+) );
+
+// POST /sites/%s/sync/now
+new Jetpack_JSON_API_Sync_Now_Endpoint( array(
+ 'description' => 'Force immediate sync of top items on a queue',
+ 'method' => 'POST',
+ 'path' => '/sites/%s/sync/now',
+ 'stat' => 'sync-now',
+ 'path_labels' => array(
+ '$site' => '(int|string) The site ID, The site domain'
+ ),
+ 'request_format' => array(
+ 'queue' => '(string) sync or full_sync',
+ ),
+ 'response_format' => array(
+ 'response' => '(array) The response from the server'
+ ),
+ 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.org/sync/now?queue=full_sync'
+) );
+
require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-log-endpoint.php' );
new Jetpack_JSON_API_Jetpack_Log_Endpoint( array(