Code Duplication    Length = 20-20 lines in 2 locations

class.json-api-endpoints.php 1 location

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

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

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