@@ 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(); |
@@ 2188-2190 (lines=3) @@ | ||
2185 | * @return bool|WP_Error |
|
2186 | */ |
|
2187 | public static function validate_services( $value, $request, $param ) { |
|
2188 | if ( ! is_array( $value ) || ! isset( $value['visible'] ) || ! isset( $value['hidden'] ) ) { |
|
2189 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with visible and hidden items.', 'jetpack' ), $param ) ); |
|
2190 | } |
|
2191 | ||
2192 | // Allow to clear everything. |
|
2193 | if ( empty( $value['visible'] ) && empty( $value['hidden'] ) ) { |
|
@@ 2228-2230 (lines=3) @@ | ||
2225 | * @return bool|WP_Error |
|
2226 | */ |
|
2227 | public static function validate_custom_service( $value, $request, $param ) { |
|
2228 | if ( ! is_array( $value ) || ! isset( $value['sharing_name'] ) || ! isset( $value['sharing_url'] ) || ! isset( $value['sharing_icon'] ) ) { |
|
2229 | return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with sharing name, url and icon.', 'jetpack' ), $param ) ); |
|
2230 | } |
|
2231 | ||
2232 | // Allow to clear everything. |
|
2233 | if ( empty( $value['sharing_name'] ) && empty( $value['sharing_url'] ) && empty( $value['sharing_icon'] ) ) { |