public static function get_result_search_page() { add_filter('posts_search', array('WC_Predictive_Search_Hook_Filter', 'search_by_title_only'), 500, 2); add_filter('posts_orderby', array('WC_Predictive_Search_Hook_Filter', 'predictive_posts_orderby'), 500, 2); add_filter('posts_request', array('WC_Predictive_Search_Hook_Filter', 'posts_request_unconflict_role_scoper_plugin'), 500, 2); global $wc_predictive_id_excludes; $psp = 1; $row = 10; $search_keyword = ''; $cat_slug = ''; $tag_slug = ''; $extra_parameter = ''; $show_price = false; $show_categories = false; $show_tags = false; if (isset($_REQUEST['psp']) && $_REQUEST['psp'] > 0) { $psp = $_REQUEST['psp']; } if (isset($_REQUEST['row']) && $_REQUEST['row'] > 0) { $row = $_REQUEST['row']; } if (isset($_REQUEST['q']) && trim($_REQUEST['q']) != '') { $search_keyword = $_REQUEST['q']; } $start = $psp * $row; $end = $start + $row; $end_row = $row; if ($search_keyword != '') { $args = array('s' => $search_keyword, 'numberposts' => $row + 1, 'offset' => $start, 'orderby' => 'predictive', 'order' => 'ASC', 'post_type' => 'product', 'post_status' => 'publish', 'exclude' => $wc_predictive_id_excludes['exclude_products'], 'suppress_filters' => FALSE, 'ps_post_type' => 'product'); if ($cat_slug != '') { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat_slug)); $extra_parameter .= '&scat=' . $cat_slug; } elseif ($tag_slug != '') { $args['tax_query'] = array(array('taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => $tag_slug)); $extra_parameter .= '&stag=' . $tag_slug; } $total_args = $args; $total_args['numberposts'] = -1; $total_args['offset'] = 0; //$search_all_products = get_posts($total_args); $search_products = get_posts($args); $html = ''; if ($search_products && count($search_products) > 0) { $html .= '<div class="rs_ajax_search_content">'; $text_lenght = get_option('woocommerce_search_text_lenght'); foreach ($search_products as $product) { $link_detail = get_permalink($product->ID); $avatar = WC_Predictive_Search::woops_get_product_thumbnail($product->ID, 'shop_catalog', 64, 64); $product_price_output = WC_Predictive_Search_Shortcodes::get_product_price($product->ID, $show_price); $product_cats_output = WC_Predictive_Search_Shortcodes::get_product_categories($product->ID, $show_categories); $product_tags_output = WC_Predictive_Search_Shortcodes::get_product_tags($product->ID, $show_tags); $product_description = WC_Predictive_Search::woops_limit_words(strip_tags(WC_Predictive_Search::strip_shortcodes(strip_shortcodes($product->post_content))), $text_lenght, '...'); if (trim($product_description) == '') { $product_description = WC_Predictive_Search::woops_limit_words(strip_tags(WC_Predictive_Search::strip_shortcodes(strip_shortcodes($product->post_excerpt))), $text_lenght, '...'); } $html .= '<div class="rs_result_row"><span class="rs_rs_avatar"><a href="' . $link_detail . '">' . $avatar . '</a></span><div class="rs_content"><a href="' . $link_detail . '"><span class="rs_rs_name">' . stripslashes($product->post_title) . '</span></a>' . $product_price_output . '<div class="rs_rs_description">' . $product_description . '</div>' . $product_cats_output . $product_tags_output . '</div></div>'; $html .= '<div style="clear:both"></div>'; $end_row--; if ($end_row < 1) { break; } } if (count($search_products) <= $row) { $html .= ''; } $html .= '</div>'; } echo $html; } die; }