| @@ -139,9 +139,10 @@ | ||
| 139 | 139 | $image = wp_get_attachment_url( $image_id, $size ); |
| 140 | 140 | $output[] = $image; |
| 141 | 141 | */ |
| 142 | 142 | $image = wp_get_attachment_image_src( $image_id, $size ); |
| 143 | - $output[] = $image[0]; | |
| 143 | + if($image) | |
| 144 | + $output[] = $image[0]; | |
| 144 | 145 | } |
| 145 | 146 | } |
| 146 | 147 | } else if(is_numeric($image_ids)) |
| 147 | 148 | { |
| @@ -248,8 +249,61 @@ | ||
| 248 | 249 | return $output; |
| 249 | 250 | } |
| 250 | 251 | } |
| 251 | 252 | |
| 253 | +if(!function_exists('wdk_files_data')) { | |
| 254 | + /** | |
| 255 | + * Initialize the class and set its properties. | |
| 256 | + * | |
| 257 | + * @param string files ids | |
| 258 | + * @param string $size The size of image | |
| 259 | + * @param string|array $ext_list Allowed extensions, mixed sring with separated like jpg,doc,pdf or array | |
| 260 | + * @return array | |
| 261 | + */ | |
| 262 | + function wdk_files_data ($listing = '', $size = 'thumb', $ext_list = array()) { | |
| 263 | + $output = array(); | |
| 264 | + | |
| 265 | + $image_ids = ''; | |
| 266 | + if(is_string($listing)){ | |
| 267 | + $image_ids = explode(',', $listing); | |
| 268 | + } | |
| 269 | + | |
| 270 | + if(is_string($ext_list)){ | |
| 271 | + if(!empty($ext_list)) { | |
| 272 | + $ext_list = explode(',', $ext_list); | |
| 273 | + } else { | |
| 274 | + $ext_list = array(); | |
| 275 | + } | |
| 276 | + } | |
| 277 | + if(is_array($image_ids)) { | |
| 278 | + foreach ($image_ids as $key => $image_id) { | |
| 279 | + if(is_numeric($image_id)) | |
| 280 | + { | |
| 281 | + $image = wp_get_attachment_url( $image_id, $size ); | |
| 282 | + if(!empty($ext_list) && !in_array(wdk_file_extension($image), $ext_list)) { | |
| 283 | + continue; | |
| 284 | + } | |
| 285 | + | |
| 286 | + if(empty($image)/* || !file_exists(str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $image))*/) | |
| 287 | + { | |
| 288 | + $image = wdk_placeholder_image_src(); | |
| 289 | + } | |
| 290 | + $attr = wdk_image_attr($image_id); | |
| 291 | + $output[] = array('src' =>$image, 'title' => $attr['title'], 'alt' => $attr['alt']); | |
| 292 | + } | |
| 293 | + } | |
| 294 | + } else if(is_numeric($image_ids)) | |
| 295 | + { | |
| 296 | + $image = wp_get_attachment_url( $image_ids, $size ); | |
| 297 | + if(!empty($ext_list) && !in_array(wdk_file_extension($image), $ext_list)) { | |
| 298 | + $attr = wdk_image_attr($image_ids); | |
| 299 | + $output[] = array('src' =>$image, 'title' => $attr['title'], 'alt' => $attr['alt']); | |
| 300 | + } | |
| 301 | + } | |
| 302 | + return $output; | |
| 303 | + } | |
| 304 | +} | |
| 305 | + | |
| 252 | 306 | if(!function_exists('wdk_image_src')) { |
| 253 | 307 | /** |
| 254 | 308 | * Initialize the class and set its properties. |
| 255 | 309 | * |
| @@ -425,9 +479,9 @@ | ||
| 425 | 479 | foreach ($list as $key => $field) { |
| 426 | 480 | $row = array(); |
| 427 | 481 | $row['value'] = wdk_field_value($field->field_id, $listing, $default); |
| 428 | 482 | |
| 429 | - if(wmvc_show_data('field_id', $field) == 'agent_image') { | |
| 483 | + if(in_array(wmvc_show_data('field_id', $field), array('agent_image','agent_email','agent_name'))) { | |
| 430 | 484 | $row['value'] = wmvc_show_data('user_id_editor', $listing); |
| 431 | 485 | } |
| 432 | 486 | |
| 433 | 487 | if(empty($row['value']) && !empty(wdk_field_option($field->field_id,'empty_value', false))) |
| @@ -447,8 +501,9 @@ | ||
| 447 | 501 | { |
| 448 | 502 | $tree_data = $category_static[$row['value']]; |
| 449 | 503 | } |
| 450 | 504 | |
| 505 | + $row['field_label'] = esc_html__('Category','wpdirectorykit'); | |
| 451 | 506 | $row['value'] = wmvc_show_data('category_title', $tree_data); |
| 452 | 507 | |
| 453 | 508 | if(isset($listing->categories_list)){ |
| 454 | 509 | $other_categories = wdk_generate_other_categories_fast($listing->categories_list); |
| @@ -467,8 +522,9 @@ | ||
| 467 | 522 | { |
| 468 | 523 | $tree_data = $location_static[$row['value']]; |
| 469 | 524 | } |
| 470 | 525 | |
| 526 | + $row['field_label'] = esc_html__('Location','wpdirectorykit'); | |
| 471 | 527 | $row['value'] = wmvc_show_data('location_title', $tree_data); |
| 472 | 528 | |
| 473 | 529 | if(isset($listing->locations_list)){ |
| 474 | 530 | $other_locations = wdk_generate_other_locations_fast($listing->locations_list); |
| @@ -475,9 +531,13 @@ | ||
| 475 | 531 | if(!empty($other_locations)) |
| 476 | 532 | $row['value'] .=', '.join(', ',$other_locations); |
| 477 | 533 | } |
| 478 | 534 | } else if(wdk_field_option($field->field_id, 'field_type') == 'DATE') { |
| 535 | + $row['field_label'] = esc_html__('Date','wpdirectorykit'); | |
| 479 | 536 | $row['value'] = wdk_generate_field_date($field->field_id, $listing); |
| 537 | + } else if(wmvc_show_data('field_id', $field) == 'date_modified') { | |
| 538 | + $row['field_label'] = esc_html__('Date','wpdirectorykit'); | |
| 539 | + $row['value'] = wdk_generate_field_date($field->field_id, $listing); | |
| 480 | 540 | } else { |
| 481 | 541 | |
| 482 | 542 | } |
| 483 | 543 | |
| @@ -548,18 +608,37 @@ | ||
| 548 | 608 | /* Favorite module */ |
| 549 | 609 | $data ['favorite_added'] = wmvc_show_data('is_favorite', $listing, false, TRUE, TRUE); |
| 550 | 610 | /* End Favorite module */ |
| 551 | 611 | |
| 552 | - $output = $WMVC->view('frontend/'.$template, $data, FALSE); | |
| 612 | + if(is_intval($template)) { | |
| 613 | + $output = ''; | |
| 614 | + $post_data = get_post($template); | |
| 553 | 615 | |
| 616 | + global $wdk_listing_id; | |
| 617 | + $wdk_listing_id = wmvc_show_data('post_id', $listing); | |
| 618 | + | |
| 619 | + if ($post_data) { | |
| 620 | + if ($post_data->post_type == 'page' || $post_data->post_type == 'elementor_library') { | |
| 621 | + $elementor_instance = \Elementor\Plugin::instance(); | |
| 622 | + $output = $elementor_instance->frontend->get_builder_content_for_display($template); | |
| 623 | + if (empty($output)) | |
| 624 | + $output = $post_data->post_content; | |
| 625 | + } else { | |
| 626 | + $output = $post_data->post_content; | |
| 627 | + } | |
| 628 | + } | |
| 629 | + } else { | |
| 630 | + $output = $WMVC->view('frontend/'.$template, $data, FALSE); | |
| 631 | + } | |
| 554 | 632 | $output = sprintf($html_sprintf, $output); |
| 633 | + | |
| 555 | 634 | if($json_output) { |
| 556 | 635 | $output = str_replace("'", "\'", $output); |
| 557 | 636 | $output = str_replace('"', '\"', $output); |
| 558 | 637 | $output = str_replace(array("\n", "\r"), '', $output); |
| 559 | 638 | } |
| 560 | - | |
| 561 | - return ($output); | |
| 639 | + | |
| 640 | + return $output; | |
| 562 | 641 | } |
| 563 | 642 | } |
| 564 | 643 | |
| 565 | 644 | if(!function_exists('wdk_image_alt')) { |
| @@ -797,9 +876,9 @@ | ||
| 797 | 876 | return $default; |
| 798 | 877 | } |
| 799 | 878 | |
| 800 | 879 | if(wdk_field_option($field_id, 'is_price_format') && wdk_field_option($field_id, 'field_type') == 'NUMBER') { |
| 801 | - $value = wdk_number_format_i18n(wdk_filter_decimal($value)); | |
| 880 | + $value = wdk_filter_decimal(wdk_number_format_i18n($value)); | |
| 802 | 881 | } elseif(wdk_field_option($field_id, 'field_type') == 'DATE') { |
| 803 | 882 | $value = wdk_get_date($value, FALSE); |
| 804 | 883 | } else { |
| 805 | 884 | $value = wdk_filter_decimal($value); |
| @@ -914,8 +993,11 @@ | ||
| 914 | 993 | |
| 915 | 994 | if(!empty($user_data)) { |
| 916 | 995 | if(wmvc_show_data($field,$user_data['userdata'], false, TRUE, TRUE)) { |
| 917 | 996 | $output = wmvc_show_data($field,$user_data['userdata'], false, TRUE, TRUE); |
| 997 | + } | |
| 998 | + if(wmvc_show_data($field, $user_data, false, TRUE, TRUE)) { | |
| 999 | + $output = wmvc_show_data($field,$user_data, false, TRUE, TRUE); | |
| 918 | 1000 | } |
| 919 | 1001 | } |
| 920 | 1002 | |
| 921 | 1003 | return $output; |