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 +145 -33 1.3.1 → 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);
@@ -150,9 +154,9 @@
150 154 $this->data['predefields_query'] = array_map('trim', $string_par);
151 155
152 156 if(!empty($this->data['settings']['custom_category_root'])) {
153 157
154 - if(strpos($this->data['settings']['field_id'],'__') !== FALSE){
158 + if(!empty($this->data['settings']['field_id']) && strpos($this->data['settings']['field_id'],'__') !== FALSE){
155 159 $this->data['settings']['custom_category_root'] = substr($this->data['settings']['custom_category_root'], strpos($this->data['settings']['custom_category_root'],'__')+2);
156 160 }
157 161 if(is_intval($this->data['settings']['custom_category_root'])) {
158 162 $this->data['predefields_query']['custom_category_root'] = $this->data['settings']['custom_category_root'];
@@ -192,9 +196,9 @@
192 196 }
193 197 }
194 198
195 199
196 - echo $this->view('wdk-search', $this->data);
200 + $this->view('wdk-search', $this->data, true);
197 201 }
198 202
199 203
200 204 private function generate_controls_conf() {
@@ -231,9 +235,22 @@
231 235 'default' => '',
232 236 ]
233 237 );
234 238
239 +
235 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(
236 253 'section_config_more',
237 254 [
238 255 'label' => __( 'Field more hide', 'wpdirectorykit' ),
239 256 'type' => Controls_Manager::SWITCHER,
@@ -245,8 +262,20 @@
245 262 '{{WRAPPER}} .wdk-field-group-additional' => 'display: {{VALUE}};',
246 263 ],
247 264 ]
248 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 + );
249 278
250 279 $this->add_control(
251 280 'section_config_more_limit',
252 281 [
@@ -303,9 +332,9 @@
303 332
304 333 $this->add_control(
305 334 'field_button_icon',
306 335 [
307 - 'label' => __( 'Icon', 'text-domain' ),
336 + 'label' => __( 'Icon', 'wpdirectorykit' ),
308 337 'type' => Controls_Manager::ICONS,
309 338 ]
310 339 );
311 340
@@ -311,13 +340,13 @@
311 340
312 341 $this->add_control(
313 342 'field_button_icon_position',
314 343 [
315 - 'label' => esc_html__('icon Position', 'wdk-compare-listing'),
344 + 'label' => esc_html__('icon Position', 'wpdirectorykit'),
316 345 'type' => Controls_Manager::SELECT,
317 346 'options' => [
318 - 'left' => esc_html__('Left', 'wdk-compare-listing'),
319 - 'right' => esc_html__('Right', 'wdk-compare-listing'),
347 + 'left' => esc_html__('Left', 'wpdirectorykit'),
348 + 'right' => esc_html__('Right', 'wpdirectorykit'),
320 349 ],
321 350 'default' => 'left',
322 351 ]
323 352 );
@@ -345,16 +374,27 @@
345 374 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
346 375 $order_i = 0;
347 376 foreach($fields as $field)
348 377 {
349 - $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);
350 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 +
351 390 $this->add_control(
352 391 'tab_field',
353 392 [
354 393 'label' => __( 'Tab', 'wpdirectorykit' ),
355 - 'type' => Controls_Manager::SELECT2,
394 + 'type' => \Wdk\Includes\Controls\Wdk_Field_Selector::INIT,
356 395 'options' => $fields_list,
396 + 'raw_options' => $raw,
357 397 'default' => 'results',
358 398 ]
359 399 );
360 400
@@ -374,8 +414,9 @@
374 414 'important_note',
375 415 [
376 416 'label' => '',
377 417 'type' => \Elementor\Controls_Manager::RAW_HTML,
418 + /* translators: 1: URL. */
378 419 'raw' => wdk_sprintf(__( 'Manage Search Form <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_searchform')),
379 420 'content_classes' => 'wdk_elementor_hint',
380 421 'separator' => 'after',
381 422 ]
@@ -446,24 +487,26 @@
446 487 );
447 488
448 489 $fields_data = wdk_cached_field_get();
449 490 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
450 - $order_i = 0;
451 491 $fields_allow_types = array();
452 492 $fields_allow_tree_types = array();
453 493
454 - $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
455 - $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');
456 496
457 - if(function_exists('run_wdk_bookings'))
458 - $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 + }
459 501
460 - $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
461 - $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
462 - $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
463 - $fields_allow_tree_types[] = $order_i.'__category_id';
464 - $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
465 - $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';
466 509
467 510 foreach($fields_data as $field)
468 511 {
469 512 if(in_array(wmvc_show_data('field_type', $field),array('TEXTAREA','TEXTAREA_WYSIWYG'))) {
@@ -468,18 +511,27 @@
468 511 {
469 512 if(in_array(wmvc_show_data('field_type', $field),array('TEXTAREA','TEXTAREA_WYSIWYG'))) {
470 513 continue;
471 514 } else if(in_array(wmvc_show_data('field_type', $field),array('SECTION'))) {
472 - $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).' --';
473 516 } else {
474 - $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).']';
475 518 }
476 519
477 520 if(wmvc_show_data('field_type', $field) == 'NUMBER') {
478 - $fields_allow_types[] = $order_i.'__'.wmvc_show_data('idfield', $field);
521 + $fields_allow_types[] = ''.wmvc_show_data('idfield', $field);
479 522 }
480 523 }
481 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 +
482 534 $repeater = new Repeater();
483 535 $repeater->start_controls_tabs( 'custom_fields_repeat' );
484 536
485 537 $repeater->add_control(
@@ -485,11 +537,12 @@
485 537 $repeater->add_control(
486 538 'field_id',
487 539 [
488 540 'label' => __( 'Field id', 'wpdirectorykit' ),
489 - 'type' => \Elementor\Controls_Manager::SELECT2,
541 + 'type' => \Wdk\Includes\Controls\Wdk_Field_Selector::INIT,
490 542 'default' => '',
491 543 'options' => $fields_list,
544 + 'raw_options' => $raw,
492 545 'separator' => 'after',
493 546 ]
494 547 );
495 548
@@ -668,9 +721,42 @@
668 721 'default' => 'results',
669 722 ]
670 723 );
671 724
725 +
672 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(
673 759 'design_layout',
674 760 [
675 761 'label' => __( 'Design Layout', 'wpdirectorykit' ),
676 762 'type' => Controls_Manager::SELECT,
@@ -941,8 +1027,23 @@
941 1027 ]
942 1028 );
943 1029
944 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(
945 1046 'button_column_inline',
946 1047 [
947 1048 'label' => __( 'Column Buttons Cell', 'wpdirectorykit' ),
948 1049 'type' => Controls_Manager::SELECT,
@@ -1525,9 +1626,9 @@
1525 1626 ],
1526 1627 [
1527 1628 'key'=>'field_button',
1528 1629 'label'=> esc_html__('Search Button', 'wpdirectorykit'),
1529 - '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',
1530 1631 'selector'=>'{{WRAPPER}} .wdk-field button.wdk-search-start',
1531 1632 'selector_hover'=>'{{WRAPPER}} .wdk-field button.wdk-search-start%1$s',
1532 1633 'options'=>'full',
1533 1634 ],
@@ -1539,8 +1640,16 @@
1539 1640 'selector_hover'=>'{{WRAPPER}} .wdk-field button.wdk-search-start.wdk-search-reset%1$s',
1540 1641 'options'=>['typo','color','border','border_radius','shadow','transition','background_group'],
1541 1642 ],
1542 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 + [
1543 1652 'key'=>'field_button_more',
1544 1653 'label'=> esc_html__('Button More', 'wpdirectorykit'),
1545 1654 'selector_hide'=>'{{WRAPPER}} .wdk-field .wdk-field-group-additional',
1546 1655 'selector'=>'{{WRAPPER}} .wdk-field button.wdk-search-additional-btn',
@@ -1666,12 +1775,12 @@
1666 1775 if(!empty($item['selector_hide'])) {
1667 1776 $this->add_responsive_control(
1668 1777 $item['key'].'_hide',
1669 1778 [
1670 - 'label' => esc_html__( 'Hide Element', 'wdk-svg-map' ),
1779 + 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
1671 1780 'type' => Controls_Manager::SWITCHER,
1672 - 'none' => esc_html__( 'Hide', 'wdk-svg-map' ),
1673 - 'block' => esc_html__( 'Show', 'wdk-svg-map' ),
1781 + 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
1782 + 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
1674 1783 'return_value' => 'none',
1675 1784 'default' => ($item['key'] == 'field_button_reset' ) ? 'none':'',
1676 1785 'selectors' => [
1677 1786 $item['selector_hide'] => 'display: {{VALUE}};',
@@ -2030,16 +2139,19 @@
2030 2139 wp_enqueue_script('wdk-suggestion');
2031 2140 wp_enqueue_style('wdk-treefield');
2032 2141
2033 2142
2034 - wp_enqueue_script('select2');
2143 + wp_enqueue_script('select2-select2');
2035 2144 wp_enqueue_script('wdk-select2');
2036 - wp_enqueue_style('select2');
2145 + wp_enqueue_style('select2-select2');
2037 2146
2038 2147 wp_enqueue_script( 'ion.range-slider' );
2039 2148 wp_enqueue_style('ion.range-slider');
2040 2149 wp_enqueue_style('wdk-slider-range');
2041 2150 wp_enqueue_script('wdk-slider-range');
2151 +
2152 + wp_enqueue_style('jquery-confirm');
2153 + wp_enqueue_script('jquery-confirm');
2042 2154
2043 2155 wp_enqueue_style( 'wdk-treefield-checkboxes');
2044 2156 wp_enqueue_script( 'wdk-treefield-checkboxes');
2045 2157