Code Duplication    Length = 7-8 lines in 4 locations

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

@@ 729-736 (lines=8) @@
726
	 *
727
	 * @return bool|WP_Error True if user is able to disconnect the site.
728
	 */
729
	public static function disconnect_site_permission_callback() {
730
		if ( current_user_can( 'jetpack_disconnect' ) ) {
731
			return true;
732
		}
733
734
		return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
735
736
	}
737
738
	/**
739
	 * Verify that the user can get a connect/link URL
@@ 780-786 (lines=7) @@
777
	 *
778
	 * @return bool|WP_Error True if user is able to change master user.
779
	 */
780
	public static function set_connection_owner_permission_callback() {
781
		if ( current_user_can( 'jetpack_disconnect' ) ) {
782
			return true;
783
		}
784
785
		return new WP_Error( 'invalid_user_permission_set_connection_owner', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
786
	}
787
788
	/**
789
	 * Verify that a user can use the /connection/user endpoint. Has to be a registered user and be currently linked.
@@ 857-863 (lines=7) @@
854
	 *
855
	 * @return bool Whether user has capability 'jetpack_disconnect'.
856
	 */
857
	public static function identity_crisis_mitigation_permission_check() {
858
		if ( current_user_can( 'jetpack_disconnect' ) ) {
859
			return true;
860
		}
861
862
		return new WP_Error( 'invalid_user_permission_identity_crisis', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
863
	}
864
865
	/**
866
	 * Verify that user can update Jetpack general settings.
@@ 745-752 (lines=8) @@
742
	 *
743
	 * @return bool|WP_Error True if user is able to disconnect the site.
744
	 */
745
	public static function connect_url_permission_callback() {
746
		if ( current_user_can( 'jetpack_connect_user' ) ) {
747
			return true;
748
		}
749
750
		return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
751
752
	}
753
754
	/**
755
	 * Verify that a user can get the data about the current user.