| @@ 274-293 (lines=20) @@ | ||
| 271 | return new WP_Error( 'unauthorized', 'User cannot view post', 403 ); |
|
| 272 | } |
|
| 273 | ||
| 274 | if ( |
|
| 275 | -1 == get_option( 'blog_public' ) && |
|
| 276 | /** |
|
| 277 | * Filter access to a specific post. |
|
| 278 | * |
|
| 279 | * @module json-api |
|
| 280 | * |
|
| 281 | * @since 3.4.0 |
|
| 282 | * |
|
| 283 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
| 284 | * @param WP_Post $post Post data. |
|
| 285 | */ |
|
| 286 | ! apply_filters( |
|
| 287 | 'wpcom_json_api_user_can_view_post', |
|
| 288 | current_user_can( 'read_post', $post->ID ), |
|
| 289 | $post |
|
| 290 | ) |
|
| 291 | ) { |
|
| 292 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
| 293 | } |
|
| 294 | ||
| 295 | if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
|
| 296 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |
|
| @@ 1060-1079 (lines=20) @@ | ||
| 1057 | } |
|
| 1058 | } |
|
| 1059 | ||
| 1060 | if ( |
|
| 1061 | -1 == get_option( 'blog_public' ) && |
|
| 1062 | /** |
|
| 1063 | * Filter access to a specific post. |
|
| 1064 | * |
|
| 1065 | * @module json-api |
|
| 1066 | * |
|
| 1067 | * @since 3.4.0 |
|
| 1068 | * |
|
| 1069 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
| 1070 | * @param WP_Post $post Post data. |
|
| 1071 | */ |
|
| 1072 | ! apply_filters( |
|
| 1073 | 'wpcom_json_api_user_can_view_post', |
|
| 1074 | current_user_can( 'read_post', $post->ID ), |
|
| 1075 | $post |
|
| 1076 | ) |
|
| 1077 | ) { |
|
| 1078 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
| 1079 | } |
|
| 1080 | ||
| 1081 | if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
|
| 1082 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |
|