|
@@ 1195-1211 (lines=17) @@
|
| 1192 |
|
); |
| 1193 |
|
} |
| 1194 |
|
|
| 1195 |
|
public static function rewind_data() { |
| 1196 |
|
$site_id = Jetpack_Options::get_option( 'id' ); |
| 1197 |
|
|
| 1198 |
|
if ( ! $site_id ) { |
| 1199 |
|
return new WP_Error( 'site_id_missing' ); |
| 1200 |
|
} |
| 1201 |
|
|
| 1202 |
|
$response = Client::wpcom_json_api_request_as_blog( sprintf( '/sites/%d/rewind', $site_id ) .'?force=wpcom', '2', array(), null, 'wpcom' ); |
| 1203 |
|
|
| 1204 |
|
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) { |
| 1205 |
|
return new WP_Error( 'rewind_data_fetch_failed' ); |
| 1206 |
|
} |
| 1207 |
|
|
| 1208 |
|
$body = wp_remote_retrieve_body( $response ); |
| 1209 |
|
|
| 1210 |
|
return json_decode( $body ); |
| 1211 |
|
} |
| 1212 |
|
|
| 1213 |
|
/** |
| 1214 |
|
* Get rewind data |
|
@@ 1254-1270 (lines=17) @@
|
| 1251 |
|
* |
| 1252 |
|
* @return array|WP_Error Result from WPCOM API or error. |
| 1253 |
|
*/ |
| 1254 |
|
public static function scan_state() { |
| 1255 |
|
$site_id = Jetpack_Options::get_option( 'id' ); |
| 1256 |
|
|
| 1257 |
|
if ( ! $site_id ) { |
| 1258 |
|
return new WP_Error( 'site_id_missing' ); |
| 1259 |
|
} |
| 1260 |
|
|
| 1261 |
|
$response = Client::wpcom_json_api_request_as_blog( sprintf( '/sites/%d/scan', $site_id ) . '?force=wpcom', '2', array(), null, 'wpcom' ); |
| 1262 |
|
|
| 1263 |
|
if ( wp_remote_retrieve_response_code( $response ) !== 200 ) { |
| 1264 |
|
return new WP_Error( 'scan_state_fetch_failed' ); |
| 1265 |
|
} |
| 1266 |
|
|
| 1267 |
|
$body = wp_remote_retrieve_body( $response ); |
| 1268 |
|
|
| 1269 |
|
return json_decode( $body ); |
| 1270 |
|
} |
| 1271 |
|
|
| 1272 |
|
/** |
| 1273 |
|
* Get Scan state for API. |