$value ) { array_push($all_post_types, $key); } $tax_query = ''; if ( $_POST['wpr_category'] != false && $_POST['wpr_category'] != '' ) { $tax_query = array( array( 'taxonomy' => $_POST['wpr_option_post_type'], 'field' => 'term_id', 'terms' => sanitize_text_field($_POST['wpr_category']), ), ); // if ( isset($_POST['wpr_option_post_type']) && !empty($_POST['wpr_option_post_type']) ) { // $tax_query = array( // array( // 'taxonomy' => $_POST['wpr_option_post_type'], // 'field' => 'term_id', // 'terms' => sanitize_text_field($_POST['wpr_category']), // ), // ); // } else { // $tax_query = array( // array( // 'taxonomy' => $_POST['wpr_query_type'] == 'product' ? $_POST['wpr_query_type'] . '_cat' : 'category', // 'field' => 'term_id', // 'terms' => sanitize_text_field($_POST['wpr_category']), // ), // ); // } } else if ( $_POST['wpr_category'] == 0 && $_POST['wpr_query_type'] != 'all' ) { if ( !empty($_POST['wpr_option_post_type']) ) { $tax_query = array( array( 'taxonomy' => $_POST['wpr_option_post_type'], 'field' => 'term_id', 'terms' => sanitize_text_field($_POST['wpr_category']), ), ); } else { // Get the string from the POST data $taxonomy_type_string = $_POST['wpr_taxonomy_type']; // Check if the string contains spaces if (strpos($taxonomy_type_string, ' ') !== false) { // Split the string into an array based on spaces $taxonomy_types = explode(' ', $taxonomy_type_string); $tax_query = [ 'relation' => 'OR' ]; foreach( $taxonomy_types as $taxonomy_type ) { array_push($tax_query, [ 'taxonomy' => $taxonomy_type, 'operator' => 'EXISTS' ]); } } else { // If there are no spaces, leave it as a single-item array $taxonomy_types = $taxonomy_type_string; $tax_query = array( array( 'taxonomy' => $_POST['wpr_taxonomy_type'], 'operator' => 'EXISTS', ), ); } } } $can_view_protected_posts = current_user_can('read_private_posts'); if ( ( 'yes' !== sanitize_text_field($_POST['wpr_show_ps_pt'] ) ) || !$can_view_protected_posts ) { $the_query = new \WP_Query( [ 'posts_per_page' => sanitize_text_field($_POST['wpr_number_of_results']), 's' => sanitize_text_field( $_POST['wpr_keyword'] ), 'post_type' => $_POST['wpr_query_type'] === 'all' || (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ? $all_post_types : array( sanitize_text_field($_POST['wpr_query_type']) ), 'offset' => sanitize_text_field($_POST['wpr_search_results_offset']), 'meta_query' => 'yes' === sanitize_text_field($_POST['wpr_exclude_without_thumb']) ? [ ['key' => '_thumbnail_id'] ] : '', 'tax_query' => $tax_query, 'post_status' => in_array('attachment', $all_post_types) ? ['publish', 'inherit'] : 'publish', 'post_password' => '' ] ); } else { $the_query = new \WP_Query( [ 'posts_per_page' => sanitize_text_field($_POST['wpr_number_of_results']), 's' => sanitize_text_field( $_POST['wpr_keyword'] ), 'post_type' => $_POST['wpr_query_type'] === 'all' || (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ? $all_post_types : array( sanitize_text_field($_POST['wpr_query_type']) ), 'offset' => sanitize_text_field($_POST['wpr_search_results_offset']), 'meta_query' => 'yes' === sanitize_text_field($_POST['wpr_exclude_without_thumb']) ? [ ['key' => '_thumbnail_id'] ] : '', 'tax_query' => $tax_query, 'post_status' => in_array('attachment', $all_post_types) ? ['publish', 'inherit'] : 'publish', ] ); } if( $the_query->have_posts() ) : $number_of_queried_posts = $the_query->found_posts; $post_count = 0; while( $the_query->have_posts() ) : $the_query->the_post(); // if ( ( !has_post_thumbnail() && 'yes' === sanitize_text_field($_POST['wpr_exclude_without_thumb'])) ) : // continue; // endif; ob_start(); // the_post_thumbnail(sanitize_text_field($_POST['ajax_search_img_size'])); the_post_thumbnail('medium'); $post_thumb = ob_get_clean(); ?>
  • found_posts ?>> '. $post_thumb .''; // echo ''. '' .''; else : echo ''; endif ; endif ; ?>

    '. $product->get_price_html() .'
    '; echo $price_html; } endif; ?> '; endif ; ?>
  • '. sanitize_text_field($_POST['wpr_no_results']) .'

    '; } endif; die(); } } new WPR_Ajax_Search();