Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 660-672 (lines=13) @@
657
	 *
658
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
659
	 */
660
	public static function disconnect_site( $request ) {
661
662
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
663
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
664
		}
665
666
		if ( Jetpack::is_active() ) {
667
			Jetpack::disconnect();
668
			return rest_ensure_response( array( 'code' => 'success' ) );
669
		}
670
671
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
672
	}
673
674
	/**
675
	 * Gets a new connect raw URL with fresh nonce.
@@ 780-795 (lines=16) @@
777
	 *
778
	 * @return bool|WP_Error True if user successfully unlinked.
779
	 */
780
	public static function unlink_user( $request ) {
781
782
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
783
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
784
		}
785
786
		if ( Jetpack::unlink_user() ) {
787
			return rest_ensure_response(
788
				array(
789
					'code' => 'success'
790
				)
791
			);
792
		}
793
794
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
795
	}
796
797
	/**
798
	 * Fetch site data from .com including the site's current plan.