function woo_ps_lite_upgrade_plugin()
{
    // Upgrade to 1.0.9
    if (version_compare(get_option('wc_predictive_search_lite_version'), '2.0') === -1) {
        WC_Predictive_Search::upgrade_version_2_0();
        update_option('wc_predictive_search_lite_version', '2.0');
    }
    update_option('wc_predictive_search_lite_version', '2.2.10');
}
 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;
 }
 public static function get_result_popup()
 {
     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;
     $row = 6;
     $text_lenght = 100;
     $show_price = 1;
     $search_keyword = '';
     $cat_slug = '';
     $tag_slug = '';
     $extra_parameter = '';
     if (isset($_REQUEST['row']) && $_REQUEST['row'] > 0) {
         $row = stripslashes(strip_tags($_REQUEST['row']));
     }
     if (isset($_REQUEST['text_lenght']) && $_REQUEST['text_lenght'] >= 0) {
         stripslashes(strip_tags($text_lenght = $_REQUEST['text_lenght']));
     }
     if (isset($_REQUEST['show_price']) && trim($_REQUEST['show_price']) != '') {
         $show_price = stripslashes(strip_tags($_REQUEST['show_price']));
     }
     if (isset($_REQUEST['q']) && trim($_REQUEST['q']) != '') {
         $search_keyword = stripslashes(strip_tags($_REQUEST['q']));
     }
     $end_row = $row;
     if ($search_keyword != '') {
         $args = array('s' => $search_keyword, 'numberposts' => $row + 1, 'offset' => 0, '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));
             if (get_option('permalink_structure') == '') {
                 $extra_parameter .= '&scat=' . $cat_slug;
             } else {
                 $extra_parameter .= '/scat/' . $cat_slug;
             }
         } elseif ($tag_slug != '') {
             $args['tax_query'] = array(array('taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => $tag_slug));
             if (get_option('permalink_structure') == '') {
                 $extra_parameter .= '&stag=' . $tag_slug;
             } else {
                 $extra_parameter .= '/stag/' . $tag_slug;
             }
         }
         $total_args = $args;
         $total_args['numberposts'] = -1;
         //$search_all_products = get_posts($total_args);
         $search_products = get_posts($args);
         if ($search_products && count($search_products) > 0) {
             echo "<div class='ajax_search_content_title'>" . __('Products', 'woops') . "</div>[|]#[|]{$search_keyword}\n";
             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_description = WC_Predictive_Search::woops_limit_words(strip_tags(WC_Predictive_Search::strip_shortcodes(strip_shortcodes(str_replace("\n", "", $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(str_replace("\n", "", $product->post_excerpt)))), $text_lenght, '...');
                 }
                 $price_html = '';
                 if ($show_price == 1) {
                     $price_html = WC_Predictive_Search_Shortcodes::get_product_price_dropdown($product->ID);
                 }
                 $item = '<div class="ajax_search_content"><div class="result_row"><a href="' . $link_detail . '"><span class="rs_avatar">' . $avatar . '</span><div class="rs_content_popup"><span class="rs_name">' . stripslashes($product->post_title) . '</span>' . $price_html . '<span class="rs_description">' . $product_description . '</span></div></a></div></div>';
                 echo $item . '[|]' . $link_detail . '[|]' . stripslashes($product->post_title) . "\n";
                 $end_row--;
                 if ($end_row < 1) {
                     break;
                 }
             }
             $rs_item = '';
             if (count($search_products) > $row) {
                 if (get_option('permalink_structure') == '') {
                     $link_search = get_permalink(get_option('woocommerce_search_page_id')) . '&rs=' . urlencode($search_keyword) . $extra_parameter;
                 } else {
                     $link_search = rtrim(get_permalink(get_option('woocommerce_search_page_id')), '/') . '/keyword/' . urlencode($search_keyword) . $extra_parameter;
                 }
                 $rs_item .= '<div class="more_result" rel="more_result"><a href="' . $link_search . '">' . __('See more results for', 'woops') . ' ' . $search_keyword . ' <span class="see_more_arrow"></span></a><span>' . __('Displaying top', 'woops') . ' ' . $row . ' ' . __('results', 'woops') . '</span></div>';
                 echo $rs_item . '[|]' . $link_search . '[|]' . $search_keyword . "\n";
             }
         } else {
             echo '<div class="ajax_no_result">' . __('Nothing found for that name. Try a different spelling or name.', 'woops') . '</div>';
         }
     }
     die;
 }