| @@ 1119-1138 (lines=20) @@ | ||
| 1116 | } |
|
| 1117 | } |
|
| 1118 | ||
| 1119 | if ( |
|
| 1120 | -1 == get_option( 'blog_public' ) && |
|
| 1121 | /** |
|
| 1122 | * Filter access to a specific post. |
|
| 1123 | * |
|
| 1124 | * @module json-api |
|
| 1125 | * |
|
| 1126 | * @since 3.4.0 |
|
| 1127 | * |
|
| 1128 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
| 1129 | * @param WP_Post $post Post data. |
|
| 1130 | */ |
|
| 1131 | ! apply_filters( |
|
| 1132 | 'wpcom_json_api_user_can_view_post', |
|
| 1133 | current_user_can( 'read_post', $post->ID ), |
|
| 1134 | $post |
|
| 1135 | ) |
|
| 1136 | ) { |
|
| 1137 | return new WP_Error( |
|
| 1138 | 'unauthorized', |
|
| 1139 | 'User cannot view post', |
|
| 1140 | array( |
|
| 1141 | 'status_code' => 403, |
|
| @@ 329-348 (lines=20) @@ | ||
| 326 | return new WP_Error( 'unauthorized', 'User cannot view post', 403 ); |
|
| 327 | } |
|
| 328 | ||
| 329 | if ( |
|
| 330 | -1 == get_option( 'blog_public' ) && |
|
| 331 | /** |
|
| 332 | * Filter access to a specific post. |
|
| 333 | * |
|
| 334 | * @module json-api |
|
| 335 | * |
|
| 336 | * @since 3.4.0 |
|
| 337 | * |
|
| 338 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
| 339 | * @param WP_Post $post Post data. |
|
| 340 | */ |
|
| 341 | ! apply_filters( |
|
| 342 | 'wpcom_json_api_user_can_view_post', |
|
| 343 | current_user_can( 'read_post', $post->ID ), |
|
| 344 | $post |
|
| 345 | ) |
|
| 346 | ) { |
|
| 347 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
| 348 | } |
|
| 349 | ||
| 350 | if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
|
| 351 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |
|