Code Duplication    Length = 3-10 lines in 4 locations

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

@@ 228-237 (lines=10) @@
225
	 */
226
	public static function activate_modules( $request ) {
227
228
		if (
229
			! isset( $request['modules'] )
230
			|| ! is_array( $request['modules'] )
231
		) {
232
			return new WP_Error(
233
				'not_found',
234
				esc_html__( 'The requested Jetpack module was not found.', 'jetpack' ),
235
				array( 'status' => 404 )
236
			);
237
		}
238
239
		$activated = array();
240
		$failed = array();

modules/widgets/class-jetpack-instagram-widget.php 1 location

@@ 231-233 (lines=3) @@
228
		}
229
230
		$data = json_decode( wp_remote_retrieve_body( $result ), true );
231
		if ( ! isset( $data['images'] ) || ! is_array( $data['images'] ) ) {
232
			return new WP_Error( 'missing_images', esc_html__( 'The images were missing', 'jetpack' ), $response_code );
233
		}
234
235
		set_transient( $transient_key, $data, HOUR_IN_SECONDS );
236
		return $data;

_inc/lib/class.core-rest-api-endpoints.php 2 locations

@@ 2965-2967 (lines=3) @@
2962
	 * @return bool|WP_Error
2963
	 */
2964
	public static function validate_services( $value, $request, $param ) {
2965
		if ( ! is_array( $value ) || ! isset( $value['visible'] ) || ! isset( $value['hidden'] ) ) {
2966
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an array with visible and hidden items.', 'jetpack' ), $param ) );
2967
		}
2968
2969
		// Allow to clear everything.
2970
		if ( empty( $value['visible'] ) && empty( $value['hidden'] ) ) {
@@ 3879-3881 (lines=3) @@
3876
	 * @return WP_REST_Response|WP_Error A response object if the extension activation was successful, or a WP_Error object if it failed.
3877
	 */
3878
	public static function activate_crm_jetpack_forms_extension( $request ) {
3879
		if ( ! isset( $request['extension'] ) || 'jetpackforms' !== $request['extension'] ) {
3880
			return new WP_Error( 'invalid_param', esc_html__( 'Missing or invalid extension parameter.', 'jetpack' ), array( 'status' => 404 ) );
3881
		}
3882
3883
		$result = ( new Automattic\Jetpack\Jetpack_CRM_Data() )->activate_crm_jetpackforms_extension();
3884