Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 541-553 (lines=13) @@
538
	 *
539
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
540
	 */
541
	public static function disconnect_site( $request ) {
542
543
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
544
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
545
		}
546
547
		if ( Jetpack::is_active() ) {
548
			Jetpack::disconnect();
549
			return rest_ensure_response( array( 'code' => 'success' ) );
550
		}
551
552
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
553
	}
554
555
	/**
556
	 * Gets a new connect raw URL with fresh nonce.
@@ 661-676 (lines=16) @@
658
	 *
659
	 * @return bool|WP_Error True if user successfully unlinked.
660
	 */
661
	public static function unlink_user( $request ) {
662
663
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
664
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
665
		}
666
667
		if ( Jetpack::unlink_user() ) {
668
			return rest_ensure_response(
669
				array(
670
					'code' => 'success'
671
				)
672
			);
673
		}
674
675
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
676
	}
677
678
	/**
679
	 * Get site data, including for example, the site's current plan.