| @@ 22-28 (lines=7) @@ | ||
| 19 | $response = Jetpack_Client::wpcom_json_api_request_as_blog( $request, '1.1' ); |
|
| 20 | ||
| 21 | // Bail if there was an error or malformed response |
|
| 22 | if ( is_wp_error( $response ) || ! is_array( $response ) || ! isset( $response['body'] ) ) { |
|
| 23 | return new WP_Error( |
|
| 24 | 'failed_to_fetch_data', |
|
| 25 | esc_html__( 'Unable to fetch the requested data.', 'jetpack' ), |
|
| 26 | array( 'status' => 500 ) |
|
| 27 | ); |
|
| 28 | } |
|
| 29 | ||
| 30 | // Decode the results |
|
| 31 | $results = json_decode( $response['body'], true ); |
|
| @@ 2449-2451 (lines=3) @@ | ||
| 2446 | * @return bool|WP_Error |
|
| 2447 | */ |
|
| 2448 | public static function validate_services( $value, $request, $param ) { |
|
| 2449 | if ( ! is_array( $value ) || ! isset( $value['visible'] ) || ! isset( $value['hidden'] ) ) { |
|
| 2450 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with visible and hidden items.', 'jetpack' ), $param ) ); |
|
| 2451 | } |
|
| 2452 | ||
| 2453 | // Allow to clear everything. |
|
| 2454 | if ( empty( $value['visible'] ) && empty( $value['hidden'] ) ) { |
|
| @@ 2489-2491 (lines=3) @@ | ||
| 2486 | * @return bool|WP_Error |
|
| 2487 | */ |
|
| 2488 | public static function validate_custom_service( $value, $request, $param ) { |
|
| 2489 | if ( ! is_array( $value ) || ! isset( $value['sharing_name'] ) || ! isset( $value['sharing_url'] ) || ! isset( $value['sharing_icon'] ) ) { |
|
| 2490 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with sharing name, url and icon.', 'jetpack' ), $param ) ); |
|
| 2491 | } |
|
| 2492 | ||
| 2493 | // Allow to clear everything. |
|
| 2494 | if ( empty( $value['sharing_name'] ) && empty( $value['sharing_url'] ) && empty( $value['sharing_icon'] ) ) { |
|