PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / elementor-elements / views / wdk-search.php

wdk-search.php in WP Directory Kit 1.5.9, at elementor-elements/views/wdk-search.php

271 lines 13.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The template for Element Listings Search Form.
4 * This is the template that elementor element, fields, search form
5 *
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 ?>
13
14 <?php
15 global $wdk_button_search_defined;
16 $wdk_button_search_defined=false;
17
18 global $wdk_enable_search_fields_toggle;
19 $wdk_enable_search_fields_toggle = true;
20
21 global $wdk_text_search_button;
22 $wdk_text_search_button = esc_html(wmvc_show_data('text_search_button', $settings));
23
24 global $wdk_text_reset_button;
25 $wdk_text_reset_button = esc_html(wmvc_show_data('text_reset_button', $settings));
26
27 global $wdk_text_more_button;
28 $wdk_text_more_button = esc_html(wmvc_show_data('text_more_button', $settings));
29
30 $current_url = '';
31
32 $results_page = wmvc_show_data('conf_link', $settings);
33
34 if(!is_array($results_page) && !empty($results_page)) {
35 //$results_page = get_permalink($results_page);
36 } else {
37 //$results_page = get_permalink(wdk_get_option('wdk_results_page'));
38
39 $results_page = wdk_get_option('wdk_results_page');
40
41 if (!wdk_get_option('wdk_is_results_page_require')) {
42 $obj_id = get_queried_object_id();
43 $current_url = get_permalink( $obj_id );
44 }
45 }
46
47 //get translation page
48 if(function_exists('PLL'))
49 {
50 $results_page = pll_get_post($results_page);
51 }
52 $results_page_id = $results_page;
53 $results_page = get_permalink($results_page);
54
55 $form_opened = '';
56 if(isset($_GET['wdk_search_additional_opened']) && wmvc_xss_clean($_GET['wdk_search_additional_opened']) == 1) {
57 $form_opened = 'open-form';
58 }
59 ?>
60
61 <div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element);?>">
62 <div class="wdk-search layout_<?php echo esc_attr(wmvc_show_data('design_layout', $settings));?>
63 <?php if
64 (
65 wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_ajax_results') &&
66 isset($settings['is_ajax_enable']) && $settings['is_ajax_enable'] == 'yes'
67 && $results_page_id == get_queried_object_id()
68 ):?>
69 ajax_results_enabled
70 <?php endif;?>
71 <?php if
72 (
73 isset($settings['section_more_before_buttons']) && $settings['section_more_before_buttons'] == 'yes'
74 ):?>
75 section_more_before_buttons
76 <?php endif;?>
77
78 <?php if
79 (
80 isset($settings['ai_search_enable']) && $settings['ai_search_enable'] == 'yes'
81 ):?>
82 ai_search_enable
83 <?php endif;?>
84
85 wdk-form-additional
86 ">
87 <form data-current-link="<?php echo esc_url($current_url);?>" data-scrollto="<?php echo esc_attr(wmvc_show_data('search_scroll', $settings));?>" class="wdk-search-form wdk-skip-empty
88 <?php if(wmvc_show_data('auto_search_enable', $settings) == 'yes'):?> auto_search <?php endif;?>
89 <?php echo esc_html($form_opened);?> <?php if(!wdk_get_option('wdk_results_page')):?> wdk-result-page-notdefined <?php endif;?>" action="<?php echo esc_url($results_page);?>">
90 <?php
91 $field_id = $tab_field ;
92 $field_values = wdk_field_option ($field_id, 'values_list');
93 $values = array();
94 if(!empty($field_values)){
95 $values = explode(',', $field_values);
96 }
97 $field_value = false;
98 if(isset($_GET['field_'.$field_id])) {
99 $field_value = sanitize_text_field(wp_unslash($_GET['field_'.$field_id]));
100 }
101
102 ?>
103 <?php if(!empty( $values )):?>
104 <div class="wdk-search-tabs">
105 <input type="radio" name="field_<?php echo esc_attr($field_id);?>" id="wdk_tab_field_any" value="" <?php if(empty($field_value)):?>checked="checked"<?php endif;?>>
106 <label for="wdk_tab_field_any">
107 <?php echo esc_html__('Any', 'wpdirectorykit');?>
108 </label>
109 <?php foreach ($values as $key => $value):?>
110 <?php if(empty($value)) continue;?>
111 <input type="radio" name="field_<?php echo esc_attr($field_id);?>" id="<?php echo esc_attr($id_element);?>_wdk_tab_field_<?php echo esc_attr($key);?>" value="<?php echo esc_attr($value);?>" <?php if($field_value == $value):?>checked="checked"<?php endif;?>>
112 <label for="<?php echo esc_attr($id_element);?>_wdk_tab_field_<?php echo esc_attr($key);?>"><?php echo esc_html($value);?>
113 <?php if(wmvc_show_data('tabs_count', $settings) == 'yes'):?>
114 <span class="tab_count"><?php echo esc_html(wmvc_show_data($value, $this->data['counts'][$field_id], 0));?></span>
115 <?php endif;?>
116 </label>
117 <?php endforeach;?>
118 </div>
119 <script>
120 jQuery(document).ready(function(){
121 jQuery('.wdk_search_field_<?php echo esc_attr($field_id);?>').remove();
122 });
123 </script>
124 <?php endif;?>
125
126 <?php if(wmvc_user_in_role('administrator') || current_user_can('wdk_listings_manage')):?>
127 <div class="section-widget-control">
128 <a class="wdk-c-btn wdk-c-edit" href="<?php echo esc_url(admin_url('admin.php?page=wdk_searchform'));?>" title="<?php echo esc_attr_e('Edit search form', 'wpdirectorykit'); ?>" target="_blank"><span class="dashicons dashicons-edit"></span></a>
129 </div>
130 <?php endif;?>
131 <div class="wdk-row">
132 <?php if(wmvc_show_data('enable_custom_fields', $settings) == 'yes'):?>
133 <?php wdk_generate_search_form_fields_elementor(wmvc_show_data('custom_fields', $settings), '', TRUE, $predefields_query); ?>
134 <?php else:?>
135 <?php wdk_generate_search_form(1, '', TRUE, $predefields_query); ?>
136 <?php endif;?>
137
138 <?php if(!$wdk_button_search_defined): ?>
139 <div class="wdk-col wdk-col-btns">
140 <div class="wdk-field wdk-field-btn">
141 <?php if(wmvc_show_data('enable_custom_fields', $settings) != 'yes'):?>
142 <div class="wdk-field-group wdk-field-group-additional">
143 <button id="wdk-search-additional" type="button" class="wdk-search-additional-btn"><?php echo esc_html($wdk_text_more_button); ?><i class="wdk-toggle-icon"></i></button>
144 <input type='checkbox' style="display: none !important" value='1' <?php if(isset($_GET['wdk_search_additional_opened']) && wmvc_xss_clean($_GET['wdk_search_additional_opened']) == 1):?> checked <?php endif;?> name='wdk_search_additional_opened' />
145 </div>
146 <?php endif;?>
147 <div class="wdk-field-group wdk-field-group-reset">
148 <button title="<?php echo esc_attr__('Reset','wpdirectorykit');?>" id="wdk-start-primary" type="reset" class="wdk-search-start wdk-search-reset wdk-click-load-animation">&nbsp;&nbsp;<?php echo esc_html(wmvc_show_data('text_reset_button', $settings)); ?>&nbsp;<i class="fa fa-spinner fa-spin fa-ajax-indicator" style="display: none;"></i>&nbsp;</button>
149 </div>
150 <div class="wdk-field-group wdk-field-group-search">
151 <button title="<?php echo esc_attr__('Search','wpdirectorykit');?>" id="wdk-start-primary" type="submit" class="wdk-search-start wdk-click-load-animation">
152 <?php if(wmvc_show_data('field_button_icon_position', $settings) == 'left') :?>
153 <?php \Elementor\Icons_Manager::render_icon( $settings['field_button_icon'], [ 'aria-hidden' => 'true', "class"=>'icon_search' ] ); ?>
154 <?php endif;?>
155 &nbsp;&nbsp;<?php echo esc_html(wmvc_show_data('text_search_button', $settings)); ?>
156 <?php if(wmvc_show_data('field_button_icon_position', $settings) == 'right') :?>
157 <?php \Elementor\Icons_Manager::render_icon( $settings['field_button_icon'], [ 'aria-hidden' => 'true', "class"=>'icon_search' ] ); ?>
158 <?php endif;?>
159 &nbsp;<i class="fa fa-spinner fa-spin fa-ajax-indicator" style="display: none;"></i>&nbsp;
160 </button>
161
162 <?php if(function_exists('run_wdk_save_search') && wdk_get_option('wdk_save_search_show_on_searchform')):?>
163 <div class="section-widget-control right">
164 <a class="wdk-c-btn wdk-c-edit wdk-save-search-button" href="#" data-url="<?php echo esc_url(admin_url('admin-ajax.php')); ?>" title="<?php echo esc_attr_e('Save Search', 'wpdirectorykit'); ?>" target="_blank">
165 <i class="fas fa-save" aria-hidden="true"></i>
166 <i class="fa fa-spinner fa-spin fa-ajax-indicator"></i>
167 </a>
168 </div>
169 <?php endif;?>
170 </div>
171 </div>
172 </div>
173 <?php else: ?>
174 </div>
175 </div>
176 <?php endif; ?>
177 </div>
178 </form>
179 </div>
180 <script>
181 jQuery(document).ready(function($) {
182 jQuery('#wdk_el_<?php echo esc_html($id_element);?> #wdk-search-additional').on('click', function (e) {
183 e.preventDefault();
184 if (jQuery('#wdk_el_<?php echo esc_html($id_element);?> #wdk-form-additional').length) {
185 var addition = jQuery('#wdk_el_<?php echo esc_html($id_element);?> #wdk-form-additional');
186 var form = jQuery(this).closest('.wdk-search-form ');
187 form.toggleClass('open-form');
188 if (form.hasClass('open-form')) {
189 form.find("[name='wdk_search_additional_opened']").prop('checked', 'checked');
190 addition.slideDown();
191 } else {
192 addition.slideUp();
193 form.find("[name='wdk_search_additional_opened']").prop('checked', false);
194 }
195 }
196 })
197
198 jQuery("form.wdk-result-page-notdefined").on('submit', function() {
199 wdk_log_notify('<?php echo esc_js(__('Results page not found, please configure results page', 'wpdirectorykit')); ?>', 'error');
200 return false;
201 });
202
203 const search_highlight = (elem) =>
204 {
205 if(elem.is('select'))
206 {
207 if(elem.val() == '' || elem.val() == 0 || elem.val() == null)
208 {
209 // remove selector class
210 elem.closest('.select-item').removeClass('sel_class');
211 elem.parent().removeClass('sel_class');
212 elem.removeClass('sel_class');
213 }
214 else
215 {
216 // add selector class
217 elem.closest('.select-item').addClass('sel_class');
218 elem.parent().addClass('sel_class');
219 elem.addClass('sel_class');
220 }
221 }
222 else if(elem.attr('type') == 'text')
223 {
224 if(elem.parent().find('.wdk_dropdown_tree').length > 0) // For treefield
225 {
226 if(elem.val() != '' && elem.val() != null)
227 {
228 // add selector class
229 elem.closest('.wdk_dropdown_tree_style').find('.wdk_dropdown_tree').addClass('sel_class');
230 elem.parent().find('.btn-group:first-child').addClass('sel_class');
231 }
232 else
233 {
234 // remove selector class
235 elem.closest('.wdk_dropdown_tree_style').find('.wdk_dropdown_tree').removeClass('sel_class');
236 elem.parent().find('.btn-group:first-child').removeClass('sel_class');
237 }
238 }
239 else // For basic input
240 {
241 if(elem.val() != '' && elem.val() != null)
242 {
243 // add selector class
244 elem.addClass('sel_class');
245 }
246 else
247 {
248 // remove selector class
249 elem.removeClass('sel_class');
250 }
251 }
252 }
253 }
254
255 // On change value, change field style
256 jQuery('#wdk_el_<?php echo esc_html($id_element);?>').find('input, select').each(function(i)
257 {
258 jQuery(this).on('change', function(){search_highlight(jQuery(this))});
259 search_highlight(jQuery(this));
260 })
261 <?php if($is_edit_mode):?>
262 wdk_select_init();
263
264 if(typeof $.fn.fieldSliderRange == 'function' && typeof $.fn.ionRangeSlider == 'function') {
265 jQuery('.wdk-slider-range-field').fieldSliderRange();
266 }
267 <?php endif;?>
268 });
269 </script>
270 </div>
271