| @@ 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 ); |
|
| @@ 225-234 (lines=10) @@ | ||
| 222 | */ |
|
| 223 | public static function activate_modules( $request ) { |
|
| 224 | ||
| 225 | if ( |
|
| 226 | ! isset( $request['modules'] ) |
|
| 227 | || ! is_array( $request['modules'] ) |
|
| 228 | ) { |
|
| 229 | return new WP_Error( |
|
| 230 | 'not_found', |
|
| 231 | esc_html__( 'The requested Jetpack module was not found.', 'jetpack' ), |
|
| 232 | array( 'status' => 404 ) |
|
| 233 | ); |
|
| 234 | } |
|
| 235 | ||
| 236 | $activated = array(); |
|
| 237 | $failed = array(); |
|
| @@ 2261-2263 (lines=3) @@ | ||
| 2258 | * @return bool|WP_Error |
|
| 2259 | */ |
|
| 2260 | public static function validate_services( $value, $request, $param ) { |
|
| 2261 | if ( ! is_array( $value ) || ! isset( $value['visible'] ) || ! isset( $value['hidden'] ) ) { |
|
| 2262 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with visible and hidden items.', 'jetpack' ), $param ) ); |
|
| 2263 | } |
|
| 2264 | ||
| 2265 | // Allow to clear everything. |
|
| 2266 | if ( empty( $value['visible'] ) && empty( $value['hidden'] ) ) { |
|
| @@ 2301-2303 (lines=3) @@ | ||
| 2298 | * @return bool|WP_Error |
|
| 2299 | */ |
|
| 2300 | public static function validate_custom_service( $value, $request, $param ) { |
|
| 2301 | if ( ! is_array( $value ) || ! isset( $value['sharing_name'] ) || ! isset( $value['sharing_url'] ) || ! isset( $value['sharing_icon'] ) ) { |
|
| 2302 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with sharing name, url and icon.', 'jetpack' ), $param ) ); |
|
| 2303 | } |
|
| 2304 | ||
| 2305 | // Allow to clear everything. |
|
| 2306 | if ( empty( $value['sharing_name'] ) && empty( $value['sharing_url'] ) && empty( $value['sharing_icon'] ) ) { |
|