| @@ 254-273 (lines=20) @@ | ||
| 251 | return new WP_Error( 'unauthorized', 'User cannot view post', 403 ); |
|
| 252 | } |
|
| 253 | ||
| 254 | if ( |
|
| 255 | -1 == get_option( 'blog_public' ) && |
|
| 256 | /** |
|
| 257 | * Filter access to a specific post. |
|
| 258 | * |
|
| 259 | * @module json-api |
|
| 260 | * |
|
| 261 | * @since 3.4.0 |
|
| 262 | * |
|
| 263 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
| 264 | * @param WP_Post $post Post data. |
|
| 265 | */ |
|
| 266 | ! apply_filters( |
|
| 267 | 'wpcom_json_api_user_can_view_post', |
|
| 268 | current_user_can( 'read_post', $post->ID ), |
|
| 269 | $post |
|
| 270 | ) |
|
| 271 | ) { |
|
| 272 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
| 273 | } |
|
| 274 | ||
| 275 | if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
|
| 276 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |
|
| @@ 1058-1077 (lines=20) @@ | ||
| 1055 | } |
|
| 1056 | } |
|
| 1057 | ||
| 1058 | if ( |
|
| 1059 | -1 == get_option( 'blog_public' ) && |
|
| 1060 | /** |
|
| 1061 | * Filter access to a specific post. |
|
| 1062 | * |
|
| 1063 | * @module json-api |
|
| 1064 | * |
|
| 1065 | * @since 3.4.0 |
|
| 1066 | * |
|
| 1067 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
| 1068 | * @param WP_Post $post Post data. |
|
| 1069 | */ |
|
| 1070 | ! apply_filters( |
|
| 1071 | 'wpcom_json_api_user_can_view_post', |
|
| 1072 | current_user_can( 'read_post', $post->ID ), |
|
| 1073 | $post |
|
| 1074 | ) |
|
| 1075 | ) { |
|
| 1076 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
| 1077 | } |
|
| 1078 | ||
| 1079 | if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
|
| 1080 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |
|