Code Duplication    Length = 20-20 lines in 2 locations

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

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

@@ 1003-1022 (lines=20) @@
1000
			}
1001
		}
1002
1003
		if (
1004
			-1 == get_option( 'blog_public' ) &&
1005
			/**
1006
			 * Filter access to a specific post.
1007
			 *
1008
			 * @module json-api
1009
			 *
1010
			 * @since 3.4.0
1011
			 *
1012
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
1013
			 * @param WP_Post $post Post data.
1014
			 */
1015
			! apply_filters(
1016
				'wpcom_json_api_user_can_view_post',
1017
				current_user_can( 'read_post', $post->ID ),
1018
				$post
1019
			)
1020
		) {
1021
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
1022
		}
1023
1024
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
1025
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );