Code Duplication    Length = 7-7 lines in 3 locations

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

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

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

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

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

@@ 115-121 (lines=7) @@
112
			$input['date'] = date( 'Y-m-d H:i:s', $time_with_offset );
113
		}
114
115
		if ( ! empty( $author_id ) && get_current_user_id() != $author_id ) {
116
			if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
117
				return new WP_Error( 'unauthorized', "User is not allowed to publish others' posts.", 403 );
118
			} elseif ( ! user_can( $author_id, $post_type->cap->edit_posts ) ) {
119
				return new WP_Error( 'unauthorized', 'Assigned author cannot publish post.', 403 );
120
			}
121
		}
122
123
		if ( !is_post_type_hierarchical( $post_type->name ) && 'revision' !== $post_type->name ) {
124
			unset( $input['parent'] );