Code Duplication    Length = 5-6 lines in 4 locations

json-endpoints/jetpack/class.jetpack-json-api-plugins-modify-endpoint.php 2 locations

@@ 188-193 (lines=6) @@
185
		$permission_error = false;
186
		foreach ( $this->plugins as $plugin ) {
187
188
			if ( ! $this->current_user_can( 'activate_plugin', $plugin ) ) {
189
				$this->log[ $plugin ]['error'] = __( 'Sorry, you are not allowed to activate this plugin.' );
190
				$has_errors                  = true;
191
				$permission_error            = true;
192
				continue;
193
			}
194
195
			if ( ( ! $this->network_wide && Jetpack::is_plugin_active( $plugin ) ) || is_plugin_active_for_network( $plugin ) ) {
196
				$this->log[ $plugin ]['error'] = __( 'The Plugin is already active.', 'jetpack' );
@@ 253-257 (lines=5) @@
250
	protected function deactivate() {
251
		$permission_error = false;
252
		foreach ( $this->plugins as $plugin ) {
253
			if ( ! $this->current_user_can('deactivate_plugin', $plugin ) ) {
254
				$error = $this->log[ $plugin ]['error'] = __( 'Sorry, you are not allowed to deactivate this plugin.', 'jetpack' );
255
				$permission_error = true;
256
				continue;
257
			}
258
259
			if ( ! Jetpack::is_plugin_active( $plugin ) ) {
260
				$error = $this->log[ $plugin ]['error'] = __( 'The Plugin is already deactivated.', 'jetpack' );

json-endpoints/jetpack/class.jetpack-json-api-plugins-modify-v1-2-endpoint.php 2 locations

@@ 99-104 (lines=6) @@
96
		$has_errors = false;
97
		foreach ( $this->plugins as $plugin ) {
98
99
			if ( ! $this->current_user_can( 'activate_plugin', $plugin ) ) {
100
				$this->log[$plugin]['error'] = __( 'Sorry, you are not allowed to activate this plugin.' );
101
				$has_errors                  = true;
102
				$permission_error            = true;
103
				continue;
104
			}
105
106
			if ( ( ! $this->network_wide && Jetpack::is_plugin_active( $plugin ) ) || is_plugin_active_for_network( $plugin ) ) {
107
				continue;
@@ 150-154 (lines=5) @@
147
	protected function deactivate() {
148
		$permission_error = false;
149
		foreach ( $this->plugins as $plugin ) {
150
			if ( ! $this->current_user_can('deactivate_plugin', $plugin ) ) {
151
				$error = $this->log[ $plugin ]['error'] = __( 'Sorry, you are not allowed to deactivate this plugin.', 'jetpack' );
152
				$permission_error = true;
153
				continue;
154
			}
155
156
			if ( ! Jetpack::is_plugin_active( $plugin ) ) {
157
				continue;