Code Duplication    Length = 20-20 lines in 2 locations

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

@@ 223-242 (lines=20) @@
220
			return new WP_Error( 'unauthorized', 'User cannot view post', 403 );
221
		}
222
223
		if (
224
			-1 == get_option( 'blog_public' ) &&
225
			/**
226
			 * Filter access to a specific post.
227
			 *
228
			 * @module json-api
229
			 *
230
			 * @since 3.4.0
231
			 *
232
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
233
			 * @param WP_Post $post Post data.
234
			 */
235
			! apply_filters(
236
				'wpcom_json_api_user_can_view_post',
237
				current_user_can( 'read_post', $post->ID ),
238
				$post
239
			)
240
		) {
241
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
242
		}
243
244
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
245
			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

@@ 990-1009 (lines=20) @@
987
			}
988
		}
989
990
		if (
991
			-1 == get_option( 'blog_public' ) &&
992
			/**
993
			 * Filter access to a specific post.
994
			 *
995
			 * @module json-api
996
			 *
997
			 * @since 3.4.0
998
			 *
999
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
1000
			 * @param WP_Post $post Post data.
1001
			 */
1002
			! apply_filters(
1003
				'wpcom_json_api_user_can_view_post',
1004
				current_user_can( 'read_post', $post->ID ),
1005
				$post
1006
			)
1007
		) {
1008
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
1009
		}
1010
1011
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
1012
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );