Code Duplication    Length = 20-20 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1093-1112 (lines=20) @@
1090
			}
1091
		}
1092
1093
		if (
1094
			-1 == get_option( 'blog_public' ) &&
1095
			/**
1096
			 * Filter access to a specific post.
1097
			 *
1098
			 * @module json-api
1099
			 *
1100
			 * @since 3.4.0
1101
			 *
1102
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
1103
			 * @param WP_Post $post Post data.
1104
			 */
1105
			! apply_filters(
1106
				'wpcom_json_api_user_can_view_post',
1107
				current_user_can( 'read_post', $post->ID ),
1108
				$post
1109
			)
1110
		) {
1111
			return new WP_Error(
1112
				'unauthorized',
1113
				'User cannot view post',
1114
				array(
1115
					'status_code' => 403,

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

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