@@ 371-384 (lines=14) @@ | ||
368 | * |
|
369 | * @return array |
|
370 | */ |
|
371 | public function intercept_refresh_blog_token_request( $response, $args, $url ) { |
|
372 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
373 | return $response; |
|
374 | } |
|
375 | ||
376 | return array( |
|
377 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
378 | 'body' => wp_json_encode( array( 'jetpack_secret' => self::BLOG_TOKEN ) ), |
|
379 | 'response' => array( |
|
380 | 'code' => 200, |
|
381 | 'message' => 'OK', |
|
382 | ), |
|
383 | ); |
|
384 | } |
|
385 | ||
386 | /** |
|
387 | * Intercept the `jetpack-refresh-blog-token` API request sent to WP.com, and mock the failure response. |
|
@@ 395-408 (lines=14) @@ | ||
392 | * |
|
393 | * @return array |
|
394 | */ |
|
395 | public function intercept_refresh_blog_token_request_fail( $response, $args, $url ) { |
|
396 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
397 | return $response; |
|
398 | } |
|
399 | ||
400 | return array( |
|
401 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
402 | 'body' => wp_json_encode( array( 'jetpack_secret_missing' => true ) ), // Meaningless body. |
|
403 | 'response' => array( |
|
404 | 'code' => 200, |
|
405 | 'message' => 'OK', |
|
406 | ), |
|
407 | ); |
|
408 | } |
|
409 | ||
410 | /** |
|
411 | * Intercept the `Jetpack_Options` call to get `blog_id`, and set a random value. |