Code Duplication    Length = 13-13 lines in 3 locations

json-endpoints/class.wpcom-json-api-update-post-endpoint.php 1 location

@@ 251-263 (lines=13) @@
248
					return $author_id;
249
			}
250
251
			if ( 'publish' === $input['status'] ) {
252
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
253
					if ( current_user_can( $post_type->cap->edit_posts ) ) {
254
						$input['status'] = 'pending';
255
					} else {
256
						return new WP_Error( 'unauthorized', 'User cannot publish posts', 403 );
257
					}
258
				}
259
			} else {
260
				if ( !current_user_can( $post_type->cap->edit_posts ) ) {
261
					return new WP_Error( 'unauthorized', 'User cannot edit posts', 403 );
262
				}
263
			}
264
		} else {
265
			$input = $this->input( false );
266

json-endpoints/class.wpcom-json-api-update-post-v1-1-endpoint.php 1 location

@@ 270-282 (lines=13) @@
267
					return $author_id;
268
			}
269
270
			if ( 'publish' === $input['status'] ) {
271
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
272
					if ( current_user_can( $post_type->cap->edit_posts ) ) {
273
						$input['status'] = 'pending';
274
					} else {
275
						return new WP_Error( 'unauthorized', 'User cannot publish posts', 403 );
276
					}
277
				}
278
			} else {
279
				if ( !current_user_can( $post_type->cap->edit_posts ) ) {
280
					return new WP_Error( 'unauthorized', 'User cannot edit posts', 403 );
281
				}
282
			}
283
		} else {
284
			$input = $this->input( false );
285

json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php 1 location

@@ 214-226 (lines=13) @@
211
					return $author_id;
212
			}
213
214
			if ( 'publish' === $input['status'] ) {
215
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
216
					if ( current_user_can( $post_type->cap->edit_posts ) ) {
217
						$input['status'] = 'pending';
218
					} else {
219
						return new WP_Error( 'unauthorized', 'User cannot publish posts', 403 );
220
					}
221
				}
222
			} else {
223
				if ( !current_user_can( $post_type->cap->edit_posts ) ) {
224
					return new WP_Error( 'unauthorized', 'User cannot edit posts', 403 );
225
				}
226
			}
227
		} else {
228
			$input = $this->input( false );
229