Code Duplication    Length = 13-13 lines in 3 locations

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

@@ 72-84 (lines=13) @@
69
					return $author_id;
70
			}
71
72
			if ( 'publish' === $input['status'] ) {
73
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
74
					if ( current_user_can( $post_type->cap->edit_posts ) ) {
75
						$input['status'] = 'pending';
76
					} else {
77
						return new WP_Error( 'unauthorized', 'User cannot publish posts', 403 );
78
					}
79
				}
80
			} else {
81
				if ( !current_user_can( $post_type->cap->edit_posts ) ) {
82
					return new WP_Error( 'unauthorized', 'User cannot edit posts', 403 );
83
				}
84
			}
85
		} else {
86
			$input = $this->input( false );
87

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

@@ 84-96 (lines=13) @@
81
					return $author_id;
82
			}
83
84
			if ( 'publish' === $input['status'] ) {
85
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
86
					if ( current_user_can( $post_type->cap->edit_posts ) ) {
87
						$input['status'] = 'pending';
88
					} else {
89
						return new WP_Error( 'unauthorized', 'User cannot publish posts', 403 );
90
					}
91
				}
92
			} else {
93
				if ( !current_user_can( $post_type->cap->edit_posts ) ) {
94
					return new WP_Error( 'unauthorized', 'User cannot edit posts', 403 );
95
				}
96
			}
97
		} else {
98
			$input = $this->input( false );
99

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

@@ 58-70 (lines=13) @@
55
					return $author_id;
56
			}
57
58
			if ( 'publish' === $input['status'] ) {
59
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
60
					if ( current_user_can( $post_type->cap->edit_posts ) ) {
61
						$input['status'] = 'pending';
62
					} else {
63
						return new WP_Error( 'unauthorized', 'User cannot publish posts', 403 );
64
					}
65
				}
66
			} else {
67
				if ( !current_user_can( $post_type->cap->edit_posts ) ) {
68
					return new WP_Error( 'unauthorized', 'User cannot edit posts', 403 );
69
				}
70
			}
71
		} else {
72
			$input = $this->input( false );
73