| @@ 320-339 (lines=20) @@ | ||
| 317 | return new WP_Error( 'unauthorized', 'User cannot view post', 403 ); |
|
| 318 | } |
|
| 319 | ||
| 320 | if ( |
|
| 321 | -1 == get_option( 'blog_public' ) && |
|
| 322 | /** |
|
| 323 | * Filter access to a specific post. |
|
| 324 | * |
|
| 325 | * @module json-api |
|
| 326 | * |
|
| 327 | * @since 3.4.0 |
|
| 328 | * |
|
| 329 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
| 330 | * @param WP_Post $post Post data. |
|
| 331 | */ |
|
| 332 | ! apply_filters( |
|
| 333 | 'wpcom_json_api_user_can_view_post', |
|
| 334 | current_user_can( 'read_post', $post->ID ), |
|
| 335 | $post |
|
| 336 | ) |
|
| 337 | ) { |
|
| 338 | return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
| 339 | } |
|
| 340 | ||
| 341 | if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
|
| 342 | return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |
|
| @@ 1110-1129 (lines=20) @@ | ||
| 1107 | } |
|
| 1108 | } |
|
| 1109 | ||
| 1110 | if ( |
|
| 1111 | -1 == get_option( 'blog_public' ) && |
|
| 1112 | /** |
|
| 1113 | * Filter access to a specific post. |
|
| 1114 | * |
|
| 1115 | * @module json-api |
|
| 1116 | * |
|
| 1117 | * @since 3.4.0 |
|
| 1118 | * |
|
| 1119 | * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
|
| 1120 | * @param WP_Post $post Post data. |
|
| 1121 | */ |
|
| 1122 | ! apply_filters( |
|
| 1123 | 'wpcom_json_api_user_can_view_post', |
|
| 1124 | current_user_can( 'read_post', $post->ID ), |
|
| 1125 | $post |
|
| 1126 | ) |
|
| 1127 | ) { |
|
| 1128 | return new WP_Error( |
|
| 1129 | 'unauthorized', |
|
| 1130 | 'User cannot view post', |
|
| 1131 | array( |
|
| 1132 | 'status_code' => 403, |
|