Code Duplication    Length = 7-7 lines in 3 locations

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

@@ 139-145 (lines=7) @@
136
			$input['date'] = date( 'Y-m-d H:i:s', $time_with_offset );
137
		}
138
139
		if ( ! empty( $author_id ) && get_current_user_id() != $author_id ) {
140
			if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
141
				return new WP_Error( 'unauthorized', "User is not allowed to publish others' posts.", 403 );
142
			} elseif ( ! user_can( $author_id, $post_type->cap->edit_posts ) ) {
143
				return new WP_Error( 'unauthorized', 'Assigned author cannot publish post.', 403 );
144
			}
145
		}
146
147
		if ( !is_post_type_hierarchical( $post_type->name ) && 'revision' !== $post_type->name ) {
148
			unset( $input['parent'] );

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

@@ 156-162 (lines=7) @@
153
			$input['date'] = date( 'Y-m-d H:i:s', $time_with_offset );
154
		}
155
156
		if ( ! empty( $author_id ) && get_current_user_id() != $author_id ) {
157
			if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
158
				return new WP_Error( 'unauthorized', "User is not allowed to publish others' posts.", 403 );
159
			} elseif ( ! user_can( $author_id, $post_type->cap->edit_posts ) ) {
160
				return new WP_Error( 'unauthorized', 'Assigned author cannot publish post.', 403 );
161
			}
162
		}
163
164
		if ( !is_post_type_hierarchical( $post_type->name ) && 'revision' !== $post_type->name ) {
165
			unset( $input['parent'] );

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

@@ 130-136 (lines=7) @@
127
			$input['date'] = date( 'Y-m-d H:i:s', $time_with_offset );
128
		}
129
130
		if ( ! empty( $author_id ) && get_current_user_id() != $author_id ) {
131
			if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
132
				return new WP_Error( 'unauthorized', "User is not allowed to publish others' posts.", 403 );
133
			} elseif ( ! user_can( $author_id, $post_type->cap->edit_posts ) ) {
134
				return new WP_Error( 'unauthorized', 'Assigned author cannot publish post.', 403 );
135
			}
136
		}
137
138
		if ( !is_post_type_hierarchical( $post_type->name ) && 'revision' !== $post_type->name ) {
139
			unset( $input['parent'] );