Code Duplication    Length = 20-20 lines in 2 locations

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

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

class.json-api-endpoints.php 1 location

@@ 1078-1097 (lines=20) @@
1075
			}
1076
		}
1077
1078
		if (
1079
			-1 == get_option( 'blog_public' ) &&
1080
			/**
1081
			 * Filter access to a specific post.
1082
			 *
1083
			 * @module json-api
1084
			 *
1085
			 * @since 3.4.0
1086
			 *
1087
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
1088
			 * @param WP_Post $post Post data.
1089
			 */
1090
			! apply_filters(
1091
				'wpcom_json_api_user_can_view_post',
1092
				current_user_can( 'read_post', $post->ID ),
1093
				$post
1094
			)
1095
		) {
1096
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
1097
		}
1098
1099
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
1100
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );