| @@ -20,8 +20,11 @@ | ||
| 20 | 20 | |
| 21 | 21 | global $wdk_text_search_button; |
| 22 | 22 | $wdk_text_search_button = esc_html(wmvc_show_data('text_search_button', $settings)); |
| 23 | 23 | |
| 24 | +global $wdk_text_reset_button; | |
| 25 | +$wdk_text_reset_button = esc_html(wmvc_show_data('text_reset_button', $settings)); | |
| 26 | + | |
| 24 | 27 | global $wdk_text_more_button; |
| 25 | 28 | $wdk_text_more_button = esc_html(wmvc_show_data('text_more_button', $settings)); |
| 26 | 29 | |
| 27 | 30 | $current_url = ''; |
| @@ -26,13 +29,16 @@ | ||
| 26 | 29 | |
| 27 | 30 | $current_url = ''; |
| 28 | 31 | |
| 29 | 32 | $results_page = wmvc_show_data('conf_link', $settings); |
| 33 | + | |
| 30 | 34 | if(!is_array($results_page) && !empty($results_page)) { |
| 31 | - $results_page = get_permalink($results_page); | |
| 35 | + //$results_page = get_permalink($results_page); | |
| 32 | 36 | } else { |
| 33 | - $results_page = get_permalink(wdk_get_option('wdk_results_page')); | |
| 37 | + //$results_page = get_permalink(wdk_get_option('wdk_results_page')); | |
| 34 | 38 | |
| 39 | + $results_page = wdk_get_option('wdk_results_page'); | |
| 40 | + | |
| 35 | 41 | if (!wdk_get_option('wdk_is_results_page_require')) { |
| 36 | 42 | $obj_id = get_queried_object_id(); |
| 37 | 43 | $current_url = get_permalink( $obj_id ); |
| 38 | 44 | } |
| @@ -37,19 +43,51 @@ | ||
| 37 | 43 | $current_url = get_permalink( $obj_id ); |
| 38 | 44 | } |
| 39 | 45 | } |
| 40 | 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 | + | |
| 41 | 55 | $form_opened = ''; |
| 42 | 56 | if(isset($_GET['wdk_search_additional_opened']) && wmvc_xss_clean($_GET['wdk_search_additional_opened']) == 1) { |
| 43 | 57 | $form_opened = 'open-form'; |
| 44 | 58 | } |
| 45 | - | |
| 46 | 59 | ?> |
| 47 | 60 | |
| 48 | 61 | <div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element);?>"> |
| 49 | - <div class="wdk-search layout_<?php echo esc_attr(wmvc_show_data('design_layout', $settings));?>"> | |
| 50 | - <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 <?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);?>"> | |
| 51 | - | |
| 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);?>"> | |
| 52 | 90 | <?php |
| 53 | 91 | $field_id = $tab_field ; |
| 54 | 92 | $field_values = wdk_field_option ($field_id, 'values_list'); |
| 55 | 93 | $values = array(); |
| @@ -57,9 +95,9 @@ | ||
| 57 | 95 | $values = explode(',', $field_values); |
| 58 | 96 | } |
| 59 | 97 | $field_value = false; |
| 60 | 98 | if(isset($_GET['field_'.$field_id])) { |
| 61 | - $field_value = sanitize_text_field($_GET['field_'.$field_id]); | |
| 99 | + $field_value = sanitize_text_field(wp_unslash($_GET['field_'.$field_id])); | |
| 62 | 100 | } |
| 63 | 101 | |
| 64 | 102 | ?> |
| 65 | 103 | <?php if(!empty( $values )):?> |
| @@ -64,13 +102,19 @@ | ||
| 64 | 102 | ?> |
| 65 | 103 | <?php if(!empty( $values )):?> |
| 66 | 104 | <div class="wdk-search-tabs"> |
| 67 | 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;?>> |
| 68 | - <label for="wdk_tab_field_any"><?php echo esc_html__('Any', 'wpdirectorykit');?></label> | |
| 106 | + <label for="wdk_tab_field_any"> | |
| 107 | + <?php echo esc_html__('Any', 'wpdirectorykit');?> | |
| 108 | + </label> | |
| 69 | 109 | <?php foreach ($values as $key => $value):?> |
| 70 | 110 | <?php if(empty($value)) continue;?> |
| 71 | - <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;?>> | |
| 72 | - <label for="<?php echo esc_html($id_element);?>_wdk_tab_field_<?php echo esc_attr($key);?>"><?php echo esc_html($value);?></label> | |
| 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> | |
| 73 | 117 | <?php endforeach;?> |
| 74 | 118 | </div> |
| 75 | 119 | <script> |
| 76 | 120 | jQuery(document).ready(function(){ |
| @@ -78,50 +122,69 @@ | ||
| 78 | 122 | }); |
| 79 | 123 | </script> |
| 80 | 124 | <?php endif;?> |
| 81 | 125 | |
| 82 | - <?php if(wmvc_user_in_role('administrator')):?> | |
| 126 | + <?php if(wmvc_user_in_role('administrator') || current_user_can('wdk_listings_manage')):?> | |
| 83 | 127 | <div class="section-widget-control"> |
| 84 | - <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> | |
| 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> | |
| 85 | 129 | </div> |
| 86 | 130 | <?php endif;?> |
| 87 | 131 | <div class="wdk-row"> |
| 88 | - <?php wdk_generate_search_form(1, '', TRUE, $predefields_query); ?> | |
| 89 | - <?php if(!$wdk_button_search_defined): ?> | |
| 90 | - <div class="wdk-col wdk-col-btns"> | |
| 91 | - <div class="wdk-field wdk-field-btn"> | |
| 92 | - <div class="wdk-field-group wdk-field-group-reset"> | |
| 93 | - <button id="wdk-start-primary" type="submit" class="wdk-search-start wdk-search-reset wdk-click-load-animation"> <?php echo esc_html(wmvc_show_data('text_search_button', $settings)); ?> <i class="fa fa-spinner fa-spin fa-ajax-indicator" style="display: none;"></i> </button> | |
| 94 | - </div> | |
| 95 | - </div> | |
| 96 | - <div class="wdk-field wdk-field-btn"> | |
| 97 | - <div class="wdk-field-group"> | |
| 98 | - <button id="wdk-start-primary" type="submit" class="wdk-search-start wdk-click-load-animation"> <?php echo esc_html(wmvc_show_data('text_search_button', $settings)); ?> <i class="fa fa-spinner fa-spin fa-ajax-indicator" style="display: none;"></i> </button> | |
| 99 | - <?php if(function_exists('run_wdk_save_search') && wdk_get_option('wdk_save_search_show_on_searchform')):?> | |
| 100 | - <div class="section-widget-control right"> | |
| 101 | - <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"> | |
| 102 | - <i class="fas fa-save" aria-hidden="true"></i> | |
| 103 | - <i class="fa fa-spinner fa-spin fa-ajax-indicator"></i> | |
| 104 | - </a> | |
| 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"> <?php echo esc_html(wmvc_show_data('text_reset_button', $settings)); ?> <i class="fa fa-spinner fa-spin fa-ajax-indicator" style="display: none;"></i> </button> | |
| 105 | 149 | </div> |
| 106 | - <?php endif;?> | |
| 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 | + <?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 | + <i class="fa fa-spinner fa-spin fa-ajax-indicator" style="display: none;"></i> | |
| 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> | |
| 107 | 171 | </div> |
| 108 | 172 | </div> |
| 173 | + <?php else: ?> | |
| 109 | 174 | </div> |
| 110 | - <?php else: ?> | |
| 111 | 175 | </div> |
| 112 | - </div> | |
| 113 | - <?php endif; ?> | |
| 176 | + <?php endif; ?> | |
| 114 | 177 | </div> |
| 115 | 178 | </form> |
| 116 | 179 | </div> |
| 117 | - <script> | |
| 180 | + <script> | |
| 118 | 181 | jQuery(document).ready(function($) { |
| 119 | - $('#wdk_el_<?php echo esc_html($id_element);?> #wdk-search-additional').on('click', function (e) { | |
| 182 | + jQuery('#wdk_el_<?php echo esc_html($id_element);?> #wdk-search-additional').on('click', function (e) { | |
| 120 | 183 | e.preventDefault(); |
| 121 | - if ($('#wdk_el_<?php echo esc_html($id_element);?> #wdk-form-additional').length) { | |
| 122 | - var addition = $('#wdk_el_<?php echo esc_html($id_element);?> #wdk-form-additional'); | |
| 123 | - var form = $(this).closest('.wdk-search-form '); | |
| 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 '); | |
| 124 | 187 | form.toggleClass('open-form'); |
| 125 | 188 | if (form.hasClass('open-form')) { |
| 126 | 189 | form.find("[name='wdk_search_additional_opened']").prop('checked', 'checked'); |
| 127 | 190 | addition.slideDown(); |
| @@ -131,9 +194,9 @@ | ||
| 131 | 194 | } |
| 132 | 195 | } |
| 133 | 196 | }) |
| 134 | 197 | |
| 135 | - $("form.wdk-result-page-notdefined").on('submit', function() { | |
| 198 | + jQuery("form.wdk-result-page-notdefined").on('submit', function() { | |
| 136 | 199 | wdk_log_notify('<?php echo esc_js(__('Results page not found, please configure results page', 'wpdirectorykit')); ?>', 'error'); |
| 137 | 200 | return false; |
| 138 | 201 | }); |
| 139 | 202 | |
| @@ -159,9 +222,9 @@ | ||
| 159 | 222 | else if(elem.attr('type') == 'text') |
| 160 | 223 | { |
| 161 | 224 | if(elem.parent().find('.wdk_dropdown_tree').length > 0) // For treefield |
| 162 | 225 | { |
| 163 | - if(elem.val() != '' && elem.val() != 0 && elem.val() != null) | |
| 226 | + if(elem.val() != '' && elem.val() != null) | |
| 164 | 227 | { |
| 165 | 228 | // add selector class |
| 166 | 229 | elem.closest('.wdk_dropdown_tree_style').find('.wdk_dropdown_tree').addClass('sel_class'); |
| 167 | 230 | elem.parent().find('.btn-group:first-child').addClass('sel_class'); |
| @@ -174,9 +237,9 @@ | ||
| 174 | 237 | } |
| 175 | 238 | } |
| 176 | 239 | else // For basic input |
| 177 | 240 | { |
| 178 | - if(elem.val() != '' && elem.val() != 0 && elem.val() != null) | |
| 241 | + if(elem.val() != '' && elem.val() != null) | |
| 179 | 242 | { |
| 180 | 243 | // add selector class |
| 181 | 244 | elem.addClass('sel_class'); |
| 182 | 245 | } |
| @@ -189,18 +252,18 @@ | ||
| 189 | 252 | } |
| 190 | 253 | } |
| 191 | 254 | |
| 192 | 255 | // On change value, change field style |
| 193 | - $('#wdk_el_<?php echo esc_html($id_element);?>').find('input, select').each(function(i) | |
| 256 | + jQuery('#wdk_el_<?php echo esc_html($id_element);?>').find('input, select').each(function(i) | |
| 194 | 257 | { |
| 195 | - $(this).on('change', function(){search_highlight($(this))}); | |
| 196 | - search_highlight($(this)); | |
| 258 | + jQuery(this).on('change', function(){search_highlight(jQuery(this))}); | |
| 259 | + search_highlight(jQuery(this)); | |
| 197 | 260 | }) |
| 198 | 261 | <?php if($is_edit_mode):?> |
| 199 | 262 | wdk_select_init(); |
| 200 | 263 | |
| 201 | 264 | if(typeof $.fn.fieldSliderRange == 'function' && typeof $.fn.ionRangeSlider == 'function') { |
| 202 | - $('.wdk-slider-range-field').fieldSliderRange(); | |
| 265 | + jQuery('.wdk-slider-range-field').fieldSliderRange(); | |
| 203 | 266 | } |
| 204 | 267 | <?php endif;?> |
| 205 | 268 | }); |
| 206 | 269 | </script> |