| @@ 25-31 (lines=7) @@ | ||
| 22 | $response = Client::wpcom_json_api_request_as_blog( $request, '1.1' ); |
|
| 23 | ||
| 24 | // Bail if there was an error or malformed response |
|
| 25 | if ( is_wp_error( $response ) || ! is_array( $response ) || ! isset( $response['body'] ) ) { |
|
| 26 | return new WP_Error( |
|
| 27 | 'failed_to_fetch_data', |
|
| 28 | esc_html__( 'Unable to fetch the requested data.', 'jetpack' ), |
|
| 29 | array( 'status' => 500 ) |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | ||
| 33 | // Decode the results |
|
| 34 | $results = json_decode( $response['body'], true ); |
|
| @@ 2421-2423 (lines=3) @@ | ||
| 2418 | * @return bool|WP_Error |
|
| 2419 | */ |
|
| 2420 | public static function validate_services( $value, $request, $param ) { |
|
| 2421 | if ( ! is_array( $value ) || ! isset( $value['visible'] ) || ! isset( $value['hidden'] ) ) { |
|
| 2422 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with visible and hidden items.', 'jetpack' ), $param ) ); |
|
| 2423 | } |
|
| 2424 | ||
| 2425 | // Allow to clear everything. |
|
| 2426 | if ( empty( $value['visible'] ) && empty( $value['hidden'] ) ) { |
|
| @@ 2461-2463 (lines=3) @@ | ||
| 2458 | * @return bool|WP_Error |
|
| 2459 | */ |
|
| 2460 | public static function validate_custom_service( $value, $request, $param ) { |
|
| 2461 | if ( ! is_array( $value ) || ! isset( $value['sharing_name'] ) || ! isset( $value['sharing_url'] ) || ! isset( $value['sharing_icon'] ) ) { |
|
| 2462 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with sharing name, url and icon.', 'jetpack' ), $param ) ); |
|
| 2463 | } |
|
| 2464 | ||
| 2465 | // Allow to clear everything. |
|
| 2466 | if ( empty( $value['sharing_name'] ) && empty( $value['sharing_url'] ) && empty( $value['sharing_icon'] ) ) { |
|