Code Duplication    Length = 20-20 lines in 2 locations

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

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

@@ 1052-1071 (lines=20) @@
1049
			}
1050
		}
1051
1052
		if (
1053
			-1 == get_option( 'blog_public' ) &&
1054
			/**
1055
			 * Filter access to a specific post.
1056
			 *
1057
			 * @module json-api
1058
			 *
1059
			 * @since 3.4.0
1060
			 *
1061
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
1062
			 * @param WP_Post $post Post data.
1063
			 */
1064
			! apply_filters(
1065
				'wpcom_json_api_user_can_view_post',
1066
				current_user_can( 'read_post', $post->ID ),
1067
				$post
1068
			)
1069
		) {
1070
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
1071
		}
1072
1073
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
1074
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );