| 2489 | | // Add public states. |
| 2490 | | $public_states = get_post_stati( array('public' => true) ); |
| 2491 | | foreach ( (array) $public_states as $state ) { |
| 2492 | | if ( 'publish' == $state ) // Publish is hard-coded above. |
| 2493 | | continue; |
| 2494 | | $where .= " OR $wpdb->posts.post_status = '$state'"; |
| 2495 | | } |
| 2496 | | |
| 2497 | | if ( $this->is_admin ) { |
| 2498 | | // Add protected states that should show in the admin all list. |
| 2499 | | $admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) ); |
| 2500 | | foreach ( (array) $admin_all_states as $state ) |
| | 2492 | // Add public states. |
| | 2493 | $public_states = get_post_stati( array('public' => true) ); |
| | 2494 | foreach ( (array) $public_states as $state ) { |
| | 2495 | if ( 'publish' == $state ) // Publish is hard-coded above. |
| | 2496 | continue; |
| 2504 | | if ( is_user_logged_in() ) { |
| 2505 | | // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. |
| 2506 | | $private_states = get_post_stati( array('private' => true) ); |
| 2507 | | foreach ( (array) $private_states as $state ) |
| 2508 | | $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = '$state'"; |
| | 2500 | if ( $this->is_admin ) { |
| | 2501 | // Add protected states that should show in the admin all list. |
| | 2502 | $admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) ); |
| | 2503 | foreach ( (array) $admin_all_states as $state ) |
| | 2504 | $where .= " OR $wpdb->posts.post_status = '$state'"; |
| | 2505 | } |
| | 2506 | |
| | 2507 | if ( is_user_logged_in() ) { |
| | 2508 | // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. |
| | 2509 | $private_states = get_post_stati( array('private' => true) ); |
| | 2510 | foreach ( (array) $private_states as $state ) |
| | 2511 | $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = '$state'"; |
| | 2512 | } |
| | 2513 | |
| | 2514 | $where .= ')'; |