PluginProbe
WP Directory Kit / 1.3.4
WP Directory Kit v1.3.4
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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / views / wdk-search.php

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

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