|
@@ 212-233 (lines=22) @@
|
| 209 |
|
} |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
class Jetpack_JSON_API_Sync_Now_Endpoint extends Jetpack_JSON_API_Sync_Endpoint { |
| 213 |
|
protected function result() { |
| 214 |
|
$args = $this->input(); |
| 215 |
|
|
| 216 |
|
if ( ! isset( $args['queue'] ) ) { |
| 217 |
|
return new WP_Error( 'invalid_queue', 'Queue name is required', 400 ); |
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
if ( ! in_array( $args['queue'], array( 'sync', 'full_sync' ) ) ) { |
| 221 |
|
return new WP_Error( 'invalid_queue', 'Queue name should be sync or full_sync', 400 ); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php'; |
| 225 |
|
|
| 226 |
|
$sender = Jetpack_Sync_Sender::get_instance(); |
| 227 |
|
$response = $sender->do_sync_for_queue( new Jetpack_Sync_Queue( $args['queue'] ) ); |
| 228 |
|
|
| 229 |
|
return array( |
| 230 |
|
'response' => $response |
| 231 |
|
); |
| 232 |
|
} |
| 233 |
|
} |
| 234 |
|
|
| 235 |
|
class Jetpack_JSON_API_Sync_Unlock_Endpoint extends Jetpack_JSON_API_Sync_Endpoint { |
| 236 |
|
protected function result() { |
|
@@ 235-261 (lines=27) @@
|
| 232 |
|
} |
| 233 |
|
} |
| 234 |
|
|
| 235 |
|
class Jetpack_JSON_API_Sync_Unlock_Endpoint extends Jetpack_JSON_API_Sync_Endpoint { |
| 236 |
|
protected function result() { |
| 237 |
|
$args = $this->input(); |
| 238 |
|
|
| 239 |
|
if ( ! isset( $args['queue'] ) ) { |
| 240 |
|
return new WP_Error( 'invalid_queue', 'Queue name is required', 400 ); |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
if ( ! in_array( $args['queue'], array( 'sync', 'full_sync' ) ) ) { |
| 244 |
|
return new WP_Error( 'invalid_queue', 'Queue name should be sync or full_sync', 400 ); |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-queue.php'; |
| 248 |
|
$queue = new Jetpack_Sync_Queue( $args['queue'] ); |
| 249 |
|
|
| 250 |
|
// If false it means that there was no lock to delete. |
| 251 |
|
$response = $queue->unlock(); |
| 252 |
|
|
| 253 |
|
if ( is_wp_error( $response ) ) { |
| 254 |
|
return $response; |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
return array( |
| 258 |
|
'success' => $response |
| 259 |
|
); |
| 260 |
|
} |
| 261 |
|
} |
| 262 |
|
|