PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.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
← All changes | elementor-elements/classes/wdk-search.php +166 -47 1.3.0 → 1.5.9 View file →
@@ -29,8 +29,9 @@
29 29 \Elementor\Controls_Manager::add_tab(
30 30 'tab_conf',
31 31 esc_html__('Settings', 'wpdirectorykit')
32 32 );
33 +
33 34
34 35 \Elementor\Controls_Manager::add_tab(
35 36 'tab_layout',
36 37 esc_html__('Layout', 'wpdirectorykit')
@@ -120,11 +121,11 @@
120 121 $this->data['id_element'] = $this->get_id();
121 122 $this->data['settings'] = $this->get_settings();
122 123 $this->data['counts'] = array();
123 124
124 - wp_enqueue_script('select2');
125 + wp_enqueue_script('select2-select2');
125 126 wp_enqueue_script('wdk-select2');
126 - wp_enqueue_style('select2');
127 + wp_enqueue_style('select2-select2');
127 128 global $wdk_visible_filters_limit;
128 129 global $wdk_enable_search_fields_toggle;
129 130
130 131 global $wdk_search_fields_toggle_reset;
@@ -129,10 +130,12 @@
129 130
130 131 global $wdk_search_fields_toggle_reset;
131 132 $wdk_search_fields_toggle_reset = true;
132 133
133 - if($this->data['settings']['section_config_more'])
134 - $wdk_enable_search_fields_toggle = true;
134 + if(isset($this->data['settings']['section_config_more'])){
135 + if($this->data['settings']['section_config_more'])
136 + $wdk_enable_search_fields_toggle = true;
137 + }
135 138
136 139 if(!empty($this->data['settings']['section_config_more_limit'])) {
137 140 $wdk_visible_filters_limit = $this->data['settings']['section_config_more_limit'] + 1;
138 141 } else {
@@ -137,8 +140,9 @@
137 140 $wdk_visible_filters_limit = $this->data['settings']['section_config_more_limit'] + 1;
138 141 } else {
139 142 $wdk_visible_filters_limit = 0;
140 143 }
144 +
141 145 $this->data['tab_field'] = NULL;
142 146
143 147 if(!empty($this->data['settings']['tab_field'])) {
144 148 $this->data['tab_field'] = substr($this->data['settings']['tab_field'], strpos($this->data['settings']['tab_field'],'__')+2);
@@ -149,15 +153,25 @@
149 153 parse_str($qr_string, $string_par);
150 154 $this->data['predefields_query'] = array_map('trim', $string_par);
151 155
152 156 if(!empty($this->data['settings']['custom_category_root'])) {
153 - $this->data['predefields_query']['custom_category_root'] =
154 - substr($this->data['settings']['custom_category_root'], strpos($this->data['settings']['custom_category_root'],'__')+2);
157 +
158 + if(!empty($this->data['settings']['field_id']) && strpos($this->data['settings']['field_id'],'__') !== FALSE){
159 + $this->data['settings']['custom_category_root'] = substr($this->data['settings']['custom_category_root'], strpos($this->data['settings']['custom_category_root'],'__')+2);
160 + }
161 + if(is_intval($this->data['settings']['custom_category_root'])) {
162 + $this->data['predefields_query']['custom_category_root'] = $this->data['settings']['custom_category_root'];
163 + }
155 164 }
156 165
157 166 if(!empty($this->data['settings']['custom_location_root'])) {
158 - $this->data['predefields_query']['custom_location_root'] =
159 - substr($this->data['settings']['custom_location_root'], strpos($this->data['settings']['custom_location_root'],'__')+2);
167 + if(strpos($this->data['settings']['field_id'],'__') !== FALSE){
168 + $this->data['settings']['custom_location_root'] = substr($this->data['settings']['custom_location_root'], strpos($this->data['settings']['custom_location_root'],'__')+2);
169 + }
170 +
171 + if(is_intval($this->data['settings']['custom_location_root'])) {
172 + $this->data['predefields_query']['custom_location_root'] = $this->data['settings']['custom_location_root'];
173 + }
160 174 }
161 175
162 176 $this->data['is_edit_mode'] = false;
163 177 if(Plugin::$instance->editor->is_edit_mode()) {
@@ -182,9 +196,9 @@
182 196 }
183 197 }
184 198
185 199
186 - echo $this->view('wdk-search', $this->data);
200 + $this->view('wdk-search', $this->data, true);
187 201 }
188 202
189 203
190 204 private function generate_controls_conf() {
@@ -221,9 +235,22 @@
221 235 'default' => '',
222 236 ]
223 237 );
224 238
239 +
225 240 $this->add_control(
241 + 'ai_search_enable',
242 + [
243 + 'label' => __( 'AI Search Enable', 'wpdirectorykit' ),
244 + 'type' => Controls_Manager::SWITCHER,
245 + 'label_on' => __( 'Show', 'wpdirectorykit' ),
246 + 'label_off' => __( 'Hide', 'wpdirectorykit' ),
247 + 'return_value' => 'yes',
248 + 'default' => '',
249 + ]
250 + );
251 +
252 + $this->add_control(
226 253 'section_config_more',
227 254 [
228 255 'label' => __( 'Field more hide', 'wpdirectorykit' ),
229 256 'type' => Controls_Manager::SWITCHER,
@@ -235,8 +262,20 @@
235 262 '{{WRAPPER}} .wdk-field-group-additional' => 'display: {{VALUE}};',
236 263 ],
237 264 ]
238 265 );
266 +
267 + $this->add_control(
268 + 'section_more_before_buttons',
269 + [
270 + 'label' => __( 'Show Additional Fields Before Search Buttons', 'wpdirectorykit' ),
271 + 'type' => Controls_Manager::SWITCHER,
272 + 'label_on' => __( 'Yes', 'wpdirectorykit' ),
273 + 'label_off' => __( 'None', 'wpdirectorykit' ),
274 + 'return_value' => 'yes',
275 + 'default' => '',
276 + ]
277 + );
239 278
240 279 $this->add_control(
241 280 'section_config_more_limit',
242 281 [
@@ -257,9 +296,9 @@
257 296 $this->add_control(
258 297 'conf_link',
259 298 [
260 299 'label' => __( 'Open results on page', 'wpdirectorykit' ),
261 - 'type' => \Elementor\Controls_Manager::SELECT,
300 + 'type' => \Elementor\Controls_Manager::SELECT2,
262 301 'default' => '',
263 302 'options' => $pages
264 303 ]
265 304 );
@@ -293,9 +332,9 @@
293 332
294 333 $this->add_control(
295 334 'field_button_icon',
296 335 [
297 - 'label' => __( 'Icon', 'text-domain' ),
336 + 'label' => __( 'Icon', 'wpdirectorykit' ),
298 337 'type' => Controls_Manager::ICONS,
299 338 ]
300 339 );
301 340
@@ -301,13 +340,13 @@
301 340
302 341 $this->add_control(
303 342 'field_button_icon_position',
304 343 [
305 - 'label' => esc_html__('icon Position', 'wdk-compare-listing'),
344 + 'label' => esc_html__('icon Position', 'wpdirectorykit'),
306 345 'type' => Controls_Manager::SELECT,
307 346 'options' => [
308 - 'left' => esc_html__('Left', 'wdk-compare-listing'),
309 - 'right' => esc_html__('Right', 'wdk-compare-listing'),
347 + 'left' => esc_html__('Left', 'wpdirectorykit'),
348 + 'right' => esc_html__('Right', 'wpdirectorykit'),
310 349 ],
311 350 'default' => 'left',
312 351 ]
313 352 );
@@ -335,16 +374,27 @@
335 374 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
336 375 $order_i = 0;
337 376 foreach($fields as $field)
338 377 {
339 - $fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field);
378 + $fields_list[wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field);
340 379 }
380 +
381 + // build raw_options preserving order
382 + $raw = [];
383 + foreach ( $fields_list as $k => $v ) {
384 + $raw[] = [
385 + 'value' => (string) $k,
386 + 'label' => $v,
387 + ];
388 + }
389 +
341 390 $this->add_control(
342 391 'tab_field',
343 392 [
344 393 'label' => __( 'Tab', 'wpdirectorykit' ),
345 - 'type' => Controls_Manager::SELECT,
394 + 'type' => \Wdk\Includes\Controls\Wdk_Field_Selector::INIT,
346 395 'options' => $fields_list,
396 + 'raw_options' => $raw,
347 397 'default' => 'results',
348 398 ]
349 399 );
350 400
@@ -364,8 +414,9 @@
364 414 'important_note',
365 415 [
366 416 'label' => '',
367 417 'type' => \Elementor\Controls_Manager::RAW_HTML,
418 + /* translators: 1: URL. */
368 419 'raw' => wdk_sprintf(__( 'Manage Search Form <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_searchform')),
369 420 'content_classes' => 'wdk_elementor_hint',
370 421 'separator' => 'after',
371 422 ]
@@ -389,39 +440,36 @@
389 440 $WMVC->model('category_m');
390 441 $WMVC->model('location_m');
391 442 $categories_data = $WMVC->category_m->get_by(array('(parent_id = 0 OR parent_id IS NULL)' => NULL));
392 443 $categories_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
393 - $order_i = 0;
394 -
395 444 foreach($categories_data as $category)
396 445 {
397 - $categories_list[(++$order_i).'__'.wmvc_show_data('idcategory', $category)] = '#'.wmvc_show_data('idcategory', $category).' '.wmvc_show_data('category_title', $category);
446 + $categories_list[wmvc_show_data('idcategory', $category)] = '#'.wmvc_show_data('idcategory', $category).' '.wmvc_show_data('category_title', $category);
398 447 }
448 +
399 449 $this->add_control(
400 450 'custom_category_root',
401 451 [
402 452 'label' => __( 'Custom Category Root', 'wpdirectorykit' ),
403 - 'type' => Controls_Manager::SELECT,
453 + 'type' => Controls_Manager::SELECT2,
404 454 'options' => $categories_list,
405 - 'default' => 'results',
455 + 'default' => '',
406 456 ]
407 457 );
408 458
409 459 $locations_data = $WMVC->location_m->get_by(array('(parent_id = 0 OR parent_id IS NULL)' => NULL));
410 460 $locations_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
411 - $order_i = 0;
412 -
413 461 foreach($locations_data as $location)
414 462 {
415 - $locations_list[(++$order_i).'__'.wmvc_show_data('idlocation', $location)] = '#'.wmvc_show_data('idlocation', $location).' '.wmvc_show_data('location_title', $location);
463 + $locations_list[wmvc_show_data('idlocation', $location)] = '#'.wmvc_show_data('idlocation', $location).' '.wmvc_show_data('location_title', $location);
416 464 }
417 465 $this->add_control(
418 466 'custom_location_root',
419 467 [
420 468 'label' => __( 'Custom Location Root', 'wpdirectorykit' ),
421 - 'type' => Controls_Manager::SELECT,
469 + 'type' => Controls_Manager::SELECT2,
422 470 'options' => $locations_list,
423 - 'default' => 'results',
471 + 'default' => '',
424 472 ]
425 473 );
426 474
427 475
@@ -439,24 +487,26 @@
439 487 );
440 488
441 489 $fields_data = wdk_cached_field_get();
442 490 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
443 - $order_i = 0;
444 491 $fields_allow_types = array();
445 492 $fields_allow_tree_types = array();
446 493
447 - $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
448 - $fields_list [(++$order_i).'__search'] = esc_html__('Smart Search', 'wpdirectorykit');
494 + $fields_list ['section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
495 + $fields_list ['search'] = esc_html__('Smart Search', 'wpdirectorykit');
449 496
450 - if(function_exists('run_wdk_bookings'))
451 - $fields_list [(++$order_i).'__booking_date'] = esc_html__('Booking Date', 'wpdirectorykit');
497 + if(function_exists('run_wdk_bookings')) {
498 + $fields_list ['booking_date'] = esc_html__('Booking Date', 'wpdirectorykit');
499 + $fields_list ['booking_guest'] = esc_html__('Booking Guests', 'wpdirectorykit');
500 + }
452 501
453 - $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
454 - $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
455 - $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
456 - $fields_allow_tree_types[] = $order_i.'__category_id';
457 - $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
458 - $fields_allow_tree_types[] = $order_i.'__location_id';
502 + $fields_list ['post_title'] = esc_html__('WP Title', 'wpdirectorykit');
503 + $fields_list ['post_title'] = esc_html__('WP Title', 'wpdirectorykit');
504 + $fields_list ['address'] = esc_html__('Address', 'wpdirectorykit');
505 + $fields_list ['category_id'] = esc_html__('Category', 'wpdirectorykit');
506 + $fields_allow_tree_types[] = 'category_id';
507 + $fields_list ['location_id'] = esc_html__('Location', 'wpdirectorykit');
508 + $fields_allow_tree_types[] = 'location_id';
459 509
460 510 foreach($fields_data as $field)
461 511 {
462 512 if(in_array(wmvc_show_data('field_type', $field),array('TEXTAREA','TEXTAREA_WYSIWYG'))) {
@@ -461,18 +511,27 @@
461 511 {
462 512 if(in_array(wmvc_show_data('field_type', $field),array('TEXTAREA','TEXTAREA_WYSIWYG'))) {
463 513 continue;
464 514 } else if(in_array(wmvc_show_data('field_type', $field),array('SECTION'))) {
465 - $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
515 + $fields_list ['section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
466 516 } else {
467 - $fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
517 + $fields_list[wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
468 518 }
469 519
470 520 if(wmvc_show_data('field_type', $field) == 'NUMBER') {
471 - $fields_allow_types[] = $order_i.'__'.wmvc_show_data('idfield', $field);
521 + $fields_allow_types[] = ''.wmvc_show_data('idfield', $field);
472 522 }
473 523 }
474 524
525 + // build raw_options preserving order
526 + $raw = [];
527 + foreach ( $fields_list as $k => $v ) {
528 + $raw[] = [
529 + 'value' => (string) $k,
530 + 'label' => $v,
531 + ];
532 + }
533 +
475 534 $repeater = new Repeater();
476 535 $repeater->start_controls_tabs( 'custom_fields_repeat' );
477 536
478 537 $repeater->add_control(
@@ -478,11 +537,12 @@
478 537 $repeater->add_control(
479 538 'field_id',
480 539 [
481 540 'label' => __( 'Field id', 'wpdirectorykit' ),
482 - 'type' => \Elementor\Controls_Manager::SELECT,
541 + 'type' => \Wdk\Includes\Controls\Wdk_Field_Selector::INIT,
483 542 'default' => '',
484 543 'options' => $fields_list,
544 + 'raw_options' => $raw,
485 545 'separator' => 'after',
486 546 ]
487 547 );
488 548
@@ -661,9 +721,42 @@
661 721 'default' => 'results',
662 722 ]
663 723 );
664 724
725 +
665 726 $this->add_responsive_control(
727 + 'form_fields_align',
728 + [
729 + 'label' => __( 'Align', 'wpdirectorykit' ),
730 + 'type' => Controls_Manager::CHOOSE,
731 + 'options' => [
732 + 'left' => [
733 + 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
734 + 'icon' => 'eicon-text-align-left',
735 + ],
736 + 'center' => [
737 + 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
738 + 'icon' => 'eicon-text-align-center',
739 + ],
740 + 'right' => [
741 + 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
742 + 'icon' => 'eicon-text-align-right',
743 + ],
744 + ],
745 + 'render_type' => 'template',
746 + 'selectors_dictionary' => [
747 + 'left' => 'justify-content: flex-start;',
748 + 'center' => 'justify-content: center;',
749 + 'right' => 'justify-content: flex-end;',
750 + ],
751 +
752 + 'selectors' => [
753 + '{{WRAPPER}} .wdk-search .wdk-search-form > .wdk-row ' => '{{VALUE}};',
754 + ],
755 + ]
756 + );
757 +
758 + $this->add_responsive_control(
666 759 'design_layout',
667 760 [
668 761 'label' => __( 'Design Layout', 'wpdirectorykit' ),
669 762 'type' => Controls_Manager::SELECT,
@@ -934,8 +1027,23 @@
934 1027 ]
935 1028 );
936 1029
937 1030 $this->add_responsive_control(
1031 + 'button_wrapper',
1032 + [
1033 + 'label' => __( 'Button Wrapper Hide', 'wpdirectorykit' ),
1034 + 'type' => Controls_Manager::SWITCHER,
1035 + 'label_on' => __( 'Show', 'wpdirectorykit' ),
1036 + 'label_off' => __( 'Hide', 'wpdirectorykit' ),
1037 + 'return_value' => 'none',
1038 + 'default' => '',
1039 + 'selectors' => [
1040 + '{{WRAPPER}} .wdk-search .wdk-col-btns' => 'display: {{VALUE}};',
1041 + ],
1042 + ]
1043 + );
1044 +
1045 + $this->add_responsive_control(
938 1046 'button_column_inline',
939 1047 [
940 1048 'label' => __( 'Column Buttons Cell', 'wpdirectorykit' ),
941 1049 'type' => Controls_Manager::SELECT,
@@ -1518,9 +1626,9 @@
1518 1626 ],
1519 1627 [
1520 1628 'key'=>'field_button',
1521 1629 'label'=> esc_html__('Search Button', 'wpdirectorykit'),
1522 - 'selector_hide'=>'{{WRAPPER}} .wdk-field .wdk-field-btn button.wdk-search-start',
1630 + 'selector_hide'=>'{{WRAPPER}} .wdk-field .wdk-field-group-search button.wdk-search-start',
1523 1631 'selector'=>'{{WRAPPER}} .wdk-field button.wdk-search-start',
1524 1632 'selector_hover'=>'{{WRAPPER}} .wdk-field button.wdk-search-start%1$s',
1525 1633 'options'=>'full',
1526 1634 ],
@@ -1532,8 +1640,16 @@
1532 1640 'selector_hover'=>'{{WRAPPER}} .wdk-field button.wdk-search-start.wdk-search-reset%1$s',
1533 1641 'options'=>['typo','color','border','border_radius','shadow','transition','background_group'],
1534 1642 ],
1535 1643 [
1644 + 'key'=>'field_button_ai_search',
1645 + 'label'=> esc_html__('Ai Search Button', 'wpdirectorykit'),
1646 + 'selector_hide'=>'{{WRAPPER}} .wdk-field-group.wdk-field-group-ai-search',
1647 + 'selector'=>'{{WRAPPER}} .wdk-field .wdk-ai-search',
1648 + 'selector_hover'=>'{{WRAPPER}} .wdk-field .wdk-ai-search%1$s',
1649 + 'options'=>['typo','color','border','border_radius','shadow','transition','background_group'],
1650 + ],
1651 + [
1536 1652 'key'=>'field_button_more',
1537 1653 'label'=> esc_html__('Button More', 'wpdirectorykit'),
1538 1654 'selector_hide'=>'{{WRAPPER}} .wdk-field .wdk-field-group-additional',
1539 1655 'selector'=>'{{WRAPPER}} .wdk-field button.wdk-search-additional-btn',
@@ -1659,12 +1775,12 @@
1659 1775 if(!empty($item['selector_hide'])) {
1660 1776 $this->add_responsive_control(
1661 1777 $item['key'].'_hide',
1662 1778 [
1663 - 'label' => esc_html__( 'Hide Element', 'wdk-svg-map' ),
1779 + 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
1664 1780 'type' => Controls_Manager::SWITCHER,
1665 - 'none' => esc_html__( 'Hide', 'wdk-svg-map' ),
1666 - 'block' => esc_html__( 'Show', 'wdk-svg-map' ),
1781 + 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
1782 + 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
1667 1783 'return_value' => 'none',
1668 1784 'default' => ($item['key'] == 'field_button_reset' ) ? 'none':'',
1669 1785 'selectors' => [
1670 1786 $item['selector_hide'] => 'display: {{VALUE}};',
@@ -2023,16 +2139,19 @@
2023 2139 wp_enqueue_script('wdk-suggestion');
2024 2140 wp_enqueue_style('wdk-treefield');
2025 2141
2026 2142
2027 - wp_enqueue_script('select2');
2143 + wp_enqueue_script('select2-select2');
2028 2144 wp_enqueue_script('wdk-select2');
2029 - wp_enqueue_style('select2');
2145 + wp_enqueue_style('select2-select2');
2030 2146
2031 2147 wp_enqueue_script( 'ion.range-slider' );
2032 2148 wp_enqueue_style('ion.range-slider');
2033 2149 wp_enqueue_style('wdk-slider-range');
2034 2150 wp_enqueue_script('wdk-slider-range');
2151 +
2152 + wp_enqueue_style('jquery-confirm');
2153 + wp_enqueue_script('jquery-confirm');
2035 2154
2036 2155 wp_enqueue_style( 'wdk-treefield-checkboxes');
2037 2156 wp_enqueue_script( 'wdk-treefield-checkboxes');
2038 2157