2487 | | if ( 'any' === $post_type ) { |
2488 | | $in_search_post_types = get_post_types( array( 'exclude_from_search' => false ) ); |
2489 | | if ( empty( $in_search_post_types ) ) { |
2490 | | $post_type_where = ' AND 1=0 '; |
2491 | | $skip_post_status = true; |
2492 | | } else { |
2493 | | $post_type_where = " AND {$wpdb->posts}.post_type IN ('" . implode( "', '", array_map( 'esc_sql', $in_search_post_types ) ) . "')"; |
2494 | | } |
2495 | | } elseif ( ! empty( $post_type ) && is_array( $post_type ) ) { |
2496 | | $post_type_where = " AND {$wpdb->posts}.post_type IN ('" . implode( "', '", esc_sql( $post_type ) ) . "')"; |
2497 | | } elseif ( ! empty( $post_type ) ) { |
2498 | | $post_type_where = $wpdb->prepare( " AND {$wpdb->posts}.post_type = %s", $post_type ); |
2499 | | $post_type_object = get_post_type_object( $post_type ); |
2500 | | } elseif ( $this->is_attachment ) { |
2501 | | $post_type_where = " AND {$wpdb->posts}.post_type = 'attachment'"; |
2502 | | $post_type_object = get_post_type_object( 'attachment' ); |
2503 | | } elseif ( $this->is_page ) { |
2504 | | $post_type_where = " AND {$wpdb->posts}.post_type = 'page'"; |
2505 | | $post_type_object = get_post_type_object( 'page' ); |
2506 | | } else { |
2507 | | $post_type_where = " AND {$wpdb->posts}.post_type = 'post'"; |
2508 | | $post_type_object = get_post_type_object( 'post' ); |
2509 | | } |
| 2487 | |
| 2488 | if ( 'all' === $post_type) { |
| 2489 | if (!isset($q['post_status'])) { |
| 2490 | $q['post_status'] = 'publish'; |
| 2491 | } |
| 2492 | } elseif ('any' === $post_type) { |
| 2493 | $in_search_post_types = get_post_types(array('exclude_from_search' => false)); |
| 2494 | if (empty($in_search_post_types)) { |
| 2495 | $post_type_where = ' AND 1=0 '; |
| 2496 | $skip_post_status = true; |
| 2497 | } else { |
| 2498 | $post_type_where = " AND {$wpdb->posts}.post_type IN ('" . implode("', '", array_map('esc_sql', $in_search_post_types)) . "')"; |
| 2499 | } |
| 2500 | } elseif (!empty($post_type) && is_array($post_type)) { |
| 2501 | $post_type_where = " AND {$wpdb->posts}.post_type IN ('" . implode("', '", esc_sql($post_type)) . "')"; |
| 2502 | } elseif (!empty($post_type)) { |
| 2503 | $post_type_where = $wpdb->prepare(" AND {$wpdb->posts}.post_type = %s", $post_type); |
| 2504 | $post_type_object = get_post_type_object($post_type); |
| 2505 | } elseif ($this->is_attachment) { |
| 2506 | $post_type_where = " AND {$wpdb->posts}.post_type = 'attachment'"; |
| 2507 | $post_type_object = get_post_type_object('attachment'); |
| 2508 | } elseif ($this->is_page) { |
| 2509 | $post_type_where = " AND {$wpdb->posts}.post_type = 'page'"; |
| 2510 | $post_type_object = get_post_type_object('page'); |
| 2511 | } else { |
| 2512 | $post_type_where = " AND {$wpdb->posts}.post_type = 'post'"; |
| 2513 | $post_type_object = get_post_type_object('post'); |
| 2514 | } |
2590 | | if ( 'any' === $post_type ) { |
2591 | | $queried_post_types = get_post_types( array( 'exclude_from_search' => false ) ); |
2592 | | } elseif ( is_array( $post_type ) ) { |
2593 | | $queried_post_types = $post_type; |
2594 | | } elseif ( ! empty( $post_type ) ) { |
2595 | | $queried_post_types = array( $post_type ); |
2596 | | } else { |
2597 | | $queried_post_types = array( 'post' ); |
2598 | | } |
| 2595 | if ( 'all' !== $post_type) { |
| 2596 | if ('any' === $post_type) { |
| 2597 | $queried_post_types = get_post_types(array('exclude_from_search' => false)); |
| 2598 | } elseif (is_array($post_type)) { |
| 2599 | $queried_post_types = $post_type; |
| 2600 | } elseif (!empty($post_type)) { |
| 2601 | $queried_post_types = array($post_type); |
| 2602 | } else { |
| 2603 | $queried_post_types = array('post'); |
| 2604 | } |
| 2605 | } |