Code Duplication    Length = 20-20 lines in 2 locations

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

@@ 246-265 (lines=20) @@
243
			return new WP_Error( 'unauthorized', 'User cannot view post', 403 );
244
		}
245
246
		if (
247
			-1 == get_option( 'blog_public' ) &&
248
			/**
249
			 * Filter access to a specific post.
250
			 *
251
			 * @module json-api
252
			 *
253
			 * @since 3.4.0
254
			 *
255
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
256
			 * @param WP_Post $post Post data.
257
			 */
258
			! apply_filters(
259
				'wpcom_json_api_user_can_view_post',
260
				current_user_can( 'read_post', $post->ID ),
261
				$post
262
			)
263
		) {
264
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
265
		}
266
267
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
268
			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

@@ 1024-1043 (lines=20) @@
1021
			}
1022
		}
1023
1024
		if (
1025
			-1 == get_option( 'blog_public' ) &&
1026
			/**
1027
			 * Filter access to a specific post.
1028
			 *
1029
			 * @module json-api
1030
			 *
1031
			 * @since 3.4.0
1032
			 *
1033
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
1034
			 * @param WP_Post $post Post data.
1035
			 */
1036
			! apply_filters(
1037
				'wpcom_json_api_user_can_view_post',
1038
				current_user_can( 'read_post', $post->ID ),
1039
				$post
1040
			)
1041
		) {
1042
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
1043
		}
1044
1045
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
1046
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );