@@ 1011-1030 (lines=20) @@ | ||
1008 | } |
|
1009 | } |
|
1010 | ||
1011 | if ( |
|
1012 | -1 == get_option( 'blog_public' ) && |
|
1013 | /** |
|
1014 | * Filter access to a specific post. |
|
1015 | * |
|
1016 | * @module json-api |
|
1017 | * |
|
1018 | * @since 3.4.0 |
|
1019 | * |
|
1020 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
1021 | * @param WP_Post $post Post data. |
|
1022 | */ |
|
1023 | ! apply_filters( |
|
1024 | 'wpcom_json_api_user_can_view_post', |
|
1025 | current_user_can( 'read_post', $post->ID ), |
|
1026 | $post |
|
1027 | ) |
|
1028 | ) { |
|
1029 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
1030 | } |
|
1031 | ||
1032 | if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
|
1033 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |
@@ 248-267 (lines=20) @@ | ||
245 | return new WP_Error( 'unauthorized', 'User cannot view post', 403 ); |
|
246 | } |
|
247 | ||
248 | if ( |
|
249 | -1 == get_option( 'blog_public' ) && |
|
250 | /** |
|
251 | * Filter access to a specific post. |
|
252 | * |
|
253 | * @module json-api |
|
254 | * |
|
255 | * @since 3.4.0 |
|
256 | * |
|
257 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
258 | * @param WP_Post $post Post data. |
|
259 | */ |
|
260 | ! apply_filters( |
|
261 | 'wpcom_json_api_user_can_view_post', |
|
262 | current_user_can( 'read_post', $post->ID ), |
|
263 | $post |
|
264 | ) |
|
265 | ) { |
|
266 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
267 | } |
|
268 | ||
269 | if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
|
270 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |