Code Duplication    Length = 20-20 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1069-1088 (lines=20) @@
1066
			}
1067
		}
1068
1069
		if (
1070
			-1 == get_option( 'blog_public' ) &&
1071
			/**
1072
			 * Filter access to a specific post.
1073
			 *
1074
			 * @module json-api
1075
			 *
1076
			 * @since 3.4.0
1077
			 *
1078
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
1079
			 * @param WP_Post $post Post data.
1080
			 */
1081
			! apply_filters(
1082
				'wpcom_json_api_user_can_view_post',
1083
				current_user_can( 'read_post', $post->ID ),
1084
				$post
1085
			)
1086
		) {
1087
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
1088
		}
1089
1090
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
1091
			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

@@ 288-307 (lines=20) @@
285
			return new WP_Error( 'unauthorized', 'User cannot view post', 403 );
286
		}
287
288
		if (
289
			-1 == get_option( 'blog_public' ) &&
290
			/**
291
			 * Filter access to a specific post.
292
			 *
293
			 * @module json-api
294
			 *
295
			 * @since 3.4.0
296
			 *
297
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
298
			 * @param WP_Post $post Post data.
299
			 */
300
			! apply_filters(
301
				'wpcom_json_api_user_can_view_post',
302
				current_user_can( 'read_post', $post->ID ),
303
				$post
304
			)
305
		) {
306
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
307
		}
308
309
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
310
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );