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

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