Code Duplication    Length = 20-20 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 970-989 (lines=20) @@
967
			}
968
		}
969
970
		if (
971
			-1 == get_option( 'blog_public' ) &&
972
			/**
973
			 * Filter access to a specific post.
974
			 *
975
			 * @module json-api
976
			 *
977
			 * @since 3.4.0
978
			 *
979
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
980
			 * @param WP_Post $post Post data.
981
			 */
982
			! apply_filters(
983
				'wpcom_json_api_user_can_view_post',
984
				current_user_can( 'read_post', $post->ID ),
985
				$post
986
			)
987
		) {
988
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
989
		}
990
991
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
992
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );

sal/class.json-api-site-base.php 1 location

@@ 210-229 (lines=20) @@
207
			return new WP_Error( 'unauthorized', 'User cannot view post', 403 );
208
		}
209
210
		if (
211
			-1 == get_option( 'blog_public' ) &&
212
			/**
213
			 * Filter access to a specific post.
214
			 *
215
			 * @module json-api
216
			 *
217
			 * @since 3.4.0
218
			 *
219
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
220
			 * @param WP_Post $post Post data.
221
			 */
222
			! apply_filters(
223
				'wpcom_json_api_user_can_view_post',
224
				current_user_can( 'read_post', $post->ID ),
225
				$post
226
			)
227
		) {
228
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
229
		}
230
231
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
232
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );