Exemple #1
0
 public static function get_ajax_auto_recount_data()
 {
     //for qtranslate
     if (!empty($_REQUEST['mdf_front_qtrans_lang'])) {
         if (function_exists('qtrans_enableLanguage')) {
             $GLOBALS['q_config']['language'] = $_REQUEST['mdf_front_qtrans_lang'];
         }
     }
     //+++
     //for WPML
     if (!empty($_REQUEST['mdf_front_wpml_lang'])) {
         if (class_exists('SitePress')) {
             global $sitepress;
             $sitepress->switch_lang($_REQUEST['mdf_front_wpml_lang']);
         }
     }
     //+++
     //when we do sort before searching
     if ((int) $_REQUEST['mdf_is_search_going'] == 0) {
         if ($_REQUEST['mdf_tmp_order'] != '0' and $_REQUEST['mdf_tmp_orderby'] != '0') {
             $_REQUEST['order'] = self::$default_order = $_REQUEST['mdf_tmp_order'];
             $_REQUEST['order_by'] = self::$default_order_by = $_REQUEST['mdf_tmp_orderby'];
         }
     }
     //+++
     $_REQUEST['no_wp_die'] = TRUE;
     $_REQUEST['mdf_ajax_request'] = TRUE;
     $link_data = explode('&', self::encode_search_get_params());
     $data = array();
     if (!empty($link_data)) {
         foreach ($link_data as $pair) {
             $tmp = explode('=', $pair);
             $data[$tmp[0]] = $tmp[1];
         }
     }
     //+++
     $_REQUEST['mdf_cat'] = $data['mdf_cat'];
     $_REQUEST['page_mdf'] = $data['page_mdf'];
     $slug = $_REQUEST['slug'];
     //print_r($_REQUEST);
     $mdf_data = self::get_page_mdf_data();
     //+++
     set_query_var('paged', 0);
     $_GET['slg'] = $slug;
     $_REQUEST['mdf_do_not_render_shortcode_tpl'] = TRUE;
     //***
     do_shortcode('[meta_data_filter_results]');
     $result = array();
     if ($_REQUEST['type'] == 'shortcode') {
         $result['form'] = do_shortcode('[mdf_search_form id="' . $_REQUEST['shortcode_id'] . '"]');
     } else {
         ob_start();
         self::dynamic_sidebar($_REQUEST['widget_id'], $_REQUEST['sidebar_id']);
         $result['form'] = ob_get_clean();
     }
     //return data if we use ajax content redrawing
     if ($_REQUEST['mdf_ajax_content_redraw'] and isset($_REQUEST['shortcode_txt'])) {
         $result['content'] = do_shortcode("[" . $_REQUEST['shortcode_txt'] . "]");
     }
     echo json_encode($result);
     exit;
 }