Exemplo n.º 1
0
 protected function post_process()
 {
     $pageposts = is_array($this->results) ? $this->results : array();
     $options = $this->options;
     $searchData = $this->searchData;
     $s = $this->s;
     $_s = $this->_s;
     $performance_options = get_option('asl_performance');
     if (is_multisite()) {
         $home_url = network_home_url();
     } else {
         $home_url = home_url();
     }
     foreach ($pageposts as $k => $v) {
         $r =& $pageposts[$k];
         $r->title = w_isset_def($r->title, null);
         $r->content = w_isset_def($r->content, null);
         $r->image = w_isset_def($r->image, null);
         $r->author = w_isset_def($r->author, null);
         $r->date = w_isset_def($r->date, null);
     }
     /* Images, title, desc */
     foreach ($pageposts as $k => $v) {
         // Let's simplify things
         $r =& $pageposts[$k];
         $r->title = apply_filters('asl_result_title_before_prostproc', $r->title, $r->id);
         $r->content = apply_filters('asl_result_content_before_prostproc', $r->content, $r->id);
         $r->image = apply_filters('asl_result_image_before_prostproc', $r->image, $r->id);
         $r->author = apply_filters('asl_result_author_before_prostproc', $r->author, $r->id);
         $r->date = apply_filters('asl_result_date_before_prostproc', $r->date, $r->id);
         $r->link = get_permalink($v->id);
         $image_settings = $searchData['image_options'];
         if ($image_settings['show_images'] != 0) {
             $im = $this->getBFIimage($r);
             if ($im != '' && strpos($im, "mshots/v1") === false && w_isset_def($performance_options['image_cropping'], 0) == 1) {
                 if (w_isset_def($image_settings['image_transparency'], 1) == 1) {
                     $bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true);
                 } else {
                     $bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true, 'color' => wpdreams_rgb2hex($image_settings['image_bg_color']));
                 }
                 $r->image = bfi_thumb($im, $bfi_params);
             } else {
                 $r->image = $im;
             }
         }
         if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
             $r->title = get_the_title($r->id);
         } else {
             if ($searchData['titlefield'] == "1") {
                 if (strlen($r->excerpt) >= 200) {
                     $r->title = wd_substr_at_word($r->excerpt, 200);
                 } else {
                     $r->title = $r->excerpt;
                 }
             } else {
                 $mykey_values = get_post_custom_values($searchData['titlefield'], $r->id);
                 if (isset($mykey_values[0])) {
                     $r->title = $mykey_values[0];
                 } else {
                     $r->title = get_the_title($r->id);
                 }
             }
         }
         //remove the search shortcodes properly
         add_shortcode('wpdreams_ajaxsearchpro', array($this, 'return_empty_string'));
         add_shortcode('wpdreams_ajaxsearchlite', array($this, 'return_empty_string'));
         if (!isset($searchData['striptagsexclude'])) {
             $searchData['striptagsexclude'] = "<a><span>";
         }
         if (!isset($searchData['descriptionfield']) || $searchData['descriptionfield'] == "0" || is_array($searchData['descriptionfield'])) {
             if (w_isset_def($searchData['strip_shortcodes'], 0) == 1) {
                 $r->content = strip_shortcodes($r->content);
             }
             if (function_exists('qtrans_getLanguage')) {
                 $r->content = apply_filters('the_content', $r->content);
             }
             $_content = strip_tags($r->content);
         } else {
             if ($searchData['descriptionfield'] == "1") {
                 $_content = strip_tags($r->excerpt);
             } else {
                 if ($searchData['descriptionfield'] == "2") {
                     $_content = strip_tags(get_the_title($r->id));
                 } else {
                     $mykey_values = get_post_custom_values($searchData['descriptionfield'], $r->id);
                     if (isset($mykey_values[0])) {
                         $_content = strip_tags($mykey_values[0]);
                     } else {
                         $_content = strip_tags($r->content);
                     }
                 }
             }
         }
         if ($_content == "" && $r->content != '') {
             $_content = $r->content;
         }
         if ($_content != "") {
             $_content = str_replace('[wpdreams_ajaxsearchlite]', "", $_content);
         }
         if ($_content != "") {
             $_content = apply_filters('the_content', $_content);
         }
         // Remove styles and scripts
         $_content = preg_replace(array('#<script(.*?)>(.*?)</script>#is', '#<style(.*?)>(.*?)</style>#is'), '', $_content);
         $_content = strip_tags($_content);
         // Get the words from around the search phrase, or just the description
         if (w_isset_def($searchData['description_context'], 1) == 1 && count($_s) > 0) {
             $_content = $this->context_find($_content, $_s[0], floor($searchData['descriptionlength'] / 6), $searchData['descriptionlength']);
         } else {
             if ($_content != '' && strlen($_content) > $searchData['descriptionlength']) {
                 $_content = wd_substr_at_word($_content, $searchData['descriptionlength']) . "...";
             }
         }
         $_content = wd_closetags($_content);
         $r->content = $_content;
         // -------------------------- Woocommerce Fixes -----------------------------
         // A trick to fix the url
         if ($r->post_type == 'product_variation' && class_exists('WC_Product_Variation')) {
             $r->title = preg_replace("/(Variation) \\#(\\d+) (of)/si", '', $r->title);
             $wc_prod_var_o = new WC_Product_Variation($r->id);
             $r->link = $wc_prod_var_o->get_permalink();
         }
         // --------------------------------------------------------------------------
         $r->title = apply_filters('asl_result_title_after_prostproc', $r->title, $r->id);
         $r->content = apply_filters('asl_result_content_after_prostproc', $r->content, $r->id);
         $r->image = apply_filters('asl_result_image_after_prostproc', $r->image, $r->id);
         $r->author = apply_filters('asl_result_author_after_prostproc', $r->author, $r->id);
         $r->date = apply_filters('asl_result_date_after_prostproc', $r->date, $r->id);
     }
     /* !Images, title, desc */
     //var_dump($pageposts); die();
     $this->results = $pageposts;
     return $pageposts;
 }
Exemplo n.º 2
0
 /**
  * Post-processes the results
  *
  * @return array of results
  */
 protected function post_process()
 {
     $pageposts = is_array($this->results) ? $this->results : array();
     $options = $this->options;
     $searchId = $this->searchId;
     $searchData = $this->searchData;
     $s = $this->s;
     $_s = $this->_s;
     // Get multibite or regular functions to variables
     extract($this->mb_f);
     // No post processing is needed on non-ajax search
     if (isset($options['non_ajax_search'])) {
         $this->results = $pageposts;
         return $pageposts;
     }
     if (is_multisite()) {
         $home_url = network_home_url();
     } else {
         $home_url = home_url();
     }
     foreach ($pageposts as $k => $v) {
         $r =& $pageposts[$k];
         $r->title = w_isset_def($r->title, null);
         $r->content = w_isset_def($r->content, null);
         $r->image = w_isset_def($r->image, null);
         $r->author = w_isset_def($r->author, null);
         $r->date = w_isset_def($r->date, null);
     }
     /*--------------------- For Image Parser -----------------------*/
     // Do not select the content field, if it is not used at all
     $get_content = $searchData['showdescription'] == 1 || $searchData['resultstype'] == "isotopic" && $searchData['i_ifnoimage'] == 'description' || $searchData['resultstype'] == "polaroid" && ($searchData['pifnoimage'] == 'descinstead' || $searchData['pshowdesc'] == 1) ? false : true;
     // Do not select excerpt if its not used at all
     $get_excerpt = w_isset_def($searchData['titlefield'], 0) == 1 || w_isset_def($searchData['descriptionfield'], 0) == 1 ? false : true;
     /*---------------------------------------------------------------*/
     aspDebug::start('--searchContent-posptrocess');
     /* Images, title, desc */
     foreach ($pageposts as $k => $v) {
         // Let's simplify things
         $r =& $pageposts[$k];
         if (isset($options['switch_on_preprocess']) && is_multisite()) {
             switch_to_blog($r->blogid);
         }
         $r = apply_filters('asp_result_before_prostproc', $r, $searchId);
         $r->title = apply_filters('asp_result_title_before_prostproc', $r->title, $r->id, $searchId);
         $r->content = apply_filters('asp_result_content_before_prostproc', $r->content, $r->id, $searchId);
         $r->image = apply_filters('asp_result_image_before_prostproc', $r->image, $r->id, $searchId);
         $r->author = apply_filters('asp_result_author_before_prostproc', $r->author, $r->id, $searchId);
         $r->date = apply_filters('asp_result_date_before_prostproc', $r->date, $r->id, $searchId);
         $r->link = get_permalink($v->id);
         // ---- URL FIX for WooCommerce product variations
         if ($r->post_type == 'product_variation' && class_exists('WC_Product_Variation')) {
             $wc_prod_var_o = new WC_Product_Variation($r->id);
             $r->link = $wc_prod_var_o->get_permalink();
         }
         $caching_options = w_false_def(get_option('asp_caching'), get_option('asp_caching_def'));
         $use_bfi = w_isset_def($caching_options['use_bfi_thumb'], 1);
         $image_settings = $searchData['image_options'];
         if ($image_settings['show_images'] != 0) {
             if ($image_settings['image_cropping'] == 0) {
                 // Use the BFI parser, but no caching
                 $im = $this->getBFIimage($r, $get_content, $get_excerpt);
                 if ($im != '') {
                     $r->image = $im;
                 }
             } else {
                 if ($use_bfi == 0) {
                     $im = $this->getCachedImage($r, $get_content, $get_excerpt);
                     if ($im != '') {
                         $r->image = $im;
                     }
                 } else {
                     $im = $this->getBFIimage($r, $get_content, $get_excerpt);
                     if ($im != '' && strpos($im, "mshots/v1") === false) {
                         if (w_isset_def($image_settings['image_transparency'], 1) == 1) {
                             $bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true);
                         } else {
                             $bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true, 'color' => wpdreams_rgb2hex($image_settings['image_bg_color']));
                         }
                         $r->image = bfi_thumb($im, $bfi_params);
                     } else {
                         $r->image = $im;
                     }
                 }
             }
         }
         // If no image and defined, remove the result here, to perevent JS confusions
         if (empty($r->image) && $searchData['resultstype'] == "isotopic" && $searchData['i_ifnoimage'] == 'removeres') {
             unset($pageposts[$k]);
             continue;
         }
         if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
             $r->title = get_the_title($r->id);
         } else {
             if ($searchData['titlefield'] == "1") {
                 if ($fn_strlen($r->excerpt) >= 200) {
                     $r->title = wd_substr_at_word($r->excerpt, 200);
                 } else {
                     $r->title = $r->excerpt;
                 }
             } else {
                 $mykey_values = get_post_custom_values($searchData['titlefield'], $r->id);
                 if (isset($mykey_values[0])) {
                     $r->title = $mykey_values[0];
                 } else {
                     $r->title = get_the_title($r->id);
                 }
             }
         }
         $r->title = $this->adv_title($r->title, $r->id);
         if (!isset($searchData['striptagsexclude'])) {
             $searchData['striptagsexclude'] = "<a><span>";
         }
         //remove the search shortcode properly
         add_shortcode('wpdreams_ajaxsearchpro', array($this, 'return_empty_string'));
         if (!isset($searchData['descriptionfield']) || $searchData['descriptionfield'] == "0" || is_array($searchData['descriptionfield'])) {
             if (function_exists('qtrans_getLanguage')) {
                 $r->content = apply_filters('the_content', $r->content, $searchId);
             }
             $_content = strip_tags($r->content, $searchData['striptagsexclude']);
         } else {
             if ($searchData['descriptionfield'] == "1") {
                 $_content = strip_tags($r->excerpt, $searchData['striptagsexclude']);
             } else {
                 if ($searchData['descriptionfield'] == "2") {
                     $_content = strip_tags(get_the_title($r->id), $searchData['striptagsexclude']);
                 } else {
                     $mykey_values = get_post_custom_values($searchData['descriptionfield'], $r->id);
                     if (isset($mykey_values[0])) {
                         $_content = strip_tags($mykey_values[0], $searchData['striptagsexclude']);
                     } else {
                         $_content = strip_tags($r->content, $searchData['striptagsexclude']);
                     }
                 }
             }
         }
         if ($_content == "") {
             $_content = $r->content;
         }
         if (isset($searchData['runshortcode']) && $searchData['runshortcode'] == 1) {
             if ($_content != "") {
                 $_content = apply_filters('the_content', $_content, $searchId);
             }
         }
         if (isset($searchData['stripshortcode']) && $searchData['stripshortcode'] == 1) {
             if ($_content != "") {
                 $_content = strip_shortcodes($_content);
             }
         }
         // Remove styles and scripts
         $_content = preg_replace(array('#<script(.*?)>(.*?)</script>#is', '#<style(.*?)>(.*?)</style>#is'), '', $_content);
         $_content = strip_tags($_content, $searchData['striptagsexclude']);
         // Get the words from around the search phrase, or just the description
         if (w_isset_def($searchData['description_context'], 1) == 1 && count($_s) > 0) {
             $_content = $this->context_find($_content, $_s[0], floor($searchData['descriptionlength'] / 6), $searchData['descriptionlength']);
         } else {
             if ($_content != '' && $fn_strlen($_content) > $searchData['descriptionlength']) {
                 $_content = wd_substr_at_word($_content, $searchData['descriptionlength']) . "...";
             }
         }
         $_content = wd_closetags($_content);
         $r->content = $this->adv_desc($_content, $r->id);
         // -------------------------- Woocommerce Fixes -----------------------------
         // A trick to fix the url
         if ($r->post_type == 'product_variation' && class_exists('WC_Product_Variation')) {
             $r->title = preg_replace("/(Variation) \\#(\\d+) (of)/si", '', $r->title);
             $wc_prod_var_o = new WC_Product_Variation($r->id);
             $r->link = $wc_prod_var_o->get_permalink();
         }
         // --------------------------------------------------------------------------
         // --------------------------------- DATE -----------------------------------
         if ($searchData["showdate"] == 1) {
             $post_time = strtotime($r->date);
             if (w_isset_def($searchData['custom_date'], 0)) {
                 $date_format = w_isset_def($searchData['custom_date_format'], "Y-m-d H:i:s");
             } else {
                 $date_format = get_option('date_format', "Y-m-d") . " " . get_option('time_format', "H:i:s");
             }
             $r->date = @date($date_format, $post_time);
         }
         // --------------------------------------------------------------------------
         $r = apply_filters('asp_result_after_prostproc', $r, $searchId);
         $r->title = apply_filters('asp_result_title_after_prostproc', $r->title, $r->id, $searchId);
         $r->content = apply_filters('asp_result_content_after_prostproc', $r->content, $r->id, $searchId);
         $r->image = apply_filters('asp_result_image_after_prostproc', $r->image, $r->id, $searchId);
         $r->author = apply_filters('asp_result_author_after_prostproc', $r->author, $r->id, $searchId);
         $r->date = apply_filters('asp_result_date_after_prostproc', $r->date, $r->id, $searchId);
     }
     aspDebug::stop('--searchContent-posptrocess');
     if (isset($options['switch_on_preprocess']) && is_multisite()) {
         restore_current_blog();
     }
     /* !Images, title, desc */
     //var_dump($pageposts); die();
     $this->results = $pageposts;
     return $pageposts;
 }
Exemplo n.º 3
0
 /**
  * Post-processes the results
  *
  * @return array of results
  */
 protected function post_process()
 {
     $pageposts = is_array($this->results) ? $this->results : array();
     $options = $this->options;
     $searchId = $this->searchId;
     $searchData = $this->searchData;
     $s = $this->s;
     $_s = $this->_s;
     // No post processing is needed on non-ajax search
     if (isset($options['non_ajax_search'])) {
         $this->results = $pageposts;
         return $pageposts;
     }
     if (is_multisite()) {
         $home_url = network_home_url();
     } else {
         $home_url = home_url();
     }
     foreach ($pageposts as $k => $v) {
         $r =& $pageposts[$k];
         $r->title = w_isset_def($r->title, null);
         $r->content = w_isset_def($r->content, null);
         $r->image = w_isset_def($r->image, null);
         $r->author = w_isset_def($r->author, null);
         $r->date = w_isset_def($r->date, null);
     }
     aspDebug::start('--searchContent-posptrocess');
     /* Images, title, desc */
     foreach ($pageposts as $k => $v) {
         // Let's simplify things
         $r =& $pageposts[$k];
         if (isset($options['switch_on_preprocess']) && is_multisite()) {
             switch_to_blog($r->blogid);
         }
         $r = apply_filters('asp_result_before_prostproc', $r, $searchId);
         $r->title = apply_filters('asp_result_title_before_prostproc', $r->title, $r->id, $searchId);
         $r->content = apply_filters('asp_result_content_before_prostproc', $r->content, $r->id, $searchId);
         $r->image = apply_filters('asp_result_image_before_prostproc', $r->image, $r->id, $searchId);
         $r->author = apply_filters('asp_result_author_before_prostproc', $r->author, $r->id, $searchId);
         $r->date = apply_filters('asp_result_date_before_prostproc', $r->date, $r->id, $searchId);
         $r->link = get_permalink($v->id);
         // ---- URL FIX for WooCommerce product variations
         if ($r->post_type == 'product_variation' && class_exists('WC_Product_Variation')) {
             $wc_prod_var_o = new WC_Product_Variation($r->id);
             $r->link = $wc_prod_var_o->get_permalink();
         }
         $caching_options = w_false_def(get_option('asp_caching'), get_option('asp_caching_def'));
         $use_bfi = w_isset_def($caching_options['use_bfi_thumb'], 1);
         $image_settings = $searchData['image_options'];
         if ($image_settings['show_images'] != 0) {
             if ($image_settings['image_cropping'] == 0) {
                 // Use the BFI parser, but no caching
                 $im = $this->getBFIimage($r);
                 if ($im != '') {
                     $r->image = $im;
                 }
             } else {
                 if ($use_bfi == 0) {
                     $im = $this->getCachedImage($r);
                     if ($im != '') {
                         $r->image = $im;
                     }
                 } else {
                     $im = $this->getBFIimage($r);
                     if ($im != '' && strpos($im, "mshots/v1") === false) {
                         if (w_isset_def($image_settings['image_transparency'], 1) == 1) {
                             $bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true);
                         } else {
                             $bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true, 'color' => wpdreams_rgb2hex($image_settings['image_bg_color']));
                         }
                         $r->image = bfi_thumb($im, $bfi_params);
                     } else {
                         $r->image = $im;
                     }
                 }
             }
         }
         if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
             $r->title = get_the_title($r->id);
         } else {
             if ($searchData['titlefield'] == "1") {
                 if (strlen($r->excerpt) >= 200) {
                     $r->title = wd_substr_at_word($r->excerpt, 200);
                 } else {
                     $r->title = $r->excerpt;
                 }
             } else {
                 $mykey_values = get_post_custom_values($searchData['titlefield'], $r->id);
                 if (isset($mykey_values[0])) {
                     $r->title = $mykey_values[0];
                 } else {
                     $r->title = get_the_title($r->id);
                 }
             }
         }
         $r->title = $this->adv_title($r->title, $r->id);
         if (!isset($searchData['striptagsexclude'])) {
             $searchData['striptagsexclude'] = "<a><span>";
         }
         //remove the search shortcode properly
         add_shortcode('wpdreams_ajaxsearchpro', array($this, 'return_empty_string'));
         if (!isset($searchData['descriptionfield']) || $searchData['descriptionfield'] == "0" || is_array($searchData['descriptionfield'])) {
             if (function_exists('qtrans_getLanguage')) {
                 $r->content = apply_filters('the_content', $r->content, $searchId);
             }
             $_content = strip_tags($r->content, $searchData['striptagsexclude']);
         } else {
             if ($searchData['descriptionfield'] == "1") {
                 $_content = strip_tags($r->excerpt, $searchData['striptagsexclude']);
             } else {
                 if ($searchData['descriptionfield'] == "2") {
                     $_content = strip_tags(get_the_title($r->id), $searchData['striptagsexclude']);
                 } else {
                     $mykey_values = get_post_custom_values($searchData['descriptionfield'], $r->id);
                     if (isset($mykey_values[0])) {
                         $_content = strip_tags($mykey_values[0], $searchData['striptagsexclude']);
                     } else {
                         $_content = strip_tags($r->content, $searchData['striptagsexclude']);
                     }
                 }
             }
         }
         if ($_content == "") {
             $_content = $r->content;
         }
         if (isset($searchData['runshortcode']) && $searchData['runshortcode'] == 1) {
             if ($_content != "") {
                 $_content = apply_filters('the_content', $_content, $searchId);
             }
         }
         if (isset($searchData['stripshortcode']) && $searchData['stripshortcode'] == 1) {
             if ($_content != "") {
                 $_content = strip_shortcodes($_content);
             }
         }
         // Remove styles and scripts
         $_content = preg_replace(array('#<script(.*?)>(.*?)</script>#is', '#<style(.*?)>(.*?)</style>#is'), '', $_content);
         $_content = strip_tags($_content, $searchData['striptagsexclude']);
         if ($_content != '' && strlen($_content) > $searchData['descriptionlength']) {
             $_content = wd_substr_at_word($_content, $searchData['descriptionlength']) . "...";
         }
         $_content = wd_closetags($_content);
         $r->content = $this->adv_desc($_content, $r->id);
         // -------------------------- Woocommerce Fixes -----------------------------
         // A trick to fix the url
         if ($r->post_type == 'product_variation' && class_exists('WC_Product_Variation')) {
             $r->title = preg_replace("/(Variation) \\#(\\d+) (of)/si", '', $r->title);
             $wc_prod_var_o = new WC_Product_Variation($r->id);
             $r->link = $wc_prod_var_o->get_permalink();
         }
         // --------------------------------------------------------------------------
         $r = apply_filters('asp_result_after_prostproc', $r, $searchId);
         $r->title = apply_filters('asp_result_title_after_prostproc', $r->title, $r->id, $searchId);
         $r->content = apply_filters('asp_result_content_after_prostproc', $r->content, $r->id, $searchId);
         $r->image = apply_filters('asp_result_image_after_prostproc', $r->image, $r->id, $searchId);
         $r->author = apply_filters('asp_result_author_after_prostproc', $r->author, $r->id, $searchId);
         $r->date = apply_filters('asp_result_date_after_prostproc', $r->date, $r->id, $searchId);
     }
     aspDebug::stop('--searchContent-posptrocess');
     if (isset($options['switch_on_preprocess']) && is_multisite()) {
         restore_current_blog();
     }
     /* !Images, title, desc */
     //var_dump($pageposts); die();
     $this->results = $pageposts;
     return $pageposts;
 }
Exemplo n.º 4
0
 protected function post_process()
 {
     $pageposts = $this->results;
     $options = $this->options;
     $searchData = $this->searchData;
     $s = $this->s;
     $_s = $this->_s;
     /* Category filtering */
     $_selected_categories = array();
     if (isset($options['categoryset'])) {
         $_selected_categories = $options['categoryset'];
     }
     $_all_categories = get_all_category_ids();
     if (count($_selected_categories) > 0 && count($_all_categories) != count($_selected_categories)) {
         foreach ($pageposts as $k => $v) {
             if ($v->term_id == null) {
                 $v->term_id = "";
                 continue;
             }
             if ($v->post_type != 'post' && $searchData['pageswithcategories'] != 1) {
                 continue;
             }
             $_term_ids = explode(',', $v->term_id);
             if (count($_term_ids) <= 0) {
                 $_term_ids = array($v->term_id);
             }
             $match = false;
             $_new_terms = array();
             foreach ($_term_ids as $_term_id) {
                 if (in_array($_term_id, $_selected_categories)) {
                     $match = true;
                     $_new_terms[] = $_term_id;
                 }
             }
             if (!$match) {
                 unset($pageposts[$k]);
             } else {
                 $v->term_id = implode(",", $_new_terms);
             }
         }
     }
     /* !Category filtering */
     /* TERM filtering */
     if (isset($options['termset'])) {
         $terms = array();
         $o_terms = array();
         foreach ($options['termset'] as $term => $tax) {
             if ($tax != "0") {
                 $o_terms[$tax][] = $term;
             }
         }
         //var_dump($o_terms);
         foreach ($pageposts as $k => $v) {
             $terms = $o_terms;
             foreach ($terms as $ex_taxonomy => $ex_terms) {
                 $_post_terms = wp_get_post_terms($v->id, $ex_taxonomy);
                 $post_terms = array();
                 if (is_array($_post_terms) && isset($_post_terms[0])) {
                     foreach ($_post_terms as $_term) {
                         $post_terms[] = (int) $_term->term_id;
                     }
                     foreach ($ex_terms as $_term) {
                         /* Get all child terms of the current term */
                         $args = array('child_of' => $_term);
                         $termchildren = get_terms($ex_taxonomy, $args);
                         if (isset($termchildren) && count($termchildren) > 0) {
                             foreach ($termchildren as $child_term) {
                                 if (!in_array((int) $child_term->term_id, $ex_terms)) {
                                     $ex_terms[] = (int) $child_term->term_id;
                                 }
                             }
                         }
                         /* Get the parent term of the current term */
                         $parent = get_term_by('id', $_term, $ex_taxonomy);
                         if (isset($parent) && isset($parent->term_id) && $parent->term_id != 0) {
                             $ex_terms[] = $parent->term_id;
                         }
                     }
                     $diff = array_unique(array_diff($post_terms, $ex_terms));
                     //var_dump($post_terms);
                     //var_dump($ex_terms);
                     //var_dump($diff);
                     //exit;
                     if (!is_array($diff) || count($diff) < 1) {
                         unset($pageposts[$k]);
                         break;
                     }
                 }
             }
         }
     }
     /* !TERM  filtering */
     /* Images, title, desc */
     foreach ($pageposts as $k => $v) {
         // Let's simplify things
         $r =& $pageposts[$k];
         $r->title = apply_filters('asp_result_title_before_prostproc', $r->title, $r->id);
         $r->content = apply_filters('asp_result_content_before_prostproc', $r->content, $r->id);
         $r->image = apply_filters('asp_result_image_before_prostproc', $r->image, $r->id);
         $r->author = apply_filters('asp_result_author_before_prostproc', $r->author, $r->id);
         $r->date = apply_filters('asp_result_date_before_prostproc', $r->date, $r->id);
         $r->link = get_permalink($v->id);
         $use_timthumb = get_option('asp_usetimbthumb');
         if ($use_timthumb) {
             if ($searchData['settings-imagesettings']['show'] == 1) {
                 $imgs = $searchData['settings-imagesettings'];
                 ksort($imgs['from']);
                 if ($searchData['resultstype'] == 'vertical') {
                     $_width = $imgs['width'];
                     $_height = $imgs['height'];
                 } else {
                     $_width = wpdreams_width_from_px($searchData['hreswidth']);
                     $_vimageratio = $_width / $searchData['selected-imagesettings']['width'];
                     $_height = $_vimageratio * $searchData['selected-imagesettings']['height'];
                 }
                 foreach ($imgs['from'] as $kk => $source) {
                     if ($kk == -11) {
                         continue;
                     }
                     if (isset($r->image) || $r->image != '') {
                         continue;
                     }
                     if ($source == 'featured') {
                         $im = wp_get_attachment_url(get_post_thumbnail_id($v->id));
                     } else {
                         if ($source == 'content') {
                             $im = wpdreams_get_image_from_content($v->content, $imgs['imagenum']);
                         } else {
                             if ($source == 'excerpt') {
                                 $im = wpdreams_get_image_from_content($v->excerpt, $imgs['imagenum']);
                             } else {
                                 if ($source == 'usecustom') {
                                     if (isset($imgs['customname']) && $imgs['customname'] != '') {
                                         $im = get_post_meta($v->id, $imgs['customname'], true);
                                         if ($im != '' && $im != false) {
                                         } else {
                                             continue;
                                         }
                                     } else {
                                         continue;
                                     }
                                 }
                             }
                         }
                     }
                     if ($im !== false && $im != '') {
                         $r->image = plugins_url('/ajax-search-pro/includes/timthumb.php') . '?cc=' . str_replace('#', '', wpdreams_rgb2hex($searchData['imagebg'])) . '&ct=0&q=95&w=' . $_width . '&h=' . $_height . '&src=' . rawurlencode($im);
                         break;
                     }
                 }
             }
         } else {
             if ($searchData['settings-imagesettings']['show'] == 1) {
                 $imgs = $searchData['settings-imagesettings'];
                 ksort($imgs['from']);
                 if ($searchData['resultstype'] == 'vertical') {
                     $_width = $imgs['width'];
                     $_height = $imgs['height'];
                 } else {
                     if ($searchData['resultstype'] == 'horizontal') {
                         $_width = wpdreams_width_from_px($searchData['hreswidth']);
                         $_vimageratio = $_width / $searchData['selected-imagesettings']['width'];
                         $_height = $_vimageratio * $searchData['selected-imagesettings']['height'];
                     } else {
                         $_width = wpdreams_width_from_px($searchData['preswidth']) - 2 * wpdreams_width_from_px($searchData['prespadding']);
                         $_height = $_width;
                     }
                 }
                 foreach ($imgs['from'] as $kk => $source) {
                     if ($kk == -11) {
                         continue;
                     }
                     if (isset($r->image) || $r->image != '') {
                         continue;
                     }
                     // Calculate the image size
                     if ($source == 'featured') {
                         //$im = get_the_post_thumbnail($v->id);
                         $im = wp_get_attachment_url(get_post_thumbnail_id($v->id));
                         //var_dump($im);
                         $img = new wpdreamsImageCache($im, "post" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, -1, $searchData['imagebg']);
                     } else {
                         if ($source == 'content') {
                             $img = new wpdreamsImageCache($v->content, "post" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, $imgs['imagenum'], $searchData['imagebg']);
                         } else {
                             if ($source == 'excerpt') {
                                 $img = new wpdreamsImageCache($v->excerpt, "post" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, $imgs['imagenum'], $searchData['imagebg']);
                             } else {
                                 if ($source == 'usecustom') {
                                     if (isset($imgs['customname']) && $imgs['customname'] != '') {
                                         $im = get_post_meta($v->id, $imgs['customname'], true);
                                         if ($im != '' && $im != false) {
                                             $img = new wpdreamsImageCache($im, "post" . $v->id, AJAXSEARCHPRO_PATH . DIRECTORY_SEPARATOR . "cache" . DIRECTORY_SEPARATOR, $_width, $_height, -1, $searchData['imagebg']);
                                         } else {
                                             continue;
                                         }
                                     } else {
                                         continue;
                                     }
                                 }
                             }
                         }
                     }
                     $res = $img->get_image();
                     if ($res != '') {
                         $r->image = plugins_url('/ajax-search-pro/cache/' . $res);
                         break;
                     }
                 }
             }
         }
         if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
             $r->title = get_the_title($r->id);
         } else {
             if ($searchData['titlefield'] == "1") {
                 if (strlen($r->excerpt) >= 200) {
                     $r->title = substr($r->excerpt, 0, 200);
                 } else {
                     $r->title = $r->excerpt;
                 }
             } else {
                 $mykey_values = get_post_custom_values($searchData['titlefield'], $r->id);
                 if (isset($mykey_values[0])) {
                     $r->title = $mykey_values[0];
                 } else {
                     $r->title = get_the_title($r->id);
                 }
             }
         }
         if (!isset($searchData['striptagsexclude'])) {
             $searchData['striptagsexclude'] = "<a><span>";
         }
         if (!isset($searchData['descriptionfield']) || $searchData['descriptionfield'] == "0" || is_array($searchData['descriptionfield'])) {
             if (function_exists('qtrans_getLanguage')) {
                 $r->content = apply_filters('the_content', $r->content);
             }
             $_content = strip_tags($r->content, $searchData['striptagsexclude']);
         } else {
             if ($searchData['descriptionfield'] == "1") {
                 $_content = strip_tags($r->excerpt, $searchData['striptagsexclude']);
             } else {
                 if ($searchData['descriptionfield'] == "2") {
                     $_content = strip_tags(get_the_title($r->id), $searchData['striptagsexclude']);
                 } else {
                     $mykey_values = get_post_custom_values($searchData['descriptionfield'], $r->id);
                     if (isset($mykey_values[0])) {
                         $_content = strip_tags($mykey_values[0], $searchData['striptagsexclude']);
                     } else {
                         $_content = strip_tags(get_content_w($r->content), $searchData['striptagsexclude']);
                     }
                 }
             }
         }
         if ($_content == "") {
             $_content = $r->content;
         }
         if (isset($searchData['runshortcode']) && $searchData['runshortcode'] == 1) {
             if ($_content != "") {
                 $_content = apply_filters('the_content', $_content);
             }
             if ($_content != "") {
                 $_content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $_content);
             }
         }
         if (isset($searchData['stripshortcode']) && $searchData['stripshortcode'] == 1) {
             if ($_content != "") {
                 $_content = strip_shortcodes($_content);
             }
         }
         $_content = strip_tags($_content, $searchData['striptagsexclude']);
         if ($_content != '' && strlen($_content) > $searchData['descriptionlength']) {
             $r->content = substr($_content, 0, $searchData['descriptionlength']) . "...";
         } else {
             $r->content = $_content . "...";
         }
         $r->title = apply_filters('asp_result_title_after_prostproc', $r->title, $r->id);
         $r->content = apply_filters('asp_result_content_after_prostproc', $r->content, $r->id);
         $r->image = apply_filters('asp_result_image_after_prostproc', $r->image, $r->id);
         $r->author = apply_filters('asp_result_author_after_prostproc', $r->author, $r->id);
         $r->date = apply_filters('asp_result_date_after_prostproc', $r->date, $r->id);
     }
     /* !Images, title, desc */
     //var_dump($pageposts); die();
     $this->results = $pageposts;
     return $pageposts;
 }