Jetpack_JSON_API_Sync_Close_Endpoint

The WordPress Core Jetpack JSON API Sync Close Endpoint class.

Defined (1)

The class is defined in the following location(s).

/json-endpoints/jetpack/class.jetpack-json-api-sync-endpoint.php  
  1. class Jetpack_JSON_API_Sync_Close_Endpoint extends Jetpack_JSON_API_Sync_Endpoint { 
  2. protected function result() { 
  3. $request_body = $this->input(); 
  4. $queue_name = $this->validate_queue( $request_body['queue'] ); 
  5.  
  6. if ( is_wp_error( $queue_name ) ) { 
  7. return $queue_name; 
  8. require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-queue.php'; 
  9.  
  10. if ( ! isset( $request_body['buffer_id'] ) ) { 
  11. return new WP_Error( 'missing_buffer_id', 'Please provide a buffer id', 400 ); 
  12.  
  13. if ( ! isset( $request_body['item_ids'] ) || ! is_array( $request_body['item_ids'] ) ) { 
  14. return new WP_Error( 'missing_item_ids', 'Please provide a list of item ids in the item_ids argument', 400 ); 
  15.  
  16. //Limit to A-Z, a-z, 0-9, _, - 
  17. $request_body ['buffer_id'] = preg_replace( '/[^A-Za-z0-9]/', '', $request_body['buffer_id'] ); 
  18. $request_body['item_ids'] = array_filter( array_map( array( 'Jetpack_JSON_API_Sync_Close_Endpoint', 'sanitize_item_ids' ), $request_body['item_ids'] ) ); 
  19.  
  20. $buffer = new Jetpack_Sync_Queue_Buffer( $request_body['buffer_id'], $request_body['item_ids'] ); 
  21. $queue = new Jetpack_Sync_Queue( $queue_name ); 
  22.  
  23. $response = $queue->close( $buffer, $request_body['item_ids'] ); 
  24.  
  25. if ( is_wp_error( $response ) ) { 
  26. return $response; 
  27.  
  28. return array( 
  29. 'success' => $response 
  30. ); 
  31.  
  32. protected static function sanitize_item_ids( $item ) { 
  33. // lets not delete any options that don't start with jpsq_sync- 
  34. if ( substr( $item, 0, 5 ) !== 'jpsq_' ) { 
  35. return null; 
  36. //Limit to A-Z, a-z, 0-9, _, -, . 
  37. return preg_replace( '/[^A-Za-z0-9-_.]/', '', $item );