Code Duplication    Length = 3-10 lines in 3 locations

_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php 1 location

@@ 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();

_inc/lib/core-api/class.jetpack-core-api-site-endpoints.php 1 location

@@ 30-36 (lines=7) @@
27
		$response = Client::wpcom_json_api_request_as_blog( $request, '1.1' );
28
29
		// Bail if there was an error or malformed response.
30
		if ( is_wp_error( $response ) || ! is_array( $response ) || ! isset( $response['body'] ) ) {
31
			return new WP_Error(
32
				'failed_to_fetch_data',
33
				esc_html__( 'Unable to fetch the requested data.', 'jetpack' ),
34
				array( 'status' => 500 )
35
			);
36
		}
37
38
		// Decode the results.
39
		$results = json_decode( $response['body'], true );

_inc/lib/class.core-rest-api-endpoints.php 1 location

@@ 2469-2471 (lines=3) @@
2466
	 * @return bool|WP_Error
2467
	 */
2468
	public static function validate_services( $value, $request, $param ) {
2469
		if ( ! is_array( $value ) || ! isset( $value['visible'] ) || ! isset( $value['hidden'] ) ) {
2470
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with visible and hidden items.', 'jetpack' ), $param ) );
2471
		}
2472
2473
		// Allow to clear everything.
2474
		if ( empty( $value['visible'] ) && empty( $value['hidden'] ) ) {