PluginProbe
WP Directory Kit / 1.5.3
WP Directory Kit v1.5.3
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.3, at elementor-elements/views/wdk-search.php

256 lines 13.3 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 ">
72 <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
73 <?php if(wmvc_show_data('auto_search_enable', $settings) == 'yes'):?> auto_search <?php endif;?>
74 <?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);?>">
75 <?php
76 $field_id = $tab_field ;
77 $field_values = wdk_field_option ($field_id, 'values_list');
78 $values = array();
79 if(!empty($field_values)){
80 $values = explode(',', $field_values);
81 }
82 $field_value = false;
83 if(isset($_GET['field_'.$field_id])) {
84 $field_value = sanitize_text_field($_GET['field_'.$field_id]);
85 }
86
87 ?>
88 <?php if(!empty( $values )):?>
89 <div class="wdk-search-tabs">
90 <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;?>>
91 <label for="wdk_tab_field_any">
92 <?php echo esc_html__('Any', 'wpdirectorykit');?>
93 </label>
94 <?php foreach ($values as $key => $value):?>
95 <?php if(empty($value)) continue;?>
96 <input type="radio" name="field_<?php echo esc_attr($field_id);?>" id="<?php echo esc_html($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;?>>
97 <label for="<?php echo esc_html($id_element);?>_wdk_tab_field_<?php echo esc_attr($key);?>"><?php echo esc_html__($value, 'wpdirectorykit');?>
98 <?php if(wmvc_show_data('tabs_count', $settings) == 'yes'):?>
99 <span class="tab_count"><?php echo esc_html__(wmvc_show_data($value, $this->data['counts'][$field_id], 0), 'wpdirectorykit');?></span>
100 <?php endif;?>
101 </label>
102 <?php endforeach;?>
103 </div>
104 <script>
105 jQuery(document).ready(function(){
106 jQuery('.wdk_search_field_<?php echo esc_attr($field_id);?>').remove();
107 });
108 </script>
109 <?php endif;?>
110
111 <?php if(wmvc_user_in_role('administrator') || current_user_can('wdk_listings_manage')):?>
112 <div class="section-widget-control">
113 <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', 'selio'); ?>" target="_blank"><span class="dashicons dashicons-edit"></span></a>
114 </div>
115 <?php endif;?>
116 <div class="wdk-row">
117 <?php if(wmvc_show_data('enable_custom_fields', $settings) == 'yes'):?>
118 <?php wdk_generate_search_form_fields_elementor(wmvc_show_data('custom_fields', $settings), '', TRUE, $predefields_query); ?>
119 <?php else:?>
120 <?php wdk_generate_search_form(1, '', TRUE, $predefields_query); ?>
121 <?php endif;?>
122
123 <?php if(!$wdk_button_search_defined): ?>
124 <div class="wdk-col wdk-col-btns">
125 <div class="wdk-field wdk-field-btn">
126 <?php if(wmvc_show_data('enable_custom_fields', $settings) != 'yes'):?>
127 <div class="wdk-field-group wdk-field-group-additional">
128 <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>
129 <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' />
130 </div>
131 <?php endif;?>
132 <div class="wdk-field-group wdk-field-group-reset">
133 <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>
134 </div>
135 <div class="wdk-field-group wdk-field-group-search">
136 <button title="<?php echo esc_attr__('Search','wpdirectorykit');?>" id="wdk-start-primary" type="submit" class="wdk-search-start wdk-click-load-animation">
137 <?php if(wmvc_show_data('field_button_icon_position', $settings) == 'left') :?>
138 <?php \Elementor\Icons_Manager::render_icon( $settings['field_button_icon'], [ 'aria-hidden' => 'true', "class"=>'icon_search' ] ); ?>
139 <?php endif;?>
140 &nbsp;&nbsp;<?php echo esc_html(wmvc_show_data('text_search_button', $settings)); ?>
141 <?php if(wmvc_show_data('field_button_icon_position', $settings) == 'right') :?>
142 <?php \Elementor\Icons_Manager::render_icon( $settings['field_button_icon'], [ 'aria-hidden' => 'true', "class"=>'icon_search' ] ); ?>
143 <?php endif;?>
144 &nbsp;<i class="fa fa-spinner fa-spin fa-ajax-indicator" style="display: none;"></i>&nbsp;
145 </button>
146
147 <?php if(function_exists('run_wdk_save_search') && wdk_get_option('wdk_save_search_show_on_searchform')):?>
148 <div class="section-widget-control right">
149 <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', 'selio'); ?>" target="_blank">
150 <i class="fas fa-save" aria-hidden="true"></i>
151 <i class="fa fa-spinner fa-spin fa-ajax-indicator"></i>
152 </a>
153 </div>
154 <?php endif;?>
155 </div>
156 </div>
157 </div>
158 <?php else: ?>
159 </div>
160 </div>
161 <?php endif; ?>
162 </div>
163 </form>
164 </div>
165 <script>
166 jQuery(document).ready(function($) {
167 $('#wdk_el_<?php echo esc_html($id_element);?> #wdk-search-additional').on('click', function (e) {
168 e.preventDefault();
169 if ($('#wdk_el_<?php echo esc_html($id_element);?> #wdk-form-additional').length) {
170 var addition = $('#wdk_el_<?php echo esc_html($id_element);?> #wdk-form-additional');
171 var form = $(this).closest('.wdk-search-form ');
172 form.toggleClass('open-form');
173 if (form.hasClass('open-form')) {
174 form.find("[name='wdk_search_additional_opened']").prop('checked', 'checked');
175 addition.slideDown();
176 } else {
177 addition.slideUp();
178 form.find("[name='wdk_search_additional_opened']").prop('checked', false);
179 }
180 }
181 })
182
183 $("form.wdk-result-page-notdefined").on('submit', function() {
184 wdk_log_notify('<?php echo esc_js(__('Results page not found, please configure results page', 'wpdirectorykit')); ?>', 'error');
185 return false;
186 });
187
188 const search_highlight = (elem) =>
189 {
190 if(elem.is('select'))
191 {
192 if(elem.val() == '' || elem.val() == 0 || elem.val() == null)
193 {
194 // remove selector class
195 elem.closest('.select-item').removeClass('sel_class');
196 elem.parent().removeClass('sel_class');
197 elem.removeClass('sel_class');
198 }
199 else
200 {
201 // add selector class
202 elem.closest('.select-item').addClass('sel_class');
203 elem.parent().addClass('sel_class');
204 elem.addClass('sel_class');
205 }
206 }
207 else if(elem.attr('type') == 'text')
208 {
209 if(elem.parent().find('.wdk_dropdown_tree').length > 0) // For treefield
210 {
211 if(elem.val() != '' && elem.val() != null)
212 {
213 // add selector class
214 elem.closest('.wdk_dropdown_tree_style').find('.wdk_dropdown_tree').addClass('sel_class');
215 elem.parent().find('.btn-group:first-child').addClass('sel_class');
216 }
217 else
218 {
219 // remove selector class
220 elem.closest('.wdk_dropdown_tree_style').find('.wdk_dropdown_tree').removeClass('sel_class');
221 elem.parent().find('.btn-group:first-child').removeClass('sel_class');
222 }
223 }
224 else // For basic input
225 {
226 if(elem.val() != '' && elem.val() != null)
227 {
228 // add selector class
229 elem.addClass('sel_class');
230 }
231 else
232 {
233 // remove selector class
234 elem.removeClass('sel_class');
235 }
236 }
237 }
238 }
239
240 // On change value, change field style
241 $('#wdk_el_<?php echo esc_html($id_element);?>').find('input, select').each(function(i)
242 {
243 $(this).on('change', function(){search_highlight($(this))});
244 search_highlight($(this));
245 })
246 <?php if($is_edit_mode):?>
247 wdk_select_init();
248
249 if(typeof $.fn.fieldSliderRange == 'function' && typeof $.fn.ionRangeSlider == 'function') {
250 $('.wdk-slider-range-field').fieldSliderRange();
251 }
252 <?php endif;?>
253 });
254 </script>
255 </div>
256