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

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