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 | application/controllers/Wdk_frontendajax.php +589 -53 1.2.9 → 1.5.9 View file →
@@ -32,11 +32,28 @@
32 32 if(isset($_POST['listing_post_id']))
33 33 $listing_post_id = sanitize_text_field($_POST['listing_post_id']);
34 34
35 35 $listing = $this->load->listing_m->get($listing_post_id, TRUE);
36 +
37 + if (!$listing || $listing->post_status != 'publish' || !empty($listing->post_password)) {
38 + return false;
39 + }
36 40
41 + /* protect check */
42 + if (
43 + !wdk_field_value('is_activated', $listing, false) || !wdk_field_value('is_approved', $listing,false)
44 + ) {
45 + $data['popup_content'] = __( 'Listing is not public', 'wpdirectorykit' );
46 + $this->output($data);
47 + }
48 +
49 + $popup_layout = 'result_item_card';
50 + if(!empty($_POST['custom_layout_id'])) {
51 + $popup_layout = (int) sanitize_text_field($_POST['custom_layout_id']);
52 + }
53 +
37 54 if(!empty($listing)) {
38 - $data['popup_content'] = wdk_listing_card($listing, array('infobox' => true), false, '<div class="infobox map-box">%1$s<div>');
55 + $data['popup_content'] = wdk_listing_card($listing, array('infobox' => true), false, '<div class="infobox map-box">%1$s<div>', $popup_layout);
39 56 } else {
40 57 $data['popup_content'] = __( 'Listing is missing', 'wpdirectorykit' );
41 58 }
42 59
@@ -57,8 +74,21 @@
57 74 $listing_post_id = sanitize_text_field($_POST['listing_post_id']);
58 75
59 76 $listing = $this->load->listing_m->get($listing_post_id, TRUE);
60 77
78 +
79 + if (!$listing || $listing->post_status != 'publish' || !empty($listing->post_password)) {
80 + return false;
81 + }
82 +
83 + /* protect check */
84 + if (
85 + !wdk_field_value('is_activated', $listing, false) || !wdk_field_value('is_approved', $listing,false)
86 + ) {
87 + $data['popup_content'] = __( 'Listing is not public', 'wpdirectorykit' );
88 + $this->output($data);
89 + }
90 +
61 91 if(!empty($listing)) {
62 92 $data['popup_content'] = wdk_listing_card($listing, [], false, '<div class="infobox map-box">%1$s<div>', 'result_item_card_dash_edit');
63 93 } else {
64 94 $data['popup_content'] = __( 'Listing is missing', 'wpdirectorykit' );
@@ -70,8 +100,11 @@
70 100 }
71 101
72 102 public function treefieldid($output="", $atts=array(), $instance=NULL)
73 103 {
104 +
105 + check_ajax_referer('wdk_secure_treefieldid', 'wdk_secure');
106 +
74 107 $this->load->load_helper('listing');
75 108 $this->load->model('listing_m');
76 109 $this->load->model('listingfield_m');
77 110
@@ -124,15 +157,20 @@
124 157
125 158 if($table == 'calendar_listing_m')
126 159 $table = 'listing_m';
127 160
161 + $post_table = $this->db->prefix.'posts';
162 +
128 163 $table_name = substr($table,0, -2);
129 - $attr_id = sanitize_text_field($parameters['attribute_id']);
130 - $attr_val = sanitize_text_field($parameters['attribute_value']);
131 - $attr_search = sanitize_text_field($parameters['search_term']);
132 - $skip_id = intval($parameters['skip_id']);
133 - $language_id = intval($parameters['language_id']);
134 164
165 + $attr_id = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_id']));
166 + $attr_val = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_value']));
167 +
168 +
169 + $attr_search = wdk_esc_sql(sanitize_text_field($parameters['search_term'] ?? ''));
170 + $skip_id = intval($parameters['skip_id'] ?? 0);
171 + $language_id = intval($parameters['language_id'] ?? 0);
172 +
135 173 if(empty($language_id))
136 174 $language_id = NULL;
137 175
138 176 $id_part="";
@@ -173,14 +211,30 @@
173 211 } elseif($attr_val == 'category_title'){
174 212 $this->load->model($table);
175 213 $attr_val_sql = $this->$table->_table_name.'.category_title';
176 214 }
215 +
216 + /* if category/locations search also in translated field */
217 + if($attr_val == 'location_title' || $attr_val == 'category_title') {
218 + $where["($id_part $attr_val_sql LIKE '%$attr_search%' OR ".$this->$table->_table_name.".titles_for_search LIKE '%$attr_search%')"] = NULL;
219 + } else {
220 + $where["($id_part $attr_val_sql LIKE '%$attr_search%')"] = NULL;
221 + }
222 + }
177 223
178 - $where["($id_part $attr_val_sql LIKE '%$attr_search%')"] = NULL;
179 -
224 + if(!empty($parameters['sql_where'] )) {
225 + $sql_where = '';
226 + if($parameters['sql_where'] == 'only_nochilds') {
227 + $sql_where = "((".$this->listing_m->_table_name.".listing_parent_post_id IS NULL OR ".$this->listing_m->_table_name.".listing_parent_post_id = 0) AND (".$this->listing_m->_table_name.".`listing_related_ids` IS NULL OR ".$this->listing_m->_table_name.".`listing_related_ids` = '') )";
228 + } else {
229 +
230 + }
231 + if(!empty($sql_where))
232 + $where[$sql_where] = NULL;
180 233 }
181 234
182 235 if(!empty($parameters['hide_fields'])) {
236 + $parameters['hide_fields'] = preg_replace('/[^0-9,]/', '', $parameters['hide_fields']);
183 237 if($table == 'location_m') {
184 238 $sql_where = esc_sql($this->$table->_table_name.'.idlocation').' NOT IN ('.esc_sql(sanitize_text_field($parameters['hide_fields'])).')';
185 239 foreach (explode(',', $parameters['hide_fields']) as $key => $id) {
186 240 $sql_where .= ' AND CONCAT(",", '.$this->$table->_table_name.'.parent_path, ",") NOT LIKE CONCAT("%,", '.intval($id).', ",%")';
@@ -197,17 +251,14 @@
197 251 $where[$sql_where] = NULL;
198 252 }
199 253 }
200 254
201 - if(!empty($parameters['attr_search']))
202 - $where[$parameters['attr_search']] = NULL;
203 -
204 255 if(isset($parameters['user_check']) && ($parameters['user_check'] == 'true' || $parameters['user_check'] == '1')) {
205 256 if($table == 'listing_m') {
206 257 if($parameters['table'] == 'calendar_listing_m') {
207 258 global $Winter_MVC_wdk_bookings;
208 259 $Winter_MVC_wdk_bookings->model('calendar_m');
209 - $this->db->join($Winter_MVC_wdk_bookings->calendar_m->_table_name.' ON '.$this->$table->_table_name.'.post_id = '.$Winter_MVC_wdk_bookings->calendar_m->_table_name.'.post_id');
260 + $this->db->join($Winter_MVC_wdk_bookings->calendar_m->_table_name.' ON '.$post_table.'.ID = '.$Winter_MVC_wdk_bookings->calendar_m->_table_name.'.post_id');
210 261 }
211 262
212 263 $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where, TRUE, get_current_user_id());
213 264 } else {
@@ -212,9 +263,9 @@
212 263 $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where, TRUE, get_current_user_id());
213 264 } else {
214 265
215 266 if(!empty($parameters['filter_ids'])){
216 - $this->db->where(array( esc_sql($this->$table->_table_name.'.'.$this->$table->_primary_key).' IN ('.esc_sql($parameters['filter_ids']).')' => NULL));
267 + $this->db->where(array( esc_sql($this->$table->_table_name.'.'.$this->$table->_primary_key).' IN ('.esc_sql(preg_replace('/[^0-9,]/', '', $parameters['filter_ids'])).')' => NULL));
217 268 }
218 269
219 270 $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where );
220 271 }
@@ -221,13 +272,13 @@
221 272 } else {
222 273 if($parameters['table'] == 'calendar_listing_m') {
223 274 global $Winter_MVC_wdk_bookings;
224 275 $Winter_MVC_wdk_bookings->model('calendar_m');
225 - $this->db->join($Winter_MVC_wdk_bookings->calendar_m->_table_name.' ON '.$this->$table->_table_name.'.post_id = '.$Winter_MVC_wdk_bookings->calendar_m->_table_name.'.post_id');
276 + $this->db->join($Winter_MVC_wdk_bookings->calendar_m->_table_name.' ON '.$post_table.'.ID = '.$Winter_MVC_wdk_bookings->calendar_m->_table_name.'.post_id');
226 277 }
227 278
228 279 if(!empty($parameters['filter_ids'])){
229 - $this->db->where(array( esc_sql($this->$table->_table_name.'.'.$this->$table->_primary_key).' IN ('.esc_sql($parameters['filter_ids']).')' => NULL));
280 + $this->db->where(array( esc_sql($this->$table->_table_name.'.'.$this->$table->_primary_key).' IN ('.esc_sql(preg_replace('/[^0-9,]/', '', $parameters['filter_ids'])).')' => NULL));
230 281 }
231 282
232 283 if($table == 'user_m') {
233 284 $like = "(meta_value LIKE '%wdk_%' )";
@@ -233,11 +284,21 @@
233 284 $like = "(meta_value LIKE '%wdk_%' )";
234 285 $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where, NULL, $like);
235 286
236 287 } else {
237 - $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where);
288 +
289 + if(method_exists($this->$table, 'get_pagination_simple')) {
290 + if($table == 'location_m') {
291 + $this->db->select('location_title, idlocation, level');
292 + } else if($table == 'category_m') {
293 + $this->db->select('category_title, idcategory, level');
294 + }
295 + $tree_results = $this->$table->get_pagination_simple(intval($parameters['limit']),intval($parameters['offset']), $where);
296 + } else {
297 + $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where);
298 + }
299 +
238 300 }
239 -
240 301 }
241 302
242 303 }
243 304
@@ -253,9 +314,12 @@
253 314 $results[$ind_order]['value'] = $level_gen
254 315 .'#'.wmvc_show_data($attr_id, $row).', '.wmvc_show_data($attr_val, $row);
255 316 } elseif($table == 'user_m') {
256 317 $results[$ind_order]['value'] = $level_gen
257 - .'#'.wmvc_show_data($attr_id, $row).', '.wmvc_show_data($attr_val, $row).' ('.wmvc_show_data('user_email', $row).')';
318 + .'#'.wmvc_show_data($attr_id, $row).', '.wmvc_show_data('display_name', $row);
319 +
320 + //if(current_user_can('wdk_listings_manage'))
321 + // $results[$ind_order]['value'] .= ' ('.wmvc_show_data('user_email', $row).')';
258 322 } elseif($table == 'icons_list') {
259 323 $results[$ind_order]['key'] = $row;
260 324 if(defined('ELEMENTOR_ASSETS_URL')){
261 325 $results[$ind_order]['value'] = '<i class="'. $row.'"></i>&nbsp;&nbsp;'.$row;
@@ -263,8 +327,10 @@
263 327 $results[$ind_order]['value'] = $row;
264 328 }
265 329 } else {
266 330 $results[$ind_order]['value'] = $level_gen
331 + // Dynamic field values are registered in the translation catalog separately.
332 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
267 333 .esc_html__(wmvc_show_data($attr_val, $row), 'wpdirectorykit');
268 334 }
269 335 $ind_order++;
270 336 }
@@ -290,11 +356,14 @@
290 356 $level_gen = str_pad('', $row->level*12, '&nbsp;').'';
291 357
292 358 if($table == 'user_m') {
293 359 $data['curr_val'] = $level_gen
294 - .wmvc_show_data(wmvc_show_data('attribute_value', $parameters), $row).' ('.wmvc_show_data('user_email', $row).')'.' #'.wmvc_show_data($attr_id, $row);
360 + .wmvc_show_data('display_name', $row);
361 +
295 362 } else {
296 363 $data['curr_val'] = $level_gen
364 + // Dynamic field values are registered in the translation catalog separately.
365 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
297 366 .esc_html__(wmvc_show_data(wmvc_show_data('attribute_value', $parameters), $row), 'wpdirectorykit');
298 367 }
299 368
300 369
@@ -308,14 +377,16 @@
308 377
309 378 $this->data['success'] = true;
310 379
311 380 $data['results'] = $results;
312 - //$data['sql'] = $this->db->last_query();
381 + $data['sql'] = $this->db->last_query();
313 382 $this->output($data);
314 383 }
315 384
316 385 public function treefieldid_checkboxes($output="", $atts=array(), $instance=NULL)
317 386 {
387 + check_ajax_referer('wdk_secure_treefieldid_checkboxes', 'wdk_secure');
388 +
318 389 $this->load->load_helper('listing');
319 390 $this->load->model('listing_m');
320 391 $this->load->model('listingfield_m');
321 392
@@ -369,11 +440,12 @@
369 440 if($table == 'calendar_listing_m')
370 441 $table = 'listing_m';
371 442
372 443 $table_name = substr($table,0, -2);
373 - $attr_id = sanitize_text_field($parameters['attribute_id']);
374 - $attr_val = sanitize_text_field($parameters['attribute_value']);
375 - $attr_search = sanitize_text_field($parameters['search_term']);
444 + $attr_id = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_id']));
445 + $attr_val = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_value']));
446 +
447 + $attr_search = wdk_esc_sql(sanitize_text_field($parameters['search_term']));
376 448 $skip_id = intval($parameters['skip_id']);
377 449 $language_id = intval($parameters['language_id']);
378 450
379 451 if(empty($language_id))
@@ -386,9 +458,23 @@
386 458 $this->load->model($table);
387 459
388 460 $where = array();
389 461 if(!empty($attr_search))
390 - $where["($id_part $attr_val LIKE '%$attr_search%')"] = NULL;
462 + $attr_val_sql = $attr_val;
463 + if($attr_val == 'location_title') {
464 + $this->load->model($table);
465 + $attr_val_sql = $this->$table->_table_name.'.location_title';
466 + } elseif($attr_val == 'category_title'){
467 + $this->load->model($table);
468 + $attr_val_sql = $this->$table->_table_name.'.category_title';
469 + }
470 +
471 + /* if category/locations search also in translated field */
472 + if($attr_val == 'location_title' || $attr_val == 'category_title') {
473 + $where["($id_part $attr_val_sql LIKE '%$attr_search%' OR ".$this->$table->_table_name.".titles_for_search LIKE '%$attr_search%')"] = NULL;
474 + } else {
475 + $where["($id_part $attr_val_sql LIKE '%$attr_search%')"] = NULL;
476 + }
391 477
392 478 if(isset($parameters['selected']) && !empty($parameters['selected'])) {
393 479
394 480 if(is_string($parameters['selected']) && strpos($parameters['selected'], ',') !== FALSE){
@@ -413,12 +499,13 @@
413 499 }
414 500 }
415 501
416 502 if(!empty($parameters['filter_ids'])){
417 - $this->db->where(array( esc_sql($this->$table->_table_name.'.'.$this->$table->_primary_key).' IN ('.esc_sql($parameters['filter_ids']).')' => NULL));
503 + $this->db->where(array( esc_sql($this->$table->_table_name.'.'.$this->$table->_primary_key).' IN ('.esc_sql(preg_replace('/[^0-9,]/', '', $parameters['filter_ids'])).')' => NULL));
418 504 }
419 505
420 506 if(!empty($parameters['hide_fields'])) {
507 + $parameters['hide_fields'] = preg_replace('/[^0-9,]/', '', $parameters['hide_fields']);
421 508 if($table == 'location_m') {
422 509 $sql_where = esc_sql($this->$table->_table_name.'.idlocation').' NOT IN ('.esc_sql(sanitize_text_field($parameters['hide_fields'])).')';
423 510 foreach (explode(',', $parameters['hide_fields']) as $key => $id) {
424 511 $sql_where .= ' AND CONCAT(",", '.$this->$table->_table_name.'.parent_path, ",") NOT LIKE CONCAT("%,", '.intval($id).', ",%")';
@@ -446,8 +533,10 @@
446 533 $level_gen = str_pad('', $row->level*12, '&nbsp;').'';
447 534
448 535 $results[$ind_order]['key'] = wmvc_show_data($attr_id, $row);
449 536 $results[$ind_order]['value'] = $level_gen
537 + // Dynamic field values are registered in the translation catalog separately.
538 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
450 539 .esc_html__(wmvc_show_data($attr_val, $row), 'wpdirectorykit');
451 540 $ind_order++;
452 541 }
453 542
@@ -460,10 +549,11 @@
460 549 {
461 550 $level_gen='';
462 551 if(isset($row->level))
463 552 $level_gen = str_pad('', $row->level*12, '&nbsp;').'';
464 -
465 - $data['curr_val'] = $level_gen
553 + $data['curr_val'] = $level_gen
554 + // Dynamic field values are registered in the translation catalog separately.
555 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
466 556 .esc_html__(wmvc_show_data(wmvc_show_data('attribute_value', $parameters), $row), 'wpdirectorykit');
467 557
468 558 }
469 559 else
@@ -490,11 +580,14 @@
490 580 return $data;
491 581 }
492 582 }
493 583
494 -
584 +
495 585 public function select_2_ajax($output="", $atts=array(), $instance=NULL)
496 586 {
587 +
588 + check_ajax_referer('wdk_secure_ajax', 'wdk_secure');
589 +
497 590 $this->load->load_helper('listing');
498 591 $this->load->model('listing_m');
499 592 $this->load->model('listingfield_m');
500 593
@@ -511,8 +604,14 @@
511 604 if(empty($parameters['table'])) return false;
512 605
513 606 $model_name = $parameters['table'];
514 607
608 + // allow only 'listing_m', 'category_m', or 'location_m' for security
609 + $allowed_models = array('listing_m', 'category_m', 'location_m');
610 + if (!in_array($model_name, $allowed_models)) {
611 + return false;
612 + }
613 +
515 614 $key_column = '';
516 615 $print_column = '';
517 616
518 617 $search_column = '';
@@ -519,13 +618,13 @@
519 618 if(empty($parameters['columns_search'])) {
520 619 switch ($model_name) {
521 620 case 'category_m':
522 621 $this->load->model($model_name);
523 - $search_column = $this->$model_name->_table_name.'.idcategory,'.$this->$model_name->_table_name.'.category_title';
622 + $search_column = $this->$model_name->_table_name.'.idcategory,'.$this->$model_name->_table_name.'.category_title, '.$this->$model_name->_table_name.'.titles_for_search';
524 623 break;
525 624 case 'location_m':
526 625 $this->load->model($model_name);
527 - $search_column = $this->$model_name->_table_name.'.idlocation,'.$this->$model_name->_table_name.'.location_title';
626 + $search_column = $this->$model_name->_table_name.'.idlocation,'.$this->$model_name->_table_name.'.location_title, '.$this->$model_name->_table_name.'.titles_for_search';
528 627 break;
529 628
530 629 default:
531 630 # code...
@@ -532,9 +631,9 @@
532 631 break;
533 632 }
534 633
535 634 } else {
536 - $search_column = $parameters['columns_search'];
635 + $search_column = esc_sql(preg_replace('/[^a-z0-9_,]/i', '', $parameters['columns_search']));
537 636 }
538 637
539 638 if(empty($parameters['key_column'])) {
540 639 switch ($model_name) {
@@ -598,9 +697,8 @@
598 697 }
599 698
600 699 $db_results_total = $this->$model_name->total($where);
601 700 $db_results = $this->$model_name->get_pagination($limit,$offset, $where);
602 - $data['output'] = $db_results;
603 701
604 702 if (!$db_results) {
605 703 $data['errors'] = '';
606 704 } else {
@@ -611,8 +709,10 @@
611 709 $level_gen = str_pad('', $row->level*12, '&nbsp;').'';
612 710
613 711 $results[] = [
614 712 'id'=> wmvc_show_data($key_column, $row),
713 + // Dynamic field values are registered in the translation catalog separately.
714 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
615 715 'text'=> $level_gen.esc_html__(trim(wmvc_show_data($print_column, $row)), 'wpdirectorykit'),
616 716 ];
617 717 }
618 718
@@ -662,9 +762,13 @@
662 762 $offset = (intval($parameters['page_result']) - 1) * $limit;
663 763 }
664 764
665 765 $this->load->model($model_name);
666 - $search_column = 'display_name,user_email,user_login,ID';
766 + $search_column = 'display_name,user_login,ID';
767 + if(current_user_can('administrator')) {
768 + $search_column = 'display_name,user_email,user_login,ID';
769 + }
770 +
667 771 $where = array();
668 772 if(!empty($_POST['q']['term']) && !empty($search_column)) {
669 773 $sql_search = '';
670 774 foreach (explode(',', $search_column) as $column) {
@@ -682,9 +786,8 @@
682 786 $like = "(meta_value LIKE '%wdk_%' )";
683 787 $db_results_total = $this->$model_name->total($where, NULL, $like);
684 788
685 789 $db_results = $this->$model_name->get_pagination($limit,$offset, $where, NULL, $like);
686 - $data['output'] = $db_results;
687 790
688 791 if (!$db_results) {
689 792 $data['errors'] = '';
690 793 } else {
@@ -713,9 +816,8 @@
713 816
714 817 //$data['sql'] = $this->db->last_query();
715 818 $this->output($data);
716 819 }
717 -
718 820
719 821 public function wdk_tree_dropdowns($output="", $atts=array(), $instance=NULL)
720 822 {
721 823 $this->load->load_helper('listing');
@@ -835,8 +937,10 @@
835 937
836 938 foreach($db_results as $row) {
837 939 $results[] = [
838 940 'id'=> wmvc_show_data($key_column, $row),
941 + // Dynamic field values are registered in the translation catalog separately.
942 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
839 943 'text'=> esc_html__(trim(wmvc_show_data($print_column, $row)),'wpdirectorykit'),
840 944 ];
841 945 }
842 946
@@ -904,9 +1008,9 @@
904 1008 foreach ($categories_search_column as $column) {
905 1009 if(!empty($sql_search))
906 1010 $sql_search .= " OR ";
907 1011
908 - $sql_search .= " ".esc_sql($column)." LIKE '%".esc_sql($search_text)."%'";
1012 + $sql_search .= " ".$this->category_m->_table_name.'.'.esc_sql($column)." LIKE '%".esc_sql($search_text)."%'";
909 1013 }
910 1014 $where ["($sql_search)"] = NULL;
911 1015 $db_results = $this->category_m->get_pagination($categories_limit, NULL, $where);
912 1016 } else {
@@ -918,9 +1022,11 @@
918 1022 'field_key' => 'search_category',
919 1023 'value' => $row->category_title,
920 1024 'print' => [
921 1025 'parsed_content' => [
922 - 'icon_class' => (!empty(wmvc_show_data('font_icon_code', $row, false))) ? wmvc_show_data('font_icon_code', $row) : 'fa fa-tag',
1026 + 'icon_class' => (!empty(wmvc_show_data('font_icon_code', $row, false))) ? esc_attr(wmvc_show_data('font_icon_code', $row)): 'fa fa-tag',
1027 + // Dynamic field values are registered in the translation catalog separately.
1028 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
923 1029 'title' => esc_html__($row->category_title, 'wpdirectorykit'),
924 1030 'sub_title' => '',
925 1031 'right_text' => __('Category', 'wpdirectorykit')
926 1032 ]
@@ -971,10 +1077,14 @@
971 1077 'field_key' => 'search_location',
972 1078 'value' => $row->location_title,
973 1079 'print' => [
974 1080 'parsed_content' => [
975 - 'icon_class' => (!empty(wmvc_show_data('font_icon_code', $row, false))) ? wmvc_show_data('font_icon_code', $row) : 'fa fa-map-marker',
1081 + 'icon_class' => (!empty(wmvc_show_data('font_icon_code', $row, false))) ? esc_attr(wmvc_show_data('font_icon_code', $row)) : 'fa fa-map-marker',
1082 + // Dynamic field values are registered in the translation catalog separately.
1083 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
976 1084 'title' => esc_html__($row->location_title, 'wpdirectorykit'),
1085 + // Dynamic field values are registered in the translation catalog separately.
1086 + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
977 1087 'sub_title' => esc_html__($subtitle, 'wpdirectorykit'),
978 1088 'right_text' => __('Location', 'wpdirectorykit')
979 1089 ]
980 1090 ]
@@ -983,14 +1093,15 @@
983 1093
984 1094 /* END Locations */
985 1095
986 1096 /* address suggestion if empty other */
987 - if(empty($results)) {
1097 + $limit = apply_filters('wdk/search_suggestion/address_limit', 5);
1098 + if(count($results)<10) {
988 1099 $this->db->select('address');
989 1100 $db_results = $this->db->where(array("address LIKE '%".esc_sql($search_text)."%'" => NULL));
990 1101 $this->db->from($this->listing_m->_table_name);
991 1102 $this->db->group_by('address');
992 - $this->db->limit(5);
1103 + $this->db->limit($limit);
993 1104
994 1105 $query = $this->db->get();
995 1106 if ($this->db->num_rows() > 0) {
996 1107 $db_results = $this->db->results();
@@ -1014,10 +1125,15 @@
1014 1125 }
1015 1126 }
1016 1127
1017 1128 /* listings by title suggestion */
1129 + // Example of how to use add_filter for 'wdk/search_suggestion/listings_limit'
1130 + // In your theme's functions.php or a custom plugin, you can add:
1131 + // add_filter('wdk/search_suggestion/listings_limit', function($limit) { return 10; });
1132 +
1133 + $limit = apply_filters('wdk/search_suggestion/listings_limit', 5);
1018 1134 $this->db->where(array("post_title LIKE '%".esc_sql($search_text)."%'" => NULL));
1019 - $db_results = $this->listing_m->get_pagination(5, NULL, array('is_activated' => 1,'is_approved'=>1));
1135 + $db_results = $this->listing_m->get_pagination($limit, NULL, array('is_activated' => 1,'is_approved'=>1));
1020 1136
1021 1137 if($db_results) foreach($db_results as $row) {
1022 1138 $results[] = [
1023 1139 'field_key' => 'link',
@@ -1032,9 +1148,9 @@
1032 1148 ]
1033 1149 ];
1034 1150 }
1035 1151
1036 - if(empty($results)) {
1152 + if(count($results)<10) {
1037 1153
1038 1154 $name_part = str_replace(' ','+',$search_text);
1039 1155
1040 1156 //$url = 'http://photon.komoot.de/api/?q='.$name_part;
@@ -1108,21 +1224,28 @@
1108 1224
1109 1225 if(isset($parameters['post_id'])) {
1110 1226 $post_id = $parameters['post_id'];
1111 1227 }
1228 +
1229 + $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id'=>$post_id), TRUE);
1230 + $time_format = "00:00:00";
1231 + if($calendar && $calendar->is_hour_enabled == 1)
1232 + $time_format = "H:i:s";
1233 +
1112 1234
1113 1235 if(isset($parameters['date_from'])) {
1114 - $date_from = wdk_normalize_date_db($parameters['date_from']);
1236 + $date_from = wdk_normalize_date_db($parameters['date_from'], 'Y-m-d H:i:s', 'Y-m-d '.$time_format);
1115 1237 }
1116 1238
1117 1239 if(isset($parameters['date_to'])) {
1118 - $date_to = wdk_normalize_date_db($parameters['date_to']);
1240 + $date_to = wdk_normalize_date_db($parameters['date_to'], 'Y-m-d H:i:s', 'Y-m-d '.$time_format);
1119 1241 }
1120 1242
1243 +
1121 1244 if($post_id && $date_from && $date_to) {
1122 1245 $price = $Winter_MVC_wdk_bookings->reservation_m->calculate_price($post_id, $date_from, $date_to);
1123 1246
1124 - $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id'=>$post_id), TRUE); // date_package_expire package_id
1247 +
1125 1248 $calendar_fees = array();
1126 1249 if($calendar && !empty($calendar->json_data_fees))
1127 1250 $calendar_fees = json_decode($calendar->json_data_fees );
1128 1251
@@ -1132,15 +1255,15 @@
1132 1255
1133 1256 if($price) {
1134 1257 $results['price'] = $price['price'];
1135 1258 $results['total'] = $price['price'];
1259 + $results['fees_data'] = array();
1136 1260 $results['fees'] = array();
1137 - foreach ($calendar_fees as $fee) {
1261 + foreach ($calendar_fees as $key => $fee) {
1138 1262 if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue;
1139 1263 if(is_intval(wmvc_show_data('value', $fee,'',TRUE,TRUE))) {
1140 - $field = str_replace(' ','_',strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
1264 + $field = wdk_generate_slug(strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
1141 1265 if(!wmvc_show_data('is_required', $fee, false,TRUE,TRUE) && isset($parameters['fee_'.$field]) && $parameters['fee_'.$field] == 0) {
1142 -
1143 1266 } else {
1144 1267 $price = 0;
1145 1268 if(wmvc_show_data('calculation_base', $fee,'',TRUE,TRUE) == 'per_night') {
1146 1269 $nights = (int)abs(strtotime($date_from) - strtotime($date_to))/(60*60*24);
@@ -1153,8 +1276,12 @@
1153 1276 $results['fees'][wmvc_show_data('title', $fee,'',TRUE,TRUE)] = $price;
1154 1277 $results['total'] += $price;
1155 1278 }
1156 1279 }
1280 +
1281 + $results['fees_data'][$key] = $fee;
1282 + $results['fees_data'][$key]->field_id = wdk_generate_slug(strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE))));
1283 + $results['fees_data'][$key]->calculation_base_text = (isset($Winter_MVC_wdk_bookings->calendar_m->calculation_base[wmvc_show_data('calculation_base', $fee,'-',TRUE,TRUE)])) ? $Winter_MVC_wdk_bookings->calendar_m->calculation_base[wmvc_show_data('calculation_base', $fee,'-',TRUE,TRUE)] : 'per stay';
1157 1284 }
1158 1285 $data['success'] = true;
1159 1286 } else {
1160 1287 $data['popup_text_error'] = __('Those dates are not available', 'wpdirectorykit');
@@ -1159,9 +1286,8 @@
1159 1286 } else {
1160 1287 $data['popup_text_error'] = __('Those dates are not available', 'wpdirectorykit');
1161 1288 }
1162 1289 }
1163 -
1164 1290
1165 1291 $data['results'] = $results;
1166 1292
1167 1293 //$data['sql'] = $this->db->last_query();
@@ -1166,9 +1292,418 @@
1166 1292
1167 1293 //$data['sql'] = $this->db->last_query();
1168 1294 $this->output($data);
1169 1295 }
1296 +
1297 + public function loading_listings() {
1298 + $this->load->load_helper('listing');
1299 + $this->load->load_helper('get_element_settings');
1300 + $this->load->model('listing_m');
1301 + $this->load->model('listingfield_m');
1302 + $this->load->model('category_m');
1303 +
1304 + $data = array();
1305 + $data['message'] = '';
1306 + $data['popup_text_success'] = '';
1307 + $data['popup_text_error'] = '';
1308 + $data['output'] = [
1309 + 'map_results'=>null,
1310 + 'listings_result'=>null,
1311 + 'listings_result_message'=>null,
1312 + 'pagination_html'=>null,
1313 + 'listings_count'=>null,
1314 + 'listings_count_html'=>null,
1315 + ];
1316 + $data['success'] = false;
1317 +
1318 + $parameters = array();
1319 + foreach ($_POST as $key => $value) {
1320 + $parameters[$key] = sanitize_text_field($value);
1321 + }
1322 +
1323 + $options = [
1324 + 'offset' => 0,
1325 + 'limit' => 6,
1326 + 'current_page' => 1,
1327 + 'limit_pagination' => 5,
1328 + 'layout_type' => 'grid',
1329 + ];
1330 +
1331 + $custom_parameters = array();
1332 + $parameters['url'] = strstr($parameters['url'], "#", true);
1333 + $parameters['url'] = strstr($parameters['url'], "?");
1334 + if(!empty($parameters['url'])) {
1335 + $qr_string = trim($parameters['url'],'?');
1336 + $string_par = array();
1337 + parse_str($qr_string, $string_par);
1338 + $custom_parameters += $string_par;
1339 + }
1340 +
1341 + $controller = 'listing';
1342 + $columns = array('ID', 'location_id', 'category_id', 'post_title', 'post_date', 'search', 'order_by','is_featured', 'address');
1343 + $external_columns = array('location_id', 'category_id', 'post_title');
1344 +
1345 + if(isset($parameters['el_results_id'])) {
1346 + wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
1347 + $data['output']['listings_count'] = $this->listing_m->total(array('is_activated' => 1,'is_approved'=>1));
1348 + $data['output']['listings_count_html'] = $data['output']['listings_count'].' '.esc_html__('Listings', 'wpdirectorykit');
1349 +
1350 + if(defined( 'WP_DEBUG' ) && WP_DEBUG)
1351 + $data['listings_count_sql'] = $this->db->last_query();
1352 +
1353 + if(isset($custom_parameters['wmvc_paged']))
1354 + $options['current_page'] = intval(wmvc_xss_clean($custom_parameters['wmvc_paged']));
1355 +
1356 + $get_settings_el_results = new WdkGetElementSettings($parameters['el_results_page_id'],$parameters['el_results_id'],$parameters['el_results_type']);
1357 + $settings_el_results = $get_settings_el_results->get_settings();
1358 + $settings_el_results = $settings_el_results['settings'] ?? [];
1359 +
1360 + if(wmvc_show_data('per_page', $settings_el_results, false)) {
1361 + $options['limit'] = wmvc_show_data('per_page', $settings_el_results, false);
1362 + }
1363 +
1364 + if(wmvc_show_data('layout_type', $settings_el_results, false)) {
1365 + $options['layout_type'] = wmvc_show_data('layout_type', $settings_el_results, false);
1366 + }
1367 +
1368 + $offset = $options['limit']*( $options['current_page']-1);
1369 +
1370 + global $_GET;
1371 + $temp_get = $_GET;
1372 + $_GET = $custom_parameters;
1373 + do_action('wpdirectorykit/ajax/loading_listings');
1374 + $REQUEST_URI = $_SERVER["REQUEST_URI"];
1375 +
1376 + $_SERVER["REQUEST_URI"] = $_SERVER['HTTP_REFERER'];
1377 +
1378 + $data['output']['pagination_html'] = wdk_wp_frontend_paginate($data['output']['listings_count'], $options['limit'], 'wmvc_paged', array(), TRUE,
1379 + FALSE, FALSE, $options['limit_pagination']);
1380 +
1381 + $_SERVER["REQUEST_URI"] = $REQUEST_URI;
1382 + $_GET = $temp_get;
1383 +
1384 + wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
1385 + $listings_result = $this->listing_m->get_pagination($options['limit'], $offset, array('is_activated' => 1,'is_approved'=>1));
1386 +
1387 + if(defined( 'WP_DEBUG' ) && WP_DEBUG)
1388 + $data['listings_result_sql'] = $this->db->last_query();
1389 +
1390 + if(wmvc_show_data('layout_type', $settings_el_results, false)) {
1391 + $settings_el_results['content_button_icon'] = $get_settings_el_results->generate_icon(wmvc_show_data('layout_type', $settings_el_results, false));
1392 + } else {
1393 + $settings_el_results['content_button_icon'] = '';
1394 + }
1395 +
1396 + if($listings_result) {
1397 + foreach ($listings_result as $key => $listing) {
1398 + $listing->card_view = '';
1399 +
1400 + if (
1401 + wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_listing_card_elementor_layout') &&
1402 + wmvc_show_data('is_custom_layout_enable', $settings_el_results) == 'yes'
1403 + ) {
1404 + if ($options['layout_type'] == 'list' && wmvc_show_data('custom_layout_id_list', $settings_el_results, false)) {
1405 + $content = '';
1406 + $post_data = get_post(wmvc_show_data('custom_layout_id_list', $settings_el_results, false));
1407 +
1408 + global $wdk_listing_id;
1409 + $wdk_listing_id = wmvc_show_data('post_id', $listing);
1410 + if ($post_data) {
1411 + if ($post_data->post_type == 'page' || $post_data->post_type == 'elementor_library') {
1412 + $elementor_instance = \Elementor\Plugin::instance();
1413 + $content = $elementor_instance->frontend->get_builder_content_for_display(wmvc_show_data('custom_layout_id_list', $settings_el_results, false));
1414 + if (empty($content))
1415 + $content = $post_data->post_content;
1416 + } else {
1417 + $content = $post_data->post_content;
1418 + }
1419 + }
1420 + $listing->card_view = ($content);
1421 + } elseif ($options['layout_type'] == 'grid' && wmvc_show_data('custom_layout_id_grid', $settings_el_results, false)) {
1422 + $content = '';
1423 + $post_data = get_post( wmvc_show_data('custom_layout_id_grid', $settings_el_results, false));
1424 +
1425 + global $wdk_listing_id;
1426 + $wdk_listing_id = wmvc_show_data('post_id', $listing);
1427 + if ($post_data) {
1428 + if ($post_data->post_type == 'page' || $post_data->post_type == 'elementor_library') {
1429 + $elementor_instance = \Elementor\Plugin::instance();
1430 + $content = $elementor_instance->frontend->get_builder_content_for_display(wmvc_show_data('custom_layout_id_grid', $settings_el_results, false));
1431 + if (empty($content))
1432 + $content = $post_data->post_content;
1433 + } else {
1434 + $content = $post_data->post_content;
1435 + }
1436 + }
1437 + $listing->card_view = ($content);
1438 + } else {
1439 + $listing->card_view = wdk_listing_card($listing, $settings_el_results);
1440 + }
1441 + } else {
1442 + $listing->card_view = wdk_listing_card($listing, $settings_el_results);
1443 + }
1444 +
1445 + $data['output']['listings_result'][] = $listing;
1446 + }
1447 + } else {
1448 + $data['output']['listings_result_message'] = '<p class="wdk_alert wdk_alert-danger">'.esc_html__('Results not found', 'wpdirectorykit').'</p>';
1449 + }
1450 +
1451 + }
1452 +
1453 + /* map results */
1454 + if(isset($parameters['el_map_id'])) {
1455 + wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
1456 + $map_results = $this->listing_m->get_pagination(NULL, NULL, array('is_activated' => 1,'is_approved'=>1));
1457 + if(defined( 'WP_DEBUG' ) && WP_DEBUG)
1458 + $data['map_results_sql'] = $this->db->last_query();
1459 +
1460 + $get_settings_el_map = new WdkGetElementSettings($parameters['el_map_page_id'],$parameters['el_map_id'],$parameters['el_map_type']);
1461 + $settings_el_map = $get_settings_el_map->get_settings();
1462 + $settings_el_map = $settings_el_map['settings'];
1463 +
1464 + foreach ($map_results as $key => $listing) {
1465 + $listing->inner_marker = '';
1466 +
1467 + $pin_icon = "";
1468 + $font_class = "";
1469 + $font_icon = (wmvc_show_data('conf_custom_map_pin_icon', $settings_el_map)) ? esc_url($get_settings_el_map->generate_icon($settings_el_map['conf_custom_map_pin_icon'])) : '<i class="fa fa-home"></i>';
1470 + $pin_icon = (isset( $settings_el_map['conf_custom_map_pin'])) ? esc_url($settings_el_map['conf_custom_map_pin']['url']) : '';
1471 +
1472 + if(wmvc_show_data('conf_hide_real_location', $category) == 'yes') {
1473 + $listing->listing_lat = wdk_move_gps($listing->listing_lat);
1474 + $listing->listing_lng = wdk_move_gps($listing->listing_lng);
1475 + }
1476 +
1477 + if(!empty(wmvc_show_data('category_id', $listing))){
1478 + $category = $this->category_m->get_data(wmvc_show_data('category_id', $listing));
1479 + if(wmvc_show_data('marker_image_id', $category, false, TRUE, TRUE)){
1480 + $pin_icon = wdk_image_src($category, 'full', NULL,'marker_image_id');
1481 + } else if(!empty(wmvc_show_data('font_icon_code', $category))) {
1482 + $font_class = wmvc_show_data('font_icon_code', $category);
1483 + }
1484 + } else {
1485 + $font_class = "";
1486 + }
1487 +
1488 + if($pin_icon){
1489 + $listing->inner_marker = '<div class="wdk_marker-container wdk_marker-container-image"><img src='.$pin_icon.'></img></div>';
1490 + }elseif($font_icon && empty($font_class)){
1491 + $listing->inner_marker = '<div class="wdk_marker-container category_id_'.esc_js(wmvc_show_data('category_id', $listing)).'"><div class="front wdk_face">'.$font_icon.'</div><div class="wdk_marker-card"><div class="wdk_marker-arrow"></div></div></div>';
1492 + }else{
1493 + $listing->inner_marker = '<div class="wdk_marker-container category_id_'.esc_js(wmvc_show_data('category_id', $listing)).'"><div class="front wdk_face"><i class="'.esc_html($font_class).'"></i></div><div class="wdk_marker-card"><div class="wdk_marker-arrow"></div></div></div>';
1494 + }
1495 +
1496 + $data['output']['map_results'][] = $listing;
1497 + }
1498 + }
1499 +
1500 + $data['success'] = true;
1501 + $this->output($data);
1502 +
1503 + }
1504 +
1170 1505
1506 + public function suggestion_locations (&$output=NULL, $atts=array())
1507 + {
1508 +
1509 + $this->load->load_helper('listing');
1510 + $this->load->model('category_m');
1511 + $this->load->model('location_m');
1512 + $this->load->model('listing_m');
1513 +
1514 + $data = array();
1515 + $data['message'] = __('No message returned!', 'wpdirectorykit');
1516 +
1517 + $data['results'] = array();
1518 + $parameters = array();
1519 + foreach ($_POST as $key => $value) {
1520 + $parameters[$key] = sanitize_text_field($value);
1521 + }
1522 +
1523 + $search_text = '';
1524 + if(!empty($parameters['search']))
1525 + $search_text = trim($parameters['search']);
1526 +
1527 + if(!empty($search_text)) {
1528 + $this->db->select("location_title as value");
1529 + $this->db->from($this->location_m->_table_name);
1530 + $this->db->where(array("location_title LIKE '%".esc_sql($search_text)."%'" => NULL));
1531 +
1532 + $query = $this->db->get();
1533 + if($this->db->num_rows() > 0) foreach($this->db->results() as $row) {
1534 + $data['results'][] = $row->value;
1535 + }
1536 + }
1537 +
1538 + $data['success'] = true;
1539 + $this->output($data);
1540 + }
1541 +
1542 + public function suggestion_categories (&$output=NULL, $atts=array())
1543 + {
1544 +
1545 + $this->load->load_helper('listing');
1546 + $this->load->model('category_m');
1547 +
1548 + $data = array();
1549 + $data['message'] = __('No message returned!', 'wpdirectorykit');
1550 +
1551 + $data['results'] = array();
1552 + $parameters = array();
1553 + foreach ($_POST as $key => $value) {
1554 + $parameters[$key] = sanitize_text_field($value);
1555 + }
1556 +
1557 + $search_text = '';
1558 + if(!empty($parameters['search']))
1559 + $search_text = trim($parameters['search']);
1560 +
1561 + if(!empty($search_text)) {
1562 + $this->db->select("category_title as value");
1563 + $this->db->from($this->category_m->_table_name);
1564 + $this->db->where(array("category_title LIKE '%".esc_sql($search_text)."%'" => NULL));
1565 +
1566 + $query = $this->db->get();
1567 + if($this->db->num_rows() > 0) foreach($this->db->results() as $row) {
1568 + $data['results'][] = $row->value;
1569 + }
1570 + }
1571 +
1572 + $data['success'] = true;
1573 + $this->output($data);
1574 + }
1575 +
1576 + public function suggestion_db_field (&$output=NULL, $atts=array())
1577 + {
1578 + $this->load->load_helper('listing');
1579 + $this->load->model('category_m');
1580 + $this->load->model('location_m');
1581 + $this->load->model('listing_m');
1582 +
1583 + $data = array();
1584 + $data['message'] = __('No message returned!', 'wpdirectorykit');
1585 +
1586 + $data['results'] = array();
1587 + $parameters = array();
1588 + foreach ($_POST as $key => $value) {
1589 + $parameters[$key] = sanitize_text_field($value);
1590 + }
1591 +
1592 + $search_text = '';
1593 + if(!empty($parameters['search']))
1594 + $search_text = trim($parameters['search']);
1595 +
1596 + $search_field_id = '';
1597 + if(!empty($parameters['field_id']))
1598 + $search_field_id = (int) trim($parameters['field_id']);
1599 +
1600 + if(!empty($search_field_id) && wdk_field_option($search_field_id, 'field_type', false)) {
1601 +
1602 + /* listings by title suggestion */
1603 + $this->db->select("DISTINCT field_".$search_field_id."_".wdk_field_option($search_field_id, 'field_type', false)." as value");
1604 + $this->db->from($this->db->prefix.'wdk_listings_fields');
1605 + $this->db->where(array("field_".$search_field_id."_".wdk_field_option($search_field_id, 'field_type', false)." LIKE '%".esc_sql($search_text)."%'" => NULL));
1606 +
1607 + $query = $this->db->get();
1608 + if($this->db->num_rows() > 0) foreach($this->db->results() as $row) {
1609 + $data['results'][] = $row->value;
1610 + }
1611 +
1612 + $field_values = wdk_field_option($search_field_id, 'values', '');
1613 + $field_values = explode(',', $field_values);
1614 + if(!empty($field_values)) {
1615 + foreach($field_values as $value) {
1616 + if(empty($value)) continue;
1617 + $data['results'][] = $value;
1618 + }
1619 + }
1620 +
1621 + }
1622 +
1623 + $data['success'] = true;
1624 + $this->output($data);
1625 +
1626 + }
1627 +
1628 + function select_2_ajax_field_db_suggestion($output="", $atts=array(), $instance=NULL)
1629 + {
1630 + global $Winter_MVC_WDK;
1631 + $Winter_MVC_WDK->load_helper('listing');
1632 + $Winter_MVC_WDK->model('location_m');
1633 +
1634 + $data = array();
1635 + $data['message'] = __('No message returned!', 'wpdirectorykit');
1636 + $data['pagination'] = true;
1637 + $results = array();
1638 +
1639 + $parameters = array();
1640 + foreach ($_POST as $key => $value) {
1641 + $parameters[$key] = sanitize_text_field($value);
1642 + }
1643 +
1644 + $limit = 10;
1645 + if(!empty($parameters['limit'])) {
1646 + $limit = intval($parameters['limit']);
1647 + }
1648 +
1649 + $offset = 0;
1650 + if(!empty($parameters['page_result']) && $parameters['page_result'] > 1) {
1651 + $offset = (intval($parameters['page_result']) - 1) * $limit;
1652 + }
1653 +
1654 + $search_text = '';
1655 + if(!empty($_POST['q']['term']))
1656 + $search_text = sanitize_text_field($_POST['q']['term']);
1657 +
1658 + $search_field_id = '';
1659 + if(!empty($parameters['field_id']))
1660 + $search_field_id = (int) trim($parameters['field_id']);
1661 +
1662 + if(!empty($search_field_id) && wdk_field_option($search_field_id, 'field_type', false)) {
1663 +
1664 + /* listings by title suggestion */
1665 + $Winter_MVC_WDK->db->select("DISTINCT field_".$search_field_id."_".wdk_field_option($search_field_id, 'field_type', false)." as value");
1666 + $Winter_MVC_WDK->db->from($Winter_MVC_WDK->db->prefix.'wdk_listings_fields');
1667 + $Winter_MVC_WDK->db->where(array("field_".$search_field_id."_".wdk_field_option($search_field_id, 'field_type', false)." LIKE '%".esc_sql($search_text)."%'" => NULL));
1668 +
1669 + $query = $Winter_MVC_WDK->db->get();
1670 + if($Winter_MVC_WDK->db->num_rows() > 0) foreach($Winter_MVC_WDK->db->results() as $row) {
1671 +
1672 + $results[] = [
1673 + 'id'=> $row->value,
1674 + 'text'=> $row->value,
1675 + ];
1676 + }
1677 +
1678 + $field_values = wdk_field_option($search_field_id, 'values', '');
1679 + $field_values = explode(',', $field_values);
1680 + if(!empty($field_values)) {
1681 + foreach($field_values as $value) {
1682 + if(empty($value)) continue;
1683 +
1684 + $results[] = [
1685 + 'id'=> $value,
1686 + 'text'=> $value,
1687 + ];
1688 + }
1689 + }
1690 +
1691 + }
1692 +
1693 + $data['success'] = true;
1694 +
1695 + $data['results'] = array_slice($results, $offset, $limit);
1696 + if(count($results) >= $limit + $offset) {
1697 + $data['pagination'] =[
1698 + "more"=> true
1699 + ];
1700 + }
1701 +
1702 + $data['success'] = true;
1703 + $this->output($data);
1704 + }
1705 +
1171 1706 private function get_fa_icons() {
1172 1707
1173 1708 /* icons font Awesome 5 */
1174 1709
@@ -1241,9 +1776,9 @@
1241 1776 "fas fa-user-circle","far fa-user-circle","fas fa-user-md","fas fa-user-plus","fas fa-user-secret","fas fa-user-times","fas fa-users","fab fa-ussunnah","fas fa-utensil-spoon","fas fa-utensils","fab fa-vaadin","fas fa-venus",
1242 1777 "fas fa-venus-double","fas fa-venus-mars","fab fa-viacoin","fab fa-viadeo","fab fa-viadeo-square","fab fa-viber","fas fa-video","fab fa-vimeo","fab fa-vimeo-square","fab fa-vimeo-v","fab fa-vine","fab fa-vk","fab fa-vnv",
1243 1778 "fas fa-volume-down","fas fa-volume-off","fas fa-volume-up","fab fa-vuejs","fab fa-weibo","fab fa-weixin","fab fa-whatsapp","fab fa-whatsapp-square","fas fa-wheelchair","fab fa-whmcs","fas fa-wifi","fab fa-wikipedia-w","fas fa-window-close",
1244 1779 "far fa-window-close","fas fa-window-maximize","far fa-window-maximize","fas fa-window-minimize","fas fa-window-restore","far fa-window-restore","fab fa-windows","fas fa-won-sign","fab fa-wordpress","fab fa-wordpress-simple",
1245 - "fab fa-wpbeginner","fab fa-wpexplorer","fab fa-wpforms","fas fa-wrench","fab fa-xbox","fab fa-xing","fab fa-xing-square","fab fa-y-combinator","fab fa-yahoo","fab fa-yandex","fab fa-yandex-international","fab fa-yelp","fas fa-yen-sign","fab fa-yoast","fab fa-youtube");
1780 + "fab fa-wpbeginner","fab fa-wpexplorer","fab fa-wpforms","fas fa-wrench","fab fa-xbox","fab fa-xing","fab fa-xing-square","fab fa-y-combinator","fab fa-yahoo","fab fa-yandex","fab fa-yandex-international","fab fa-yelp","fas fa-yen-sign","fab fa-yoast","fab fa-youtube","fas fa-school");
1246 1781
1247 1782
1248 1783 /* icons font Awesome 4 */
1249 1784 return array("fa fa-500px","fa fa-address-book","fa fa-address-book-o","fa fa-address-card","fa fa-address-card-o","fa fa-adjust","fa fa-adn","fa fa-align-center","fa fa-align-justify","fa fa-align-left","fa fa-align-right",
@@ -1292,13 +1827,14 @@
1292 1827 "fa fa-stop-circle-o","fa fa-street-view","fa fa-strikethrough","fa fa-stumbleupon","fa fa-stumbleupon-circle","fa fa-subscript","fa fa-subway","fa fa-suitcase","fa fa-sun-o","fa fa-superpowers","fa fa-superscript","fa fa-table",
1293 1828 "fa fa-tablet","fa fa-tachometer","fa fa-tag","fa fa-tags","fa fa-tasks","fa fa-taxi","fa fa-telegram","fa fa-television","fa fa-tencent-weibo","fa fa-terminal","fa fa-text-height","fa fa-text-width","fa fa-th","fa fa-th-large","fa fa-th-list",
1294 1829 "fa fa-themeisle","fa fa-thermometer-empty","fa fa-thermometer-full","fa fa-thermometer-half","fa fa-thermometer-quarter","fa fa-thermometer-three-quarters","fa fa-thumb-tack","fa fa-thumbs-down","fa fa-thumbs-o-down",
1295 1830 "fa fa-thumbs-o-up","fa fa-thumbs-up","fa fa-ticket","fa fa-times","fa fa-times-circle","fa fa-times-circle-o","fa fa-tint","fa fa-toggle-off","fa fa-toggle-on","fa fa-trademark","fa fa-train","fa fa-transgender","fa fa-transgender-alt",
1296 - "fa fa-trash","fa fa-trash-o","fa fa-tree","fa fa-trello","fa fa-tripadvisor","fa fa-trophy","fa fa-truck","fa fa-try","fa fa-tty","fa fa-tumblr","fa fa-tumblr-square","fa fa-twitch","fa fa-twitter","fa fa-twitter-square","fa fa-umbrella",
1831 + "fa fa-trash","fa fa-trash-o","fa fa-tree","fa fa-trello","fa fa-tripadvisor","fa fa-trophy","fa fa-truck","fa fa-try","fa fa-tty","fa fa-tumblr","fa fa-tumblr-square","fa fa-twitch","fab fa-x-twitter","fab fa-x-twitter-square","fa fa-umbrella",
1297 1832 "fa fa-underline","fa fa-undo","fa fa-universal-access","fa fa-university","fa fa-unlock","fa fa-unlock-alt","fa fa-upload","fa fa-usb","fa fa-usd","fa fa-user","fa fa-user-circle","fa fa-user-circle-o","fa fa-user-md","fa fa-user-o",
1298 1833 "fa fa-user-plus","fa fa-user-secret","fa fa-user-times","fa fa-users","fa fa-venus","fa fa-venus-double","fa fa-venus-mars","fa fa-viacoin","fa fa-viadeo","fa fa-viadeo-square","fa fa-video-camera","fa fa-vimeo","fa fa-vimeo-square","fa fa-vine",
1299 1834 "fa fa-vk","fa fa-volume-control-phone","fa fa-volume-down","fa fa-volume-off","fa fa-volume-up","fa fa-weibo","fa fa-weixin","fa fa-whatsapp","fa fa-wheelchair","fa fa-wheelchair-alt","fa fa-wifi","fa fa-wikipedia-w","fa fa-window-close",
1300 1835 "fa fa-window-close-o","fa fa-window-maximize","fa fa-window-minimize","fa fa-window-restore","fa fa-windows","fa fa-wordpress","fa fa-wpbeginner","fa fa-wpexplorer","fa fa-wpforms","fa fa-wrench","fa fa-xing","fa fa-xing-square",
1301 - "fa fa-y-combinator","fa fa-yahoo","fa fa-yelp","fa fa-yoast","fa fa-youtube","fa fa-youtube-play","fa fa-youtube-square");
1302 - }
1836 + "fa fa-y-combinator","fa fa-yahoo","fa fa-yelp","fa fa-yoast","fa fa-youtube","fa fa-youtube-play","fa fa-youtube-square","fa-solid fa-school");
1837 + }
1303 1838
1304 1839 }
1840 +