| @@ 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 ); |
|
| @@ 217-226 (lines=10) @@ | ||
| 214 | */ |
|
| 215 | public static function activate_modules( $request ) { |
|
| 216 | ||
| 217 | if ( |
|
| 218 | ! isset( $request['modules'] ) |
|
| 219 | || ! is_array( $request['modules'] ) |
|
| 220 | ) { |
|
| 221 | return new WP_Error( |
|
| 222 | 'not_found', |
|
| 223 | esc_html__( 'The requested Jetpack module was not found.', 'jetpack' ), |
|
| 224 | array( 'status' => 404 ) |
|
| 225 | ); |
|
| 226 | } |
|
| 227 | ||
| 228 | $activated = array(); |
|
| 229 | $failed = array(); |
|
| @@ 2231-2233 (lines=3) @@ | ||
| 2228 | * @return bool|WP_Error |
|
| 2229 | */ |
|
| 2230 | public static function validate_services( $value, $request, $param ) { |
|
| 2231 | if ( ! is_array( $value ) || ! isset( $value['visible'] ) || ! isset( $value['hidden'] ) ) { |
|
| 2232 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with visible and hidden items.', 'jetpack' ), $param ) ); |
|
| 2233 | } |
|
| 2234 | ||
| 2235 | // Allow to clear everything. |
|
| 2236 | if ( empty( $value['visible'] ) && empty( $value['hidden'] ) ) { |
|
| @@ 2271-2273 (lines=3) @@ | ||
| 2268 | * @return bool|WP_Error |
|
| 2269 | */ |
|
| 2270 | public static function validate_custom_service( $value, $request, $param ) { |
|
| 2271 | if ( ! is_array( $value ) || ! isset( $value['sharing_name'] ) || ! isset( $value['sharing_url'] ) || ! isset( $value['sharing_icon'] ) ) { |
|
| 2272 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with sharing name, url and icon.', 'jetpack' ), $param ) ); |
|
| 2273 | } |
|
| 2274 | ||
| 2275 | // Allow to clear everything. |
|
| 2276 | if ( empty( $value['sharing_name'] ) && empty( $value['sharing_url'] ) && empty( $value['sharing_icon'] ) ) { |
|