| @@ 217-236 (lines=20) @@ | ||
| 214 | return new WP_Error( 'unauthorized', 'User cannot view post', 403 ); | |
| 215 | } | |
| 216 | ||
| 217 | if ( | |
| 218 | -1 == get_option( 'blog_public' ) && | |
| 219 | /** | |
| 220 | * Filter access to a specific post. | |
| 221 | * | |
| 222 | * @module json-api | |
| 223 | * | |
| 224 | * @since 3.4.0 | |
| 225 | * | |
| 226 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. | |
| 227 | * @param WP_Post $post Post data. | |
| 228 | */ | |
| 229 | ! apply_filters( | |
| 230 | 'wpcom_json_api_user_can_view_post', | |
| 231 | current_user_can( 'read_post', $post->ID ), | |
| 232 | $post | |
| 233 | ) | |
| 234 | 		) { | |
| 235 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); | |
| 236 | } | |
| 237 | ||
| 238 | 		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { | |
| 239 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); | |
| @@ 977-996 (lines=20) @@ | ||
| 974 | } | |
| 975 | } | |
| 976 | ||
| 977 | if ( | |
| 978 | -1 == get_option( 'blog_public' ) && | |
| 979 | /** | |
| 980 | * Filter access to a specific post. | |
| 981 | * | |
| 982 | * @module json-api | |
| 983 | * | |
| 984 | * @since 3.4.0 | |
| 985 | * | |
| 986 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. | |
| 987 | * @param WP_Post $post Post data. | |
| 988 | */ | |
| 989 | ! apply_filters( | |
| 990 | 'wpcom_json_api_user_can_view_post', | |
| 991 | current_user_can( 'read_post', $post->ID ), | |
| 992 | $post | |
| 993 | ) | |
| 994 | 		) { | |
| 995 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); | |
| 996 | } | |
| 997 | ||
| 998 | 		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { | |
| 999 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); | |