|
@@ 1253-1278 (lines=26) @@
|
| 1250 |
|
* |
| 1251 |
|
* @return array Array of rewind properties. |
| 1252 |
|
*/ |
| 1253 |
|
public static function get_rewind_data() { |
| 1254 |
|
$rewind_data = self::rewind_data(); |
| 1255 |
|
|
| 1256 |
|
if ( ! is_wp_error( $rewind_data ) ) { |
| 1257 |
|
return rest_ensure_response( array( |
| 1258 |
|
'code' => 'success', |
| 1259 |
|
'message' => esc_html__( 'Backup & Scan data correctly received.', 'jetpack' ), |
| 1260 |
|
'data' => wp_json_encode( $rewind_data ), |
| 1261 |
|
) |
| 1262 |
|
); |
| 1263 |
|
} |
| 1264 |
|
|
| 1265 |
|
if ( $rewind_data->get_error_code() === 'rewind_data_fetch_failed' ) { |
| 1266 |
|
return new WP_Error( 'rewind_data_fetch_failed', esc_html__( 'Failed fetching rewind data. Try again later.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1267 |
|
} |
| 1268 |
|
|
| 1269 |
|
if ( $rewind_data->get_error_code() === 'site_id_missing' ) { |
| 1270 |
|
return new WP_Error( 'site_id_missing', esc_html__( 'The ID of this site does not exist.', 'jetpack' ), array( 'status' => 404 ) ); |
| 1271 |
|
} |
| 1272 |
|
|
| 1273 |
|
return new WP_Error( |
| 1274 |
|
'error_get_rewind_data', |
| 1275 |
|
esc_html__( 'Could not retrieve Backup & Scan data.', 'jetpack' ), |
| 1276 |
|
array( 'status' => 500 ) |
| 1277 |
|
); |
| 1278 |
|
} |
| 1279 |
|
|
| 1280 |
|
/** |
| 1281 |
|
* Gets Scan state data. |
|
@@ 1312-1338 (lines=27) @@
|
| 1309 |
|
* |
| 1310 |
|
* @return WP_REST_Response|WP_Error REST response or error state. |
| 1311 |
|
*/ |
| 1312 |
|
public static function get_scan_state() { |
| 1313 |
|
$scan_state = self::scan_state(); |
| 1314 |
|
|
| 1315 |
|
if ( ! is_wp_error( $scan_state ) ) { |
| 1316 |
|
return rest_ensure_response( |
| 1317 |
|
array( |
| 1318 |
|
'code' => 'success', |
| 1319 |
|
'message' => esc_html__( 'Scan state correctly received.', 'jetpack' ), |
| 1320 |
|
'data' => wp_json_encode( $scan_state ), |
| 1321 |
|
) |
| 1322 |
|
); |
| 1323 |
|
} |
| 1324 |
|
|
| 1325 |
|
if ( $scan_state->get_error_code() === 'scan_state_fetch_failed' ) { |
| 1326 |
|
return new WP_Error( 'scan_state_fetch_failed', esc_html__( 'Failed fetching rewind data. Try again later.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1327 |
|
} |
| 1328 |
|
|
| 1329 |
|
if ( $scan_state->get_error_code() === 'site_id_missing' ) { |
| 1330 |
|
return new WP_Error( 'site_id_missing', esc_html__( 'The ID of this site does not exist.', 'jetpack' ), array( 'status' => 404 ) ); |
| 1331 |
|
} |
| 1332 |
|
|
| 1333 |
|
return new WP_Error( |
| 1334 |
|
'error_get_rewind_data', |
| 1335 |
|
esc_html__( 'Could not retrieve Scan state.', 'jetpack' ), |
| 1336 |
|
array( 'status' => 500 ) |
| 1337 |
|
); |
| 1338 |
|
} |
| 1339 |
|
|
| 1340 |
|
/** |
| 1341 |
|
* Disconnects Jetpack from the WordPress.com Servers |