| @@ -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,8 +157,10 @@ | ||
| 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 | 164 | |
| 130 | 165 | $attr_id = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_id'])); |
| 131 | 166 | $attr_val = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_value'])); |
| @@ -130,11 +165,11 @@ | ||
| 130 | 165 | $attr_id = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_id'])); |
| 131 | 166 | $attr_val = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_value'])); |
| 132 | 167 | |
| 133 | 168 | |
| 134 | - $attr_search = sanitize_text_field($parameters['search_term']); | |
| 135 | - $skip_id = intval($parameters['skip_id']); | |
| 136 | - $language_id = intval($parameters['language_id']); | |
| 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); | |
| 137 | 172 | |
| 138 | 173 | if(empty($language_id)) |
| 139 | 174 | $language_id = NULL; |
| 140 | 175 | |
| @@ -176,13 +211,30 @@ | ||
| 176 | 211 | } elseif($attr_val == 'category_title'){ |
| 177 | 212 | $this->load->model($table); |
| 178 | 213 | $attr_val_sql = $this->$table->_table_name.'.category_title'; |
| 179 | 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 | + } | |
| 180 | 223 | |
| 181 | - $where["($id_part $attr_val_sql LIKE '%$attr_search%')"] = NULL; | |
| 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; | |
| 182 | 233 | } |
| 183 | 234 | |
| 184 | 235 | if(!empty($parameters['hide_fields'])) { |
| 236 | + $parameters['hide_fields'] = preg_replace('/[^0-9,]/', '', $parameters['hide_fields']); | |
| 185 | 237 | if($table == 'location_m') { |
| 186 | 238 | $sql_where = esc_sql($this->$table->_table_name.'.idlocation').' NOT IN ('.esc_sql(sanitize_text_field($parameters['hide_fields'])).')'; |
| 187 | 239 | foreach (explode(',', $parameters['hide_fields']) as $key => $id) { |
| 188 | 240 | $sql_where .= ' AND CONCAT(",", '.$this->$table->_table_name.'.parent_path, ",") NOT LIKE CONCAT("%,", '.intval($id).', ",%")'; |
| @@ -199,17 +251,14 @@ | ||
| 199 | 251 | $where[$sql_where] = NULL; |
| 200 | 252 | } |
| 201 | 253 | } |
| 202 | 254 | |
| 203 | - if(!empty($parameters['attr_search'])) | |
| 204 | - $where[$parameters['attr_search']] = NULL; | |
| 205 | - | |
| 206 | 255 | if(isset($parameters['user_check']) && ($parameters['user_check'] == 'true' || $parameters['user_check'] == '1')) { |
| 207 | 256 | if($table == 'listing_m') { |
| 208 | 257 | if($parameters['table'] == 'calendar_listing_m') { |
| 209 | 258 | global $Winter_MVC_wdk_bookings; |
| 210 | 259 | $Winter_MVC_wdk_bookings->model('calendar_m'); |
| 211 | - $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'); | |
| 212 | 261 | } |
| 213 | 262 | |
| 214 | 263 | $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where, TRUE, get_current_user_id()); |
| 215 | 264 | } else { |
| @@ -214,9 +263,9 @@ | ||
| 214 | 263 | $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where, TRUE, get_current_user_id()); |
| 215 | 264 | } else { |
| 216 | 265 | |
| 217 | 266 | if(!empty($parameters['filter_ids'])){ |
| 218 | - $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)); | |
| 219 | 268 | } |
| 220 | 269 | |
| 221 | 270 | $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where ); |
| 222 | 271 | } |
| @@ -223,13 +272,13 @@ | ||
| 223 | 272 | } else { |
| 224 | 273 | if($parameters['table'] == 'calendar_listing_m') { |
| 225 | 274 | global $Winter_MVC_wdk_bookings; |
| 226 | 275 | $Winter_MVC_wdk_bookings->model('calendar_m'); |
| 227 | - $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'); | |
| 228 | 277 | } |
| 229 | 278 | |
| 230 | 279 | if(!empty($parameters['filter_ids'])){ |
| 231 | - $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)); | |
| 232 | 281 | } |
| 233 | 282 | |
| 234 | 283 | if($table == 'user_m') { |
| 235 | 284 | $like = "(meta_value LIKE '%wdk_%' )"; |
| @@ -246,8 +295,9 @@ | ||
| 246 | 295 | $tree_results = $this->$table->get_pagination_simple(intval($parameters['limit']),intval($parameters['offset']), $where); |
| 247 | 296 | } else { |
| 248 | 297 | $tree_results = $this->$table->get_pagination(intval($parameters['limit']),intval($parameters['offset']), $where); |
| 249 | 298 | } |
| 299 | + | |
| 250 | 300 | } |
| 251 | 301 | } |
| 252 | 302 | |
| 253 | 303 | } |
| @@ -264,9 +314,12 @@ | ||
| 264 | 314 | $results[$ind_order]['value'] = $level_gen |
| 265 | 315 | .'#'.wmvc_show_data($attr_id, $row).', '.wmvc_show_data($attr_val, $row); |
| 266 | 316 | } elseif($table == 'user_m') { |
| 267 | 317 | $results[$ind_order]['value'] = $level_gen |
| 268 | - .'#'.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).')'; | |
| 269 | 322 | } elseif($table == 'icons_list') { |
| 270 | 323 | $results[$ind_order]['key'] = $row; |
| 271 | 324 | if(defined('ELEMENTOR_ASSETS_URL')){ |
| 272 | 325 | $results[$ind_order]['value'] = '<i class="'. $row.'"></i> '.$row; |
| @@ -274,8 +327,10 @@ | ||
| 274 | 327 | $results[$ind_order]['value'] = $row; |
| 275 | 328 | } |
| 276 | 329 | } else { |
| 277 | 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 | |
| 278 | 333 | .esc_html__(wmvc_show_data($attr_val, $row), 'wpdirectorykit'); |
| 279 | 334 | } |
| 280 | 335 | $ind_order++; |
| 281 | 336 | } |
| @@ -301,11 +356,14 @@ | ||
| 301 | 356 | $level_gen = str_pad('', $row->level*12, ' ').''; |
| 302 | 357 | |
| 303 | 358 | if($table == 'user_m') { |
| 304 | 359 | $data['curr_val'] = $level_gen |
| 305 | - .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 | + | |
| 306 | 362 | } else { |
| 307 | 363 | $data['curr_val'] = $level_gen |
| 364 | + // Dynamic field values are registered in the translation catalog separately. | |
| 365 | + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText | |
| 308 | 366 | .esc_html__(wmvc_show_data(wmvc_show_data('attribute_value', $parameters), $row), 'wpdirectorykit'); |
| 309 | 367 | } |
| 310 | 368 | |
| 311 | 369 | |
| @@ -319,14 +377,16 @@ | ||
| 319 | 377 | |
| 320 | 378 | $this->data['success'] = true; |
| 321 | 379 | |
| 322 | 380 | $data['results'] = $results; |
| 323 | - //$data['sql'] = $this->db->last_query(); | |
| 381 | + $data['sql'] = $this->db->last_query(); | |
| 324 | 382 | $this->output($data); |
| 325 | 383 | } |
| 326 | 384 | |
| 327 | 385 | public function treefieldid_checkboxes($output="", $atts=array(), $instance=NULL) |
| 328 | 386 | { |
| 387 | + check_ajax_referer('wdk_secure_treefieldid_checkboxes', 'wdk_secure'); | |
| 388 | + | |
| 329 | 389 | $this->load->load_helper('listing'); |
| 330 | 390 | $this->load->model('listing_m'); |
| 331 | 391 | $this->load->model('listingfield_m'); |
| 332 | 392 | |
| @@ -383,9 +443,9 @@ | ||
| 383 | 443 | $table_name = substr($table,0, -2); |
| 384 | 444 | $attr_id = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_id'])); |
| 385 | 445 | $attr_val = preg_replace("/[^0-9a-zA-Z_\-]/", "",sanitize_text_field($parameters['attribute_value'])); |
| 386 | 446 | |
| 387 | - $attr_search = sanitize_text_field($parameters['search_term']); | |
| 447 | + $attr_search = wdk_esc_sql(sanitize_text_field($parameters['search_term'])); | |
| 388 | 448 | $skip_id = intval($parameters['skip_id']); |
| 389 | 449 | $language_id = intval($parameters['language_id']); |
| 390 | 450 | |
| 391 | 451 | if(empty($language_id)) |
| @@ -398,9 +458,23 @@ | ||
| 398 | 458 | $this->load->model($table); |
| 399 | 459 | |
| 400 | 460 | $where = array(); |
| 401 | 461 | if(!empty($attr_search)) |
| 402 | - $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 | + } | |
| 403 | 477 | |
| 404 | 478 | if(isset($parameters['selected']) && !empty($parameters['selected'])) { |
| 405 | 479 | |
| 406 | 480 | if(is_string($parameters['selected']) && strpos($parameters['selected'], ',') !== FALSE){ |
| @@ -425,12 +499,13 @@ | ||
| 425 | 499 | } |
| 426 | 500 | } |
| 427 | 501 | |
| 428 | 502 | if(!empty($parameters['filter_ids'])){ |
| 429 | - $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)); | |
| 430 | 504 | } |
| 431 | 505 | |
| 432 | 506 | if(!empty($parameters['hide_fields'])) { |
| 507 | + $parameters['hide_fields'] = preg_replace('/[^0-9,]/', '', $parameters['hide_fields']); | |
| 433 | 508 | if($table == 'location_m') { |
| 434 | 509 | $sql_where = esc_sql($this->$table->_table_name.'.idlocation').' NOT IN ('.esc_sql(sanitize_text_field($parameters['hide_fields'])).')'; |
| 435 | 510 | foreach (explode(',', $parameters['hide_fields']) as $key => $id) { |
| 436 | 511 | $sql_where .= ' AND CONCAT(",", '.$this->$table->_table_name.'.parent_path, ",") NOT LIKE CONCAT("%,", '.intval($id).', ",%")'; |
| @@ -458,8 +533,10 @@ | ||
| 458 | 533 | $level_gen = str_pad('', $row->level*12, ' ').''; |
| 459 | 534 | |
| 460 | 535 | $results[$ind_order]['key'] = wmvc_show_data($attr_id, $row); |
| 461 | 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 | |
| 462 | 539 | .esc_html__(wmvc_show_data($attr_val, $row), 'wpdirectorykit'); |
| 463 | 540 | $ind_order++; |
| 464 | 541 | } |
| 465 | 542 | |
| @@ -472,10 +549,11 @@ | ||
| 472 | 549 | { |
| 473 | 550 | $level_gen=''; |
| 474 | 551 | if(isset($row->level)) |
| 475 | 552 | $level_gen = str_pad('', $row->level*12, ' ').''; |
| 476 | - | |
| 477 | - $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 | |
| 478 | 556 | .esc_html__(wmvc_show_data(wmvc_show_data('attribute_value', $parameters), $row), 'wpdirectorykit'); |
| 479 | 557 | |
| 480 | 558 | } |
| 481 | 559 | else |
| @@ -505,8 +583,11 @@ | ||
| 505 | 583 | |
| 506 | 584 | |
| 507 | 585 | public function select_2_ajax($output="", $atts=array(), $instance=NULL) |
| 508 | 586 | { |
| 587 | + | |
| 588 | + check_ajax_referer('wdk_secure_ajax', 'wdk_secure'); | |
| 589 | + | |
| 509 | 590 | $this->load->load_helper('listing'); |
| 510 | 591 | $this->load->model('listing_m'); |
| 511 | 592 | $this->load->model('listingfield_m'); |
| 512 | 593 | |
| @@ -523,8 +604,14 @@ | ||
| 523 | 604 | if(empty($parameters['table'])) return false; |
| 524 | 605 | |
| 525 | 606 | $model_name = $parameters['table']; |
| 526 | 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 | + | |
| 527 | 614 | $key_column = ''; |
| 528 | 615 | $print_column = ''; |
| 529 | 616 | |
| 530 | 617 | $search_column = ''; |
| @@ -531,13 +618,13 @@ | ||
| 531 | 618 | if(empty($parameters['columns_search'])) { |
| 532 | 619 | switch ($model_name) { |
| 533 | 620 | case 'category_m': |
| 534 | 621 | $this->load->model($model_name); |
| 535 | - $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'; | |
| 536 | 623 | break; |
| 537 | 624 | case 'location_m': |
| 538 | 625 | $this->load->model($model_name); |
| 539 | - $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'; | |
| 540 | 627 | break; |
| 541 | 628 | |
| 542 | 629 | default: |
| 543 | 630 | # code... |
| @@ -544,9 +631,9 @@ | ||
| 544 | 631 | break; |
| 545 | 632 | } |
| 546 | 633 | |
| 547 | 634 | } else { |
| 548 | - $search_column = $parameters['columns_search']; | |
| 635 | + $search_column = esc_sql(preg_replace('/[^a-z0-9_,]/i', '', $parameters['columns_search'])); | |
| 549 | 636 | } |
| 550 | 637 | |
| 551 | 638 | if(empty($parameters['key_column'])) { |
| 552 | 639 | switch ($model_name) { |
| @@ -610,9 +697,8 @@ | ||
| 610 | 697 | } |
| 611 | 698 | |
| 612 | 699 | $db_results_total = $this->$model_name->total($where); |
| 613 | 700 | $db_results = $this->$model_name->get_pagination($limit,$offset, $where); |
| 614 | - $data['output'] = $db_results; | |
| 615 | 701 | |
| 616 | 702 | if (!$db_results) { |
| 617 | 703 | $data['errors'] = ''; |
| 618 | 704 | } else { |
| @@ -623,8 +709,10 @@ | ||
| 623 | 709 | $level_gen = str_pad('', $row->level*12, ' ').''; |
| 624 | 710 | |
| 625 | 711 | $results[] = [ |
| 626 | 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 | |
| 627 | 715 | 'text'=> $level_gen.esc_html__(trim(wmvc_show_data($print_column, $row)), 'wpdirectorykit'), |
| 628 | 716 | ]; |
| 629 | 717 | } |
| 630 | 718 | |
| @@ -674,9 +762,13 @@ | ||
| 674 | 762 | $offset = (intval($parameters['page_result']) - 1) * $limit; |
| 675 | 763 | } |
| 676 | 764 | |
| 677 | 765 | $this->load->model($model_name); |
| 678 | - $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 | + | |
| 679 | 771 | $where = array(); |
| 680 | 772 | if(!empty($_POST['q']['term']) && !empty($search_column)) { |
| 681 | 773 | $sql_search = ''; |
| 682 | 774 | foreach (explode(',', $search_column) as $column) { |
| @@ -694,9 +786,8 @@ | ||
| 694 | 786 | $like = "(meta_value LIKE '%wdk_%' )"; |
| 695 | 787 | $db_results_total = $this->$model_name->total($where, NULL, $like); |
| 696 | 788 | |
| 697 | 789 | $db_results = $this->$model_name->get_pagination($limit,$offset, $where, NULL, $like); |
| 698 | - $data['output'] = $db_results; | |
| 699 | 790 | |
| 700 | 791 | if (!$db_results) { |
| 701 | 792 | $data['errors'] = ''; |
| 702 | 793 | } else { |
| @@ -846,8 +937,10 @@ | ||
| 846 | 937 | |
| 847 | 938 | foreach($db_results as $row) { |
| 848 | 939 | $results[] = [ |
| 849 | 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 | |
| 850 | 943 | 'text'=> esc_html__(trim(wmvc_show_data($print_column, $row)),'wpdirectorykit'), |
| 851 | 944 | ]; |
| 852 | 945 | } |
| 853 | 946 | |
| @@ -915,9 +1008,9 @@ | ||
| 915 | 1008 | foreach ($categories_search_column as $column) { |
| 916 | 1009 | if(!empty($sql_search)) |
| 917 | 1010 | $sql_search .= " OR "; |
| 918 | 1011 | |
| 919 | - $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)."%'"; | |
| 920 | 1013 | } |
| 921 | 1014 | $where ["($sql_search)"] = NULL; |
| 922 | 1015 | $db_results = $this->category_m->get_pagination($categories_limit, NULL, $where); |
| 923 | 1016 | } else { |
| @@ -929,9 +1022,11 @@ | ||
| 929 | 1022 | 'field_key' => 'search_category', |
| 930 | 1023 | 'value' => $row->category_title, |
| 931 | 1024 | 'print' => [ |
| 932 | 1025 | 'parsed_content' => [ |
| 933 | - '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 | |
| 934 | 1029 | 'title' => esc_html__($row->category_title, 'wpdirectorykit'), |
| 935 | 1030 | 'sub_title' => '', |
| 936 | 1031 | 'right_text' => __('Category', 'wpdirectorykit') |
| 937 | 1032 | ] |
| @@ -982,10 +1077,14 @@ | ||
| 982 | 1077 | 'field_key' => 'search_location', |
| 983 | 1078 | 'value' => $row->location_title, |
| 984 | 1079 | 'print' => [ |
| 985 | 1080 | 'parsed_content' => [ |
| 986 | - '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 | |
| 987 | 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 | |
| 988 | 1087 | 'sub_title' => esc_html__($subtitle, 'wpdirectorykit'), |
| 989 | 1088 | 'right_text' => __('Location', 'wpdirectorykit') |
| 990 | 1089 | ] |
| 991 | 1090 | ] |
| @@ -994,14 +1093,15 @@ | ||
| 994 | 1093 | |
| 995 | 1094 | /* END Locations */ |
| 996 | 1095 | |
| 997 | 1096 | /* address suggestion if empty other */ |
| 998 | - if(empty($results)) { | |
| 1097 | + $limit = apply_filters('wdk/search_suggestion/address_limit', 5); | |
| 1098 | + if(count($results)<10) { | |
| 999 | 1099 | $this->db->select('address'); |
| 1000 | 1100 | $db_results = $this->db->where(array("address LIKE '%".esc_sql($search_text)."%'" => NULL)); |
| 1001 | 1101 | $this->db->from($this->listing_m->_table_name); |
| 1002 | 1102 | $this->db->group_by('address'); |
| 1003 | - $this->db->limit(5); | |
| 1103 | + $this->db->limit($limit); | |
| 1004 | 1104 | |
| 1005 | 1105 | $query = $this->db->get(); |
| 1006 | 1106 | if ($this->db->num_rows() > 0) { |
| 1007 | 1107 | $db_results = $this->db->results(); |
| @@ -1025,10 +1125,15 @@ | ||
| 1025 | 1125 | } |
| 1026 | 1126 | } |
| 1027 | 1127 | |
| 1028 | 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); | |
| 1029 | 1134 | $this->db->where(array("post_title LIKE '%".esc_sql($search_text)."%'" => NULL)); |
| 1030 | - $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)); | |
| 1031 | 1136 | |
| 1032 | 1137 | if($db_results) foreach($db_results as $row) { |
| 1033 | 1138 | $results[] = [ |
| 1034 | 1139 | 'field_key' => 'link', |
| @@ -1043,9 +1148,9 @@ | ||
| 1043 | 1148 | ] |
| 1044 | 1149 | ]; |
| 1045 | 1150 | } |
| 1046 | 1151 | |
| 1047 | - if(empty($results)) { | |
| 1152 | + if(count($results)<10) { | |
| 1048 | 1153 | |
| 1049 | 1154 | $name_part = str_replace(' ','+',$search_text); |
| 1050 | 1155 | |
| 1051 | 1156 | //$url = 'http://photon.komoot.de/api/?q='.$name_part; |
| @@ -1119,21 +1224,28 @@ | ||
| 1119 | 1224 | |
| 1120 | 1225 | if(isset($parameters['post_id'])) { |
| 1121 | 1226 | $post_id = $parameters['post_id']; |
| 1122 | 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 | + | |
| 1123 | 1234 | |
| 1124 | 1235 | if(isset($parameters['date_from'])) { |
| 1125 | - $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); | |
| 1126 | 1237 | } |
| 1127 | 1238 | |
| 1128 | 1239 | if(isset($parameters['date_to'])) { |
| 1129 | - $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); | |
| 1130 | 1241 | } |
| 1131 | 1242 | |
| 1243 | + | |
| 1132 | 1244 | if($post_id && $date_from && $date_to) { |
| 1133 | 1245 | $price = $Winter_MVC_wdk_bookings->reservation_m->calculate_price($post_id, $date_from, $date_to); |
| 1134 | 1246 | |
| 1135 | - $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id'=>$post_id), TRUE); // date_package_expire package_id | |
| 1247 | + | |
| 1136 | 1248 | $calendar_fees = array(); |
| 1137 | 1249 | if($calendar && !empty($calendar->json_data_fees)) |
| 1138 | 1250 | $calendar_fees = json_decode($calendar->json_data_fees ); |
| 1139 | 1251 | |
| @@ -1212,8 +1324,9 @@ | ||
| 1212 | 1324 | 'offset' => 0, |
| 1213 | 1325 | 'limit' => 6, |
| 1214 | 1326 | 'current_page' => 1, |
| 1215 | 1327 | 'limit_pagination' => 5, |
| 1328 | + 'layout_type' => 'grid', | |
| 1216 | 1329 | ]; |
| 1217 | 1330 | |
| 1218 | 1331 | $custom_parameters = array(); |
| 1219 | 1332 | $parameters['url'] = strstr($parameters['url'], "#", true); |
| @@ -1236,8 +1349,23 @@ | ||
| 1236 | 1349 | |
| 1237 | 1350 | if(defined( 'WP_DEBUG' ) && WP_DEBUG) |
| 1238 | 1351 | $data['listings_count_sql'] = $this->db->last_query(); |
| 1239 | 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 | + | |
| 1240 | 1368 | $offset = $options['limit']*( $options['current_page']-1); |
| 1241 | 1369 | |
| 1242 | 1370 | global $_GET; |
| 1243 | 1371 | $temp_get = $_GET; |
| @@ -1242,11 +1370,16 @@ | ||
| 1242 | 1370 | global $_GET; |
| 1243 | 1371 | $temp_get = $_GET; |
| 1244 | 1372 | $_GET = $custom_parameters; |
| 1245 | 1373 | do_action('wpdirectorykit/ajax/loading_listings'); |
| 1374 | + $REQUEST_URI = $_SERVER["REQUEST_URI"]; | |
| 1246 | 1375 | |
| 1376 | + $_SERVER["REQUEST_URI"] = $_SERVER['HTTP_REFERER']; | |
| 1377 | + | |
| 1247 | 1378 | $data['output']['pagination_html'] = wdk_wp_frontend_paginate($data['output']['listings_count'], $options['limit'], 'wmvc_paged', array(), TRUE, |
| 1248 | 1379 | FALSE, FALSE, $options['limit_pagination']); |
| 1380 | + | |
| 1381 | + $_SERVER["REQUEST_URI"] = $REQUEST_URI; | |
| 1249 | 1382 | $_GET = $temp_get; |
| 1250 | 1383 | |
| 1251 | 1384 | wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters); |
| 1252 | 1385 | $listings_result = $this->listing_m->get_pagination($options['limit'], $offset, array('is_activated' => 1,'is_approved'=>1)); |
| @@ -1253,12 +1386,8 @@ | ||
| 1253 | 1386 | |
| 1254 | 1387 | if(defined( 'WP_DEBUG' ) && WP_DEBUG) |
| 1255 | 1388 | $data['listings_result_sql'] = $this->db->last_query(); |
| 1256 | 1389 | |
| 1257 | - $get_settings_el_results = new WdkGetElementSettings($parameters['el_results_page_id'],$parameters['el_results_id'],$parameters['el_results_type']); | |
| 1258 | - $settings_el_results = $get_settings_el_results->get_settings(); | |
| 1259 | - $settings_el_results = $settings_el_results['settings']; | |
| 1260 | - | |
| 1261 | 1390 | if(wmvc_show_data('layout_type', $settings_el_results, false)) { |
| 1262 | 1391 | $settings_el_results['content_button_icon'] = $get_settings_el_results->generate_icon(wmvc_show_data('layout_type', $settings_el_results, false)); |
| 1263 | 1392 | } else { |
| 1264 | 1393 | $settings_el_results['content_button_icon'] = ''; |
| @@ -1271,9 +1400,9 @@ | ||
| 1271 | 1400 | if ( |
| 1272 | 1401 | wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_listing_card_elementor_layout') && |
| 1273 | 1402 | wmvc_show_data('is_custom_layout_enable', $settings_el_results) == 'yes' |
| 1274 | 1403 | ) { |
| 1275 | - if (wmvc_show_data('layout_type', $settings_el_results) == 'list' && wmvc_show_data('custom_layout_id_list', $settings_el_results, false)) { | |
| 1404 | + if ($options['layout_type'] == 'list' && wmvc_show_data('custom_layout_id_list', $settings_el_results, false)) { | |
| 1276 | 1405 | $content = ''; |
| 1277 | 1406 | $post_data = get_post(wmvc_show_data('custom_layout_id_list', $settings_el_results, false)); |
| 1278 | 1407 | |
| 1279 | 1408 | global $wdk_listing_id; |
| @@ -1287,10 +1416,10 @@ | ||
| 1287 | 1416 | } else { |
| 1288 | 1417 | $content = $post_data->post_content; |
| 1289 | 1418 | } |
| 1290 | 1419 | } |
| 1291 | - //$listing->card_view = wp_kses_post($content); | |
| 1292 | - } elseif (wmvc_show_data('layout_type', $settings_el_results) == 'grid' && wmvc_show_data('custom_layout_id_grid', $settings_el_results, false)) { | |
| 1420 | + $listing->card_view = ($content); | |
| 1421 | + } elseif ($options['layout_type'] == 'grid' && wmvc_show_data('custom_layout_id_grid', $settings_el_results, false)) { | |
| 1293 | 1422 | $content = ''; |
| 1294 | 1423 | $post_data = get_post( wmvc_show_data('custom_layout_id_grid', $settings_el_results, false)); |
| 1295 | 1424 | |
| 1296 | 1425 | global $wdk_listing_id; |
| @@ -1304,9 +1433,9 @@ | ||
| 1304 | 1433 | } else { |
| 1305 | 1434 | $content = $post_data->post_content; |
| 1306 | 1435 | } |
| 1307 | 1436 | } |
| 1308 | - //$listing->card_view = wp_kses_post($content); | |
| 1437 | + $listing->card_view = ($content); | |
| 1309 | 1438 | } else { |
| 1310 | 1439 | $listing->card_view = wdk_listing_card($listing, $settings_el_results); |
| 1311 | 1440 | } |
| 1312 | 1441 | } else { |
| @@ -1324,9 +1453,11 @@ | ||
| 1324 | 1453 | /* map results */ |
| 1325 | 1454 | if(isset($parameters['el_map_id'])) { |
| 1326 | 1455 | wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters); |
| 1327 | 1456 | $map_results = $this->listing_m->get_pagination(NULL, NULL, array('is_activated' => 1,'is_approved'=>1)); |
| 1328 | - | |
| 1457 | + if(defined( 'WP_DEBUG' ) && WP_DEBUG) | |
| 1458 | + $data['map_results_sql'] = $this->db->last_query(); | |
| 1459 | + | |
| 1329 | 1460 | $get_settings_el_map = new WdkGetElementSettings($parameters['el_map_page_id'],$parameters['el_map_id'],$parameters['el_map_type']); |
| 1330 | 1461 | $settings_el_map = $get_settings_el_map->get_settings(); |
| 1331 | 1462 | $settings_el_map = $settings_el_map['settings']; |
| 1332 | 1463 | |
| @@ -1335,9 +1466,9 @@ | ||
| 1335 | 1466 | |
| 1336 | 1467 | $pin_icon = ""; |
| 1337 | 1468 | $font_class = ""; |
| 1338 | 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>'; |
| 1339 | - $pin_icon = (isset( $settings_el_map['conf_custom_map_pin'])) ? esc_url($get_settings_el_map['conf_custom_map_pin']['url']) : ''; | |
| 1470 | + $pin_icon = (isset( $settings_el_map['conf_custom_map_pin'])) ? esc_url($settings_el_map['conf_custom_map_pin']['url']) : ''; | |
| 1340 | 1471 | |
| 1341 | 1472 | if(wmvc_show_data('conf_hide_real_location', $category) == 'yes') { |
| 1342 | 1473 | $listing->listing_lat = wdk_move_gps($listing->listing_lat); |
| 1343 | 1474 | $listing->listing_lng = wdk_move_gps($listing->listing_lng); |
| @@ -1363,11 +1494,8 @@ | ||
| 1363 | 1494 | } |
| 1364 | 1495 | |
| 1365 | 1496 | $data['output']['map_results'][] = $listing; |
| 1366 | 1497 | } |
| 1367 | - | |
| 1368 | - if(defined( 'WP_DEBUG' ) && WP_DEBUG) | |
| 1369 | - $data['map_results_sql'] = $this->db->last_query(); | |
| 1370 | 1498 | } |
| 1371 | 1499 | |
| 1372 | 1500 | $data['success'] = true; |
| 1373 | 1501 | $this->output($data); |
| @@ -1372,9 +1500,210 @@ | ||
| 1372 | 1500 | $data['success'] = true; |
| 1373 | 1501 | $this->output($data); |
| 1374 | 1502 | |
| 1375 | 1503 | } |
| 1504 | + | |
| 1376 | 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 | + | |
| 1377 | 1706 | private function get_fa_icons() { |
| 1378 | 1707 | |
| 1379 | 1708 | /* icons font Awesome 5 */ |
| 1380 | 1709 | |
| @@ -1447,9 +1776,9 @@ | ||
| 1447 | 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", |
| 1448 | 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", |
| 1449 | 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", |
| 1450 | 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", |
| 1451 | - "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"); | |
| 1452 | 1781 | |
| 1453 | 1782 | |
| 1454 | 1783 | /* icons font Awesome 4 */ |
| 1455 | 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", |
| @@ -1498,14 +1827,14 @@ | ||
| 1498 | 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", |
| 1499 | 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", |
| 1500 | 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", |
| 1501 | 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", |
| 1502 | - "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", | |
| 1503 | 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", |
| 1504 | 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", |
| 1505 | 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", |
| 1506 | 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", |
| 1507 | - "fa fa-y-combinator","fa fa-yahoo","fa fa-yelp","fa fa-yoast","fa fa-youtube","fa fa-youtube-play","fa fa-youtube-square"); | |
| 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"); | |
| 1508 | 1837 | } |
| 1509 | 1838 | |
| 1510 | 1839 | } |
| 1511 | 1840 | |