public function get_all_search_forms_wlang($lang = "")
 {
     if ($lang != "") {
         if (Search_Filter_Helper::has_wpml()) {
             global $sitepress;
             if (!empty($sitepress)) {
                 $sitepress->switch_lang($lang);
             }
         }
     }
     $search_form_query = new WP_Query('post_type=search-filter-widget&fields=ids&post_status=publish&posts_per_page=-1');
     $all_search_form_ids = $search_form_query->get_posts();
     return $all_search_form_ids;
 }
 public function set_filter_term_ids_cached()
 {
     //$time_start = microtime(true);
     global $wpdb;
     $filter_names = array();
     $filter_names = array_unique(array_keys($this->filters));
     $filter_query_arr = array();
     foreach ($filter_names as $filter_name) {
         array_push($filter_query_arr, "field_name = '{$filter_name}'");
     }
     $filter_query_sql = implode(" OR ", $filter_query_arr);
     if (empty($filter_query_sql)) {
         return;
     }
     $field_terms_results = $wpdb->get_results("\n\t\t\tSELECT field_name, field_value, result_ids\n\t\t\tFROM {$this->term_results_table_name}\n\t\t\tWHERE {$filter_query_sql}\n\t\t\t");
     $treat_child_posts_as_parent = false;
     if (isset($this->form_settings["treat_child_posts_as_parent"])) {
         $treat_child_posts_as_parent = (bool) $this->form_settings["treat_child_posts_as_parent"];
     }
     $parent_convert_ids = array();
     $cache_term_results = array();
     foreach ($field_terms_results as $term_result) {
         $setup_term = true;
         if (!isset($cache_term_results[$term_result->field_name])) {
             $cache_term_results[$term_result->field_name] = array();
         }
         $field_value = $term_result->field_value;
         if ($this->is_taxonomy_key($term_result->field_name)) {
             //convert ID to slug
             //$term_id_postfix = $field_value;
             $taxonomy_name = substr($term_result->field_name, strlen(SF_TAX_PRE));
             $term = get_term($term_result->field_value, $taxonomy_name, 'OBJECT', false);
             $field_value = $term->slug;
             //.$term_id_postfix;
             if (Search_Filter_Helper::has_wpml()) {
                 //do not even add the term to the list if its in the wrong language
                 if ($term_result->field_value != $term->term_id) {
                     //this means WPML changed teh ID to current language ID, which means we just want to skip over this completely
                     //echo "\ntax name: $taxonomy_name | field_value: ".$term_result->field_value. " | term id: ".$term->term_id."\n";
                     $setup_term = false;
                 }
             }
         }
         if ($setup_term) {
             $cache_term_results[$term_result->field_name][$field_value] = explode(",", $term_result->result_ids);
             //then convert any IDs to parent IDs instead
             if ($treat_child_posts_as_parent) {
                 if ($this->is_meta_value($term_result->field_name)) {
                     $parent_convert_ids = array_merge($parent_convert_ids, $cache_term_results[$term_result->field_name][$field_value]);
                     /*
                     $field_terms_results = $wpdb->get_results(
                     	"
                     	SELECT post_id, post_parent_id
                     	FROM $this->table_name
                     	WHERE field_name = '$filter_name' 
                     		AND cast(field_value AS UNSIGNED) $compare_operator $filter_value
                     	"
                     );
                     */
                 }
             }
         }
     }
     if ($treat_child_posts_as_parent) {
         //this converts child posts ids in to parent ids
         $parent_convert_ids = array_unique($parent_convert_ids);
         //get post types
         $post_types = array();
         if (isset($this->form_settings['post_types'])) {
             if (is_array($this->form_settings['post_types'])) {
                 $post_types = array_keys($this->form_settings['post_types']);
             }
         }
         //if its a single post type, get rid of array - helps with some compatibility issues where themes are not expecting an array here
         if (count($post_types) == 1) {
             $post_types = $post_types[0];
         }
         $parent_conv_args = array('post_type' => $post_types, 'posts_per_page' => -1, 'paged' => 1, 'post__in' => $parent_convert_ids, 'fields' => "id=>parent", 'orderby' => "", 'meta_key' => "", 'order' => "", 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false);
         // The Query
         $query_arr = new WP_Query($parent_conv_args);
         $new_ids = array();
         if ($query_arr->have_posts()) {
             foreach ($query_arr->posts as $post) {
                 if ($post->post_parent == 0) {
                     $new_ids['post_' . $post->ID] = $post->ID;
                 } else {
                     $new_ids['post_' . $post->ID] = $post->post_parent;
                 }
             }
         }
         foreach ($field_terms_results as $term_result) {
             $field_value = $term_result->field_value;
             if ($this->is_meta_value($term_result->field_name)) {
                 $current_arr = $cache_term_results[$term_result->field_name][$field_value];
                 $new_curr_arr = array();
                 foreach ($current_arr as $post_id) {
                     if (isset($new_ids['post_' . $post_id])) {
                         array_push($new_curr_arr, $new_ids['post_' . $post_id]);
                     }
                 }
                 $cache_term_results[$term_result->field_name][$field_value] = array_unique($new_curr_arr);
             }
         }
     }
     //echo "\n\n\n------------------------------------------------------------\n\n\n";
     foreach ($this->filters as $filter_name => $filter) {
         $field_terms = $this->filters[$filter_name]["terms"];
         if ($filter['type'] == "choice") {
             foreach ($field_terms as $term_name => $tval) {
                 $cached_term_results = array();
                 if (isset($cache_term_results[$filter_name])) {
                     if (isset($cache_term_results[$filter_name][$term_name])) {
                         $cached_term_results = $cache_term_results[$filter_name][$term_name];
                     }
                 }
                 $this->filters[$filter_name]['terms'][$term_name]['cache_result_ids'] = $cached_term_results;
             }
             $hierarchical = 0;
             $include_children = 0;
             if (isset($this->form_fields[$filter_name]['hierarchical']) && isset($this->form_fields[$filter_name]['include_children'])) {
                 $hierarchical = $this->form_fields[$filter_name]['hierarchical'];
                 $include_children = $this->form_fields[$filter_name]['include_children'];
             }
             if ($hierarchical == 1 && $include_children == 1) {
                 $taxonomy_name = "";
                 $term_ids_w_parent = array();
                 if (strpos($filter_name, SF_TAX_PRE) === 0) {
                     $taxonomy_name = substr($filter_name, strlen(SF_TAX_PRE));
                 }
                 if ($taxonomy_name != "") {
                     foreach ($field_terms as $term_name => $the_term) {
                         if (isset($the_term['term_id'])) {
                             $ancestors = get_ancestors($the_term['term_id'], $taxonomy_name);
                             foreach ($ancestors as $ancestor) {
                                 if (!isset($term_ids_w_parent[$ancestor])) {
                                     $term_ids_w_parent[$ancestor] = array();
                                 }
                                 $term_ids_w_parent[$ancestor] = array_merge($term_ids_w_parent[$ancestor], $this->filters[$filter_name]['terms'][$term_name]['cache_result_ids']);
                             }
                         }
                     }
                     foreach ($term_ids_w_parent as $term_wp_id => $term_wp_ids) {
                         //get
                         $push_term = get_term($term_wp_id, $taxonomy_name);
                         $push_term_name = $push_term->slug;
                         if (isset($this->filters[$filter_name]['terms'][$push_term_name])) {
                             $this->filters[$filter_name]['terms'][$push_term_name]['cache_result_ids'] = array_unique(array_merge($this->filters[$filter_name]['terms'][$push_term_name]['cache_result_ids'], $term_wp_ids));
                         } else {
                             $this->filters[$filter_name]['terms'][$push_term_name] = array();
                             $this->filters[$filter_name]['terms'][$push_term_name]['cache_result_ids'] = $term_wp_ids;
                         }
                     }
                     //now put these IDs back on the the cached result IDs
                 }
             } else {
                 //echo "don't include the kids";
             }
         } else {
             if ($filter['is_range'] == true) {
                 $start_field_name = $filter_name;
                 $end_field_name = $filter_name;
                 //start / end keys are the same
                 if ($filter['type'] == "number") {
                     if (isset($this->form_fields[$filter_name]['number_use_same_toggle'])) {
                         if ($this->form_fields[$filter_name]['number_use_same_toggle'] != 1) {
                             $end_field_name = SF_META_PRE . $this->form_fields[$filter_name]['number_end_meta_key'];
                         }
                     }
                 } else {
                     if ($filter['type'] == "date") {
                         if (isset($this->form_fields[$filter_name]['date_use_same_toggle'])) {
                             if ($this->form_fields[$filter_name]['date_use_same_toggle'] != 1) {
                                 $end_field_name = SF_META_PRE . $this->form_fields[$filter_name]['date_end_meta_key'];
                             }
                         }
                     }
                 }
                 $this->filters[$filter_name]['terms']["value"]['cache_result_ids'] = $this->get_cache_number_range_ids($start_field_name, $end_field_name, $this->filters[$filter_name]);
                 /*
                 				foreach($field_terms as $term_name => $tval)
                 				{
                 					$_filter_name = $filter_name;
                 					
                 					if($term_name=="max")
                 					{//then check to see if we use the same meta_key
                 						
                 						if($filter['type']=="number")
                 						{
                 							if(isset($this->form_fields[$filter_name]['number_use_same_toggle']))
                 							{
                 								if($this->form_fields[$filter_name]['number_use_same_toggle']!=1)
                 								{
                 									$_filter_name = SF_META_PRE.$this->form_fields[$filter_name]['number_end_meta_key'];
                 								}
                 							}							
                 						}
                 						else if($filter['type']=="date")
                 						{
                 							if(isset($this->form_fields[$filter_name]['date_use_same_toggle']))
                 							{
                 								if($this->form_fields[$filter_name]['date_use_same_toggle']!=1)
                 								{
                 									
                 									$_filter_name = SF_META_PRE.$this->form_fields[$filter_name]['date_end_meta_key'];
                 									
                 								}
                 							}							
                 						}
                 					}
                 					$this->filters[$filter_name]['terms'][$term_name]['cache_result_ids'] = $this->get_cache_number_range_ids($_filter_name, $term_name, $this->filters[$filter_name]);
                 					
                 				}*/
             } else {
                 if ($filter['type'] == "date") {
                     foreach ($field_terms as $term_name => $tval) {
                         $this->filters[$filter_name]['terms'][$term_name]['cache_result_ids'] = $this->get_cache_number_ids($filter_name, $term_name, $this->filters[$filter_name]);
                     }
                 }
             }
         }
     }
     //$time_end = microtime(true);
     //$total_time = $time_end - $time_start;
     //echo "========================<br />";
     //echo "Total time `set_filter_term_ids_cached`: $total_time seconds<br /><br />";
 }
            }
            if (isset($values['taxonomies_settings'][$taxonomy->name]['include_exclude'])) {
                $sval = $values['taxonomies_settings'][$taxonomy->name]['include_exclude'];
            }
        }
        echo '<select name="settings_taxonomies[' . $taxonomy->name . '][include_exclude]" class="meta_key" id="' . $taxonomy->name . '_include_exclude">';
        echo '<option value="include"' . $this->set_selected($sval, "include", false) . '>Include</option>';
        echo '<option value="exclude"' . $this->set_selected($sval, "exclude", false) . '>Exclude</option>';
        echo '</select>';
        $ids_string = "";
        if ($tval != "") {
            $ids_array = array_map("intval", explode(",", $tval));
            if (Search_Filter_Helper::has_wpml()) {
                $res = array();
                foreach ($ids_array as $id) {
                    $xlat = Search_Filter_Helper::wpml_object_id($id, $taxonomy->name, false);
                    if (!is_null($xlat)) {
                        $res[] = $xlat;
                    }
                }
                $ids_array = $res;
            }
            $ids_string = implode(",", $ids_array);
        }
        ?>
							</td>
							<td>
							<input class="settings_exclude_ids" id="<?php 
        echo esc_attr($taxonomy->name);
        ?>
_ids" name="settings_taxonomies[<?php 
    function form($instance)
    {
        if (isset($instance['title']) && isset($instance['formid'])) {
            $title = __(esc_attr($instance['title']), $this->plugin_slug);
            $formid = esc_attr($instance['formid']);
        } else {
            $title = __('', $this->plugin_slug);
            $formid = __('', $this->plugin_slug);
        }
        ?>
		<div class="sf-widget-content">
			<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
 <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo $title;
        ?>
" /></label></p>
			<p>
				<label for="<?php 
        echo $this->get_field_id('formid');
        ?>
">Choose a Search Form: 
					<select class="widefat" name="<?php 
        echo $this->get_field_name('formid');
        ?>
" id="<?php 
        echo $this->get_field_id('formid');
        ?>
">
						<option value="0"><?php 
        _e('Please choose');
        ?>
</option>
						<?php 
        //
        $custom_posts = new WP_Query('post_type=search-filter-widget&post_status=publish&posts_per_page=-1');
        if (Search_Filter_Helper::has_wpml()) {
            $formid = Search_Filter_Helper::wpml_object_id($formid, 'search-filter-widget', true, ICL_LANGUAGE_CODE);
        }
        //var_dump($custom_posts);
        while ($custom_posts->have_posts()) {
            $custom_posts->the_post();
            ?>
							<option value="<?php 
            the_ID();
            ?>
" <?php 
            if ($formid == get_the_ID()) {
                echo ' selected="selected"';
            }
            ?>
><?php 
            the_title();
            ?>
</option>
						<?php 
        }
        ?>

					</select>
				</label>
			</p>
			<p class="sf-widget-text-last">
				<?php 
        _e('Don\'t see a Search Form you want to use? <a href="' . admin_url('post-new.php?post_type=search-filter-widget') . '">Create a new Search Form</a>.');
        ?>
				
			</p>
		</div>
		<?php 
    }
Beispiel #5
0
 function get_results()
 {
     //$this->hard_remove_filters();
     if (isset($_GET['sfid']) && isset($_GET['sf_action'])) {
         //get_form
         $sf_action = esc_attr($_GET['sf_action']);
         if (esc_attr($_GET['sfid']) != "" && ($sf_action == "get_results" || $sf_action == "get_form")) {
             global $searchandfilter;
             $sfid = (int) $_GET['sfid'];
             $sf_inst = $searchandfilter->get($sfid);
             if ($sf_action == "get_results") {
                 if ($sf_inst->settings("display_results_as") == "shortcode") {
                     $results = array();
                     $results['form'] = $this->display_shortcode->display_shortcode(array("id" => $sfid));
                     $results['results'] = $sf_inst->query()->the_results();
                     echo Search_Filter_Helper::json_encode($results);
                     exit;
                 }
             } else {
                 if ($sf_action == "get_form") {
                     $results = array();
                     $results['form'] = $this->display_shortcode->display_shortcode(array("id" => $sfid));
                     echo Search_Filter_Helper::json_encode($results);
                     exit;
                 }
             }
         }
     }
 }
 public function cache_progress()
 {
     $cache_json = $this->cache_options;
     unset($cache_json['cache_list']);
     echo Search_Filter_Helper::json_encode($cache_json);
     if ($this->cache_options['rc_status'] == "") {
         //then we need to test for a remote connection
         $this->can_wp_remote_post();
     }
     if ($this->cache_options['rc_status'] == "connect_success") {
         //there is a remote connection error, so don't try remote call
         $query_args = array("action" => "refresh_cache");
         $url = add_query_arg($query_args, admin_url('admin-ajax.php'));
         $this->wp_remote_post_with_cookie($url);
         //run in the background - calls refresh_cache()
     } else {
         $this->refresh_cache();
     }
     /*if(($this->cache_options['locked']==false)&&($this->cache_options['rc_status']))
     		{
     			//refresh_cache
     		}*/
     exit;
 }
 public function display_shortcode($atts, $content = null)
 {
     $lazy_load_js = get_option('search_filter_lazy_load_js');
     if ($lazy_load_js == 1) {
         $this->enqueue_scripts();
     }
     // extract the attributes into variables
     extract(shortcode_atts(array('id' => '', 'show' => 'form', 'action' => ''), $atts));
     $returnvar = "";
     //make sure its set
     if ($id != "") {
         $base_form_id = (int) $id;
         if (Search_Filter_Helper::has_wpml()) {
             $base_form_id = Search_Filter_Helper::wpml_object_id($id, 'search-filter-widget', true, ICL_LANGUAGE_CODE);
         }
         if (get_post_status($base_form_id) != "publish") {
             return;
         }
         $fields = get_post_meta($base_form_id, '_search-filter-fields', true);
         $settings = get_post_meta($base_form_id, '_search-filter-settings', true);
         $addclass = "";
         global $searchandfilter;
         $searchform = $searchandfilter->get($base_form_id);
         $this->set_defaults($base_form_id);
         if ($action == "prep_query") {
             return $returnvar;
         } else {
             if ($action == "do_archive_query") {
                 do_action("search_filter_archive_query", $base_form_id);
                 //legacy
                 do_action("search_filter_do_query", $base_form_id);
                 return $returnvar;
             } else {
                 if ($action == "setup_pagination") {
                     //$searchform->query()->prep_query();
                     $searchform->query()->setup_pagination();
                     return $returnvar;
                 } else {
                     if ($show == "form") {
                         /* TODO  set auto count somewhere else */
                         //make sure there are fields
                         if (isset($fields)) {
                             //make sure fields are in array format as expected
                             if (is_array($fields)) {
                                 $use_ajax = isset($settings['use_ajax_toggle']) ? (bool) $settings['use_ajax_toggle'] : false;
                                 $use_history_api = true;
                                 $ajax_target = isset($settings['ajax_target']) ? esc_attr($settings['ajax_target']) : '';
                                 $results_url = isset($settings['results_url']) ? esc_attr($settings['results_url']) : '';
                                 $page_slug = isset($settings['page_slug']) ? esc_attr($settings['page_slug']) : '';
                                 $ajax_links_selector = isset($settings['ajax_links_selector']) ? esc_attr($settings['ajax_links_selector']) : '';
                                 $ajax_auto_submit = isset($settings['auto_submit']) ? (int) $settings['auto_submit'] : '';
                                 $auto_count = isset($settings['enable_auto_count']) ? (int) $settings['enable_auto_count'] : '';
                                 $auto_count_refresh_mode = isset($settings['auto_count_refresh_mode']) ? (int) $settings['auto_count_refresh_mode'] : '';
                                 $use_results_shortcode = isset($settings['use_results_shortcode']) ? (int) $settings['use_results_shortcode'] : '';
                                 /* legacy */
                                 $display_results_as = isset($settings['display_results_as']) ? esc_attr($settings['display_results_as']) : 'shortcode';
                                 $update_ajax_url = isset($settings['update_ajax_url']) ? (int) $settings['update_ajax_url'] : 1;
                                 $only_results_ajax = isset($settings['only_results_ajax']) ? (int) $settings['only_results_ajax'] : '';
                                 $scroll_to_pos = isset($settings['scroll_to_pos']) ? esc_attr($settings['scroll_to_pos']) : '';
                                 $scroll_on_action = isset($settings['scroll_on_action']) ? esc_attr($settings['scroll_on_action']) : '';
                                 $custom_scroll_to = isset($settings['custom_scroll_to']) ? esc_html($settings['custom_scroll_to']) : '';
                                 //$is_woocommerce = isset($settings['is_woocommerce']) ? esc_html($settings['is_woocommerce']) : '';
                                 /* legacy */
                                 if (isset($settings['use_results_shortcode'])) {
                                     if ($settings['use_results_shortcode'] == 1) {
                                         $display_results_as = "shortcode";
                                     } else {
                                         $display_results_as = "archive";
                                     }
                                 }
                                 /* end legacy */
                                 //if($display_results_as=="shortcode")
                                 //{
                                 //prep the query so we can get the counts for the items in the search form - should not really be loaded here - needs to run before page load
                                 $searchform->query()->prep_query();
                                 //}
                                 if ($display_results_as == "shortcode") {
                                     //if we're using a shortcode, grab the selector automatically from the id
                                     $ajax_target = "#search-filter-results-" . $base_form_id;
                                 }
                                 $post_types = isset($settings['post_types']) ? $settings['post_types'] : '';
                                 //url
                                 /*$ajax_url = "";
                                 		$start_url = home_url();
                                 		$full_url = $this->get_current_URL();
                                 		if(substr($full_url, 0, strlen($start_url)) == $start_url)
                                 		{
                                 			$ajax_url = substr($full_url, strlen($start_url));
                                 		}*/
                                 $form_attr = ' data-sf-form-id="' . $base_form_id . '" data-is-rtl="' . (int) is_rtl() . '"';
                                 $ajax_url = "";
                                 /* figure out the ajax/results urls */
                                 if ($display_results_as == "archive") {
                                     //get search & filter results url respecting permalink settings
                                     $results_url = home_url("?sfid=" . $base_form_id);
                                     //$results_url = add_query_arg(array('sfid' => $base_form_id), pll_home_url());
                                     if (get_option('permalink_structure')) {
                                         $page_slug = $settings['page_slug'];
                                         if ($page_slug != "") {
                                             $results_url = trailingslashit(home_url($page_slug));
                                         }
                                     }
                                     if (has_filter('sf_archive_results_url')) {
                                         $results_url = apply_filters('sf_archive_results_url', $results_url, $base_form_id, $page_slug);
                                     }
                                 } else {
                                     if ($display_results_as == "post_type_archive") {
                                         //get the post type for this form (should only be one set)
                                         //then find out the proper url for the archive page according to permalink option
                                         if (isset($settings['post_types'])) {
                                             $post_types = array_keys($settings['post_types']);
                                             if (isset($post_types[0])) {
                                                 $post_type = $post_types[0];
                                                 if ($post_type == "post") {
                                                     if (get_option('show_on_front') == 'page') {
                                                         $results_url = get_permalink(get_option('page_for_posts'));
                                                     } else {
                                                         $results_url = home_url('/');
                                                     }
                                                 } else {
                                                     $results_url = get_post_type_archive_link($post_type);
                                                 }
                                             }
                                         }
                                     } else {
                                         if ($display_results_as == "shortcode") {
                                             //use the results_url defined by the user
                                             $ajax_url = home_url("?sfid=" . $base_form_id . "&sf_action=get_results");
                                         } else {
                                             if ($display_results_as == "custom_edd_store") {
                                                 //use the results_url defined by the user
                                             } else {
                                                 if ($display_results_as == "custom_woocommerce_store" && function_exists('woocommerce_get_page_id')) {
                                                     //find woocommerce shop page
                                                     $results_url = home_url("?post_type=product");
                                                     $searchform->query()->remove_permalink_filters();
                                                     if (get_option('permalink_structure')) {
                                                         $results_url = get_permalink(woocommerce_get_page_id('shop'));
                                                     }
                                                     $searchform->query()->add_permalink_filters();
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 if ($results_url != "") {
                                     if (has_filter('sf_results_url')) {
                                         $results_url = apply_filters('sf_results_url', $results_url, $base_form_id);
                                     }
                                     $form_attr .= ' data-results-url="' . $results_url . '"';
                                 }
                                 if ($use_ajax && $ajax_url != "") {
                                     if (has_filter('sf_ajax_results_url')) {
                                         $ajax_url = apply_filters('sf_ajax_results_url', $ajax_url, $base_form_id);
                                     }
                                     $form_attr .= ' data-ajax-url="' . $ajax_url . '"';
                                 }
                                 $ajax_form_url = home_url("?sfid=" . $base_form_id . "&sf_action=get_form");
                                 if ($ajax_form_url != "") {
                                     if (has_filter('sf_ajax_form_url')) {
                                         $ajax_form_url = apply_filters('sf_ajax_form_url', $ajax_form_url, $base_form_id);
                                     }
                                     $form_attr .= ' data-ajax-form-url="' . $ajax_form_url . '"';
                                 }
                                 $form_attr .= ' data-use-history-api="' . (int) $use_history_api . '"';
                                 $form_attr .= ' data-template-loaded="' . (int) $this->is_template_loaded . '"';
                                 $lang_code = "";
                                 if (Search_Filter_Helper::has_wpml()) {
                                     $lang_code = ICL_LANGUAGE_CODE;
                                 }
                                 $form_attr .= ' data-lang-code="' . $lang_code . '"';
                                 $form_attr .= ' data-ajax="' . (int) $use_ajax . '"';
                                 if ($use_ajax) {
                                     if ($ajax_target != "") {
                                         $form_attr .= ' data-ajax-target="' . $ajax_target . '"';
                                     }
                                     if ($ajax_links_selector != "") {
                                         $form_attr .= ' data-ajax-links-selector="' . $ajax_links_selector . '"';
                                     }
                                     if ($update_ajax_url != "") {
                                         $form_attr .= ' data-update-ajax-url="' . $update_ajax_url . '"';
                                     }
                                     if ($only_results_ajax != "") {
                                         $form_attr .= ' data-only-results-ajax="' . $only_results_ajax . '"';
                                     }
                                     if ($scroll_to_pos != "") {
                                         $form_attr .= ' data-scroll-to-pos="' . $scroll_to_pos . '"';
                                         if ($scroll_to_pos == "custom") {
                                             if ($custom_scroll_to != "") {
                                                 $form_attr .= ' data-custom-scroll-to="' . $custom_scroll_to . '"';
                                             }
                                         }
                                     }
                                     if ($scroll_on_action != "") {
                                         $form_attr .= ' data-scroll-on-action="' . $scroll_on_action . '"';
                                     }
                                 }
                                 $form_attr .= ' data-auto-update="' . $ajax_auto_submit . '"';
                                 if ($auto_count == 1) {
                                     $form_attr .= ' data-auto-count="' . esc_attr($auto_count) . '"';
                                     if ($auto_count_refresh_mode == 1) {
                                         $form_attr .= ' data-auto-count-refresh-mode="' . esc_attr($auto_count_refresh_mode) . '"';
                                     }
                                 }
                                 $returnvar .= '<form action="' . $results_url . '" method="post" class="searchandfilter' . $addclass . '"' . $form_attr . ' id="search-filter-form-' . $base_form_id . '" autocomplete="off">';
                                 $returnvar .= "<ul>";
                                 $this->fields = new Search_Filter_Fields($this->plugin_slug, $base_form_id);
                                 //loop through each field and grab html
                                 foreach ($fields as $field) {
                                     $returnvar .= $this->get_field($field, $post_types, $base_form_id);
                                 }
                                 $returnvar .= "</ul>";
                                 $returnvar .= "</form>";
                             }
                         }
                     } else {
                         if ($show == "results") {
                             /* legacy */
                             if ($searchform->settings('use_results_shortcode') == 1) {
                                 $display_results_as = "shortcode";
                             } else {
                                 $display_results_as = "archive";
                             }
                             /* end legacy */
                             if ($searchform->settings('display_results_as') != "") {
                                 $display_results_as = $searchform->settings('display_results_as');
                             }
                             if ($display_results_as == "shortcode") {
                                 $returnvar = $this->display_results->output_results($base_form_id, $settings);
                             } else {
                                 if (current_user_can('edit_posts')) {
                                     $returnvar = __("<p><strong>Notice:</strong> This Search Form has not been configured to use a shortcode. <a href='" . get_edit_post_link($base_form_id) . "'>Edit settings</a>.</p>", $this->plugin_slug);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $returnvar;
 }
 function lang_object_ids($ids_array, $type)
 {
     if (Search_Filter_Helper::has_wpml()) {
         $res = array();
         foreach ($ids_array as $id) {
             $xlat = Search_Filter_Helper::wpml_object_id($id, $type, false);
             if (!is_null($xlat)) {
                 $res[] = $xlat;
             }
         }
         return $res;
     } else {
         return $ids_array;
     }
 }