| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | if ( ! defined( 'ABSPATH' ) ) { |
| 12: | exit; |
| 13: | } |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | class EPL_Elementor_Property_Icons extends \Elementor\Widget_Base { |
| 23: | use EPL_Elementor_Dynamic_Widget; |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | public function get_name() { |
| 32: | return 'epl-property-icons'; |
| 33: | } |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | public function get_title() { |
| 42: | return esc_html__( 'Icons', 'easy-property-listings' ); |
| 43: | } |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | public function get_icon() { |
| 52: | return 'eicon-info-circle-o'; |
| 53: | } |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | |
| 60: | |
| 61: | public function get_categories() { |
| 62: | return array( 'epl-elements' ); |
| 63: | } |
| 64: | |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | |
| 70: | |
| 71: | public function get_keywords() { |
| 72: | return array( 'property', 'icons', 'bed', 'bath', 'parking', 'epl' ); |
| 73: | } |
| 74: | |
| 75: | |
| 76: | |
| 77: | |
| 78: | |
| 79: | protected function register_controls() { |
| 80: | |
| 81: | |
| 82: | $this->start_controls_section( |
| 83: | 'section_layout', |
| 84: | array( |
| 85: | 'label' => esc_html__( 'Layout', 'easy-property-listings' ), |
| 86: | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 87: | ) |
| 88: | ); |
| 89: | |
| 90: | $this->add_control( |
| 91: | 'layout', |
| 92: | array( |
| 93: | 'label' => esc_html__( 'Layout', 'easy-property-listings' ), |
| 94: | 'type' => \Elementor\Controls_Manager::SELECT, |
| 95: | 'options' => array( |
| 96: | 'horizontal' => esc_html__( 'Horizontal', 'easy-property-listings' ), |
| 97: | 'vertical' => esc_html__( 'Vertical', 'easy-property-listings' ), |
| 98: | ), |
| 99: | 'default' => 'horizontal', |
| 100: | ) |
| 101: | ); |
| 102: | |
| 103: | $this->add_control( |
| 104: | 'show_icons', |
| 105: | array( |
| 106: | 'label' => esc_html__( 'Show Icons', 'easy-property-listings' ), |
| 107: | 'type' => \Elementor\Controls_Manager::SWITCHER, |
| 108: | 'label_on' => esc_html__( 'Yes', 'easy-property-listings' ), |
| 109: | 'label_off' => esc_html__( 'No', 'easy-property-listings' ), |
| 110: | 'return_value' => 'yes', |
| 111: | 'default' => 'yes', |
| 112: | ) |
| 113: | ); |
| 114: | |
| 115: | $this->add_control( |
| 116: | 'show_labels', |
| 117: | array( |
| 118: | 'label' => esc_html__( 'Show Labels', 'easy-property-listings' ), |
| 119: | 'type' => \Elementor\Controls_Manager::SWITCHER, |
| 120: | 'label_on' => esc_html__( 'Yes', 'easy-property-listings' ), |
| 121: | 'label_off' => esc_html__( 'No', 'easy-property-listings' ), |
| 122: | 'return_value' => 'yes', |
| 123: | 'default' => '', |
| 124: | 'description' => esc_html__( 'Show text labels (e.g., "Beds", "Baths")', 'easy-property-listings' ), |
| 125: | ) |
| 126: | ); |
| 127: | |
| 128: | $this->add_control( |
| 129: | 'divider_switch', |
| 130: | array( |
| 131: | 'label' => esc_html__( 'Divider', 'easy-property-listings' ), |
| 132: | 'type' => \Elementor\Controls_Manager::SWITCHER, |
| 133: | 'label_on' => esc_html__( 'Show', 'easy-property-listings' ), |
| 134: | 'label_off' => esc_html__( 'Hide', 'easy-property-listings' ), |
| 135: | 'return_value' => 'yes', |
| 136: | 'default' => '', |
| 137: | ) |
| 138: | ); |
| 139: | |
| 140: | $this->add_control( |
| 141: | 'divider_text', |
| 142: | array( |
| 143: | 'label' => esc_html__( 'Divider Character', 'easy-property-listings' ), |
| 144: | 'type' => \Elementor\Controls_Manager::TEXT, |
| 145: | 'default' => '|', |
| 146: | 'condition' => array( |
| 147: | 'divider_switch' => 'yes', |
| 148: | ), |
| 149: | ) |
| 150: | ); |
| 151: | |
| 152: | $this->end_controls_section(); |
| 153: | |
| 154: | |
| 155: | $this->start_controls_section( |
| 156: | 'section_icons', |
| 157: | array( |
| 158: | 'label' => esc_html__( 'Icons', 'easy-property-listings' ), |
| 159: | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 160: | ) |
| 161: | ); |
| 162: | |
| 163: | $repeater = new \Elementor\Repeater(); |
| 164: | |
| 165: | $repeater->add_control( |
| 166: | 'icon_type', |
| 167: | array( |
| 168: | 'label' => esc_html__( 'Data Type', 'easy-property-listings' ), |
| 169: | 'type' => \Elementor\Controls_Manager::SELECT, |
| 170: | 'options' => array( |
| 171: | 'bed' => esc_html__( 'Bedrooms', 'easy-property-listings' ), |
| 172: | 'bath' => esc_html__( 'Bathrooms', 'easy-property-listings' ), |
| 173: | 'parking' => esc_html__( 'Parking', 'easy-property-listings' ), |
| 174: | 'land' => esc_html__( 'Land Size', 'easy-property-listings' ), |
| 175: | 'building' => esc_html__( 'Building Size', 'easy-property-listings' ), |
| 176: | 'rooms' => esc_html__( 'Rooms', 'easy-property-listings' ), |
| 177: | 'pool' => esc_html__( 'Pool', 'easy-property-listings' ), |
| 178: | 'ac' => esc_html__( 'Air Conditioning', 'easy-property-listings' ), |
| 179: | ), |
| 180: | 'default' => 'bed', |
| 181: | ) |
| 182: | ); |
| 183: | |
| 184: | $repeater->add_control( |
| 185: | 'selected_icon', |
| 186: | array( |
| 187: | 'label' => esc_html__( 'Icon', 'easy-property-listings' ), |
| 188: | 'type' => \Elementor\Controls_Manager::ICONS, |
| 189: | 'default' => array( |
| 190: | 'value' => 'fas fa-bed', |
| 191: | 'library' => 'fa-solid', |
| 192: | ), |
| 193: | ) |
| 194: | ); |
| 195: | |
| 196: | $repeater->add_control( |
| 197: | 'custom_label', |
| 198: | array( |
| 199: | 'label' => esc_html__( 'Custom Label', 'easy-property-listings' ), |
| 200: | 'type' => \Elementor\Controls_Manager::TEXT, |
| 201: | 'default' => '', |
| 202: | 'placeholder' => esc_html__( 'Leave empty for default', 'easy-property-listings' ), |
| 203: | ) |
| 204: | ); |
| 205: | |
| 206: | $repeater->add_control( |
| 207: | 'hide_if_empty', |
| 208: | array( |
| 209: | 'label' => esc_html__( 'Hide if Empty', 'easy-property-listings' ), |
| 210: | 'type' => \Elementor\Controls_Manager::SWITCHER, |
| 211: | 'label_on' => esc_html__( 'Yes', 'easy-property-listings' ), |
| 212: | 'label_off' => esc_html__( 'No', 'easy-property-listings' ), |
| 213: | 'return_value' => 'yes', |
| 214: | 'default' => 'yes', |
| 215: | ) |
| 216: | ); |
| 217: | |
| 218: | $this->add_control( |
| 219: | 'icon_list', |
| 220: | array( |
| 221: | 'label' => esc_html__( 'Icon List', 'easy-property-listings' ), |
| 222: | 'type' => \Elementor\Controls_Manager::REPEATER, |
| 223: | 'fields' => $repeater->get_controls(), |
| 224: | 'default' => array( |
| 225: | array( |
| 226: | 'icon_type' => 'bed', |
| 227: | 'selected_icon' => array( |
| 228: | 'value' => 'fas fa-bed', |
| 229: | 'library' => 'fa-solid', |
| 230: | ), |
| 231: | 'custom_label' => '', |
| 232: | 'hide_if_empty' => 'yes', |
| 233: | ), |
| 234: | array( |
| 235: | 'icon_type' => 'bath', |
| 236: | 'selected_icon' => array( |
| 237: | 'value' => 'fas fa-bath', |
| 238: | 'library' => 'fa-solid', |
| 239: | ), |
| 240: | 'custom_label' => '', |
| 241: | 'hide_if_empty' => 'yes', |
| 242: | ), |
| 243: | array( |
| 244: | 'icon_type' => 'parking', |
| 245: | 'selected_icon' => array( |
| 246: | 'value' => 'fas fa-car', |
| 247: | 'library' => 'fa-solid', |
| 248: | ), |
| 249: | 'custom_label' => '', |
| 250: | 'hide_if_empty' => 'yes', |
| 251: | ), |
| 252: | ), |
| 253: | 'title_field' => '<# var iconLabels = ' . wp_json_encode( |
| 254: | array( |
| 255: | 'bed' => esc_html__( 'Bedrooms', 'easy-property-listings' ), |
| 256: | 'bath' => esc_html__( 'Bathrooms', 'easy-property-listings' ), |
| 257: | 'parking' => esc_html__( 'Parking', 'easy-property-listings' ), |
| 258: | 'land' => esc_html__( 'Land Size', 'easy-property-listings' ), |
| 259: | 'building' => esc_html__( 'Building Size', 'easy-property-listings' ), |
| 260: | 'rooms' => esc_html__( 'Rooms', 'easy-property-listings' ), |
| 261: | 'pool' => esc_html__( 'Pool', 'easy-property-listings' ), |
| 262: | 'ac' => esc_html__( 'Air Conditioning', 'easy-property-listings' ), |
| 263: | ) |
| 264: | ) . '; #>{{{ iconLabels[icon_type] || icon_type }}}', |
| 265: | ) |
| 266: | ); |
| 267: | |
| 268: | $this->end_controls_section(); |
| 269: | |
| 270: | |
| 271: | $this->start_controls_section( |
| 272: | 'section_style', |
| 273: | array( |
| 274: | 'label' => esc_html__( 'Style', 'easy-property-listings' ), |
| 275: | 'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 276: | ) |
| 277: | ); |
| 278: | |
| 279: | $this->add_control( |
| 280: | 'icon_color', |
| 281: | array( |
| 282: | 'label' => esc_html__( 'Icon Color', 'easy-property-listings' ), |
| 283: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 284: | 'selectors' => array( |
| 285: | '{{WRAPPER}} .epl-property-icons .epl-icon-item i' => 'color: {{VALUE}};', |
| 286: | '{{WRAPPER}} .epl-property-icons .epl-icon-item svg' => 'fill: {{VALUE}};', |
| 287: | ), |
| 288: | 'condition' => array( |
| 289: | 'show_icons' => 'yes', |
| 290: | ), |
| 291: | ) |
| 292: | ); |
| 293: | |
| 294: | $this->add_control( |
| 295: | 'text_color', |
| 296: | array( |
| 297: | 'label' => esc_html__( 'Value/Text Color', 'easy-property-listings' ), |
| 298: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 299: | 'selectors' => array( |
| 300: | '{{WRAPPER}} .epl-property-icons .epl-icon-item' => 'color: {{VALUE}};', |
| 301: | ), |
| 302: | ) |
| 303: | ); |
| 304: | |
| 305: | $this->add_control( |
| 306: | 'divider_style_heading', |
| 307: | array( |
| 308: | 'label' => esc_html__( 'Divider', 'easy-property-listings' ), |
| 309: | 'type' => \Elementor\Controls_Manager::HEADING, |
| 310: | 'separator' => 'before', |
| 311: | 'condition' => array( |
| 312: | 'divider_switch' => 'yes', |
| 313: | ), |
| 314: | ) |
| 315: | ); |
| 316: | |
| 317: | $this->add_control( |
| 318: | 'divider_color', |
| 319: | array( |
| 320: | 'label' => esc_html__( 'Divider Color', 'easy-property-listings' ), |
| 321: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 322: | 'selectors' => array( |
| 323: | '{{WRAPPER}} .epl-property-icons .epl-icon-divider' => 'color: {{VALUE}};', |
| 324: | ), |
| 325: | 'condition' => array( |
| 326: | 'divider_switch' => 'yes', |
| 327: | ), |
| 328: | ) |
| 329: | ); |
| 330: | |
| 331: | $this->add_responsive_control( |
| 332: | 'divider_size', |
| 333: | array( |
| 334: | 'label' => esc_html__( 'Divider Size', 'easy-property-listings' ), |
| 335: | 'type' => \Elementor\Controls_Manager::SLIDER, |
| 336: | 'size_units' => array( 'px', 'em' ), |
| 337: | 'range' => array( |
| 338: | 'px' => array( |
| 339: | 'min' => 10, |
| 340: | 'max' => 50, |
| 341: | ), |
| 342: | ), |
| 343: | 'selectors' => array( |
| 344: | '{{WRAPPER}} .epl-property-icons .epl-icon-divider' => 'font-size: {{SIZE}}{{UNIT}};', |
| 345: | ), |
| 346: | 'condition' => array( |
| 347: | 'divider_switch' => 'yes', |
| 348: | ), |
| 349: | ) |
| 350: | ); |
| 351: | |
| 352: | $this->add_group_control( |
| 353: | \Elementor\Group_Control_Typography::get_type(), |
| 354: | array( |
| 355: | 'name' => 'typography', |
| 356: | 'selector' => '{{WRAPPER}} .epl-property-icons .epl-icon-item, {{WRAPPER}} .epl-property-icons .epl-icon-divider', |
| 357: | 'separator' => 'before', |
| 358: | ) |
| 359: | ); |
| 360: | |
| 361: | $this->add_responsive_control( |
| 362: | 'icon_size', |
| 363: | array( |
| 364: | 'label' => esc_html__( 'Icon Size', 'easy-property-listings' ), |
| 365: | 'type' => \Elementor\Controls_Manager::SLIDER, |
| 366: | 'size_units' => array( 'px', 'em' ), |
| 367: | 'range' => array( |
| 368: | 'px' => array( |
| 369: | 'min' => 10, |
| 370: | 'max' => 100, |
| 371: | ), |
| 372: | ), |
| 373: | 'default' => array( |
| 374: | 'size' => 16, |
| 375: | 'unit' => 'px', |
| 376: | ), |
| 377: | 'selectors' => array( |
| 378: | '{{WRAPPER}} .epl-property-icons .epl-icon-item i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 379: | '{{WRAPPER}} .epl-property-icons .epl-icon-item svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 380: | ), |
| 381: | 'condition' => array( |
| 382: | 'show_icons' => 'yes', |
| 383: | ), |
| 384: | ) |
| 385: | ); |
| 386: | |
| 387: | $this->add_responsive_control( |
| 388: | 'icon_gap', |
| 389: | array( |
| 390: | 'label' => esc_html__( 'Content Gap', 'easy-property-listings' ), |
| 391: | 'type' => \Elementor\Controls_Manager::SLIDER, |
| 392: | 'size_units' => array( 'px' ), |
| 393: | 'range' => array( |
| 394: | 'px' => array( |
| 395: | 'min' => 0, |
| 396: | 'max' => 30, |
| 397: | ), |
| 398: | ), |
| 399: | 'default' => array( |
| 400: | 'size' => 5, |
| 401: | 'unit' => 'px', |
| 402: | ), |
| 403: | 'selectors' => array( |
| 404: | '{{WRAPPER}} .epl-property-icons .epl-icon-item' => 'gap: {{SIZE}}{{UNIT}};', |
| 405: | ), |
| 406: | ) |
| 407: | ); |
| 408: | |
| 409: | $this->add_responsive_control( |
| 410: | 'item_spacing', |
| 411: | array( |
| 412: | 'label' => esc_html__( 'Spacing Between Items', 'easy-property-listings' ), |
| 413: | 'type' => \Elementor\Controls_Manager::SLIDER, |
| 414: | 'size_units' => array( 'px' ), |
| 415: | 'range' => array( |
| 416: | 'px' => array( |
| 417: | 'min' => 0, |
| 418: | 'max' => 50, |
| 419: | ), |
| 420: | ), |
| 421: | 'default' => array( |
| 422: | 'size' => 15, |
| 423: | 'unit' => 'px', |
| 424: | ), |
| 425: | 'selectors' => array( |
| 426: | '{{WRAPPER}} .epl-property-icons' => 'gap: {{SIZE}}{{UNIT}};', |
| 427: | ), |
| 428: | ) |
| 429: | ); |
| 430: | |
| 431: | $this->add_responsive_control( |
| 432: | 'minimum_height', |
| 433: | array( |
| 434: | 'label' => esc_html__( 'Minimum Height', 'easy-property-listings' ), |
| 435: | 'type' => \Elementor\Controls_Manager::SLIDER, |
| 436: | 'size_units' => array( 'px' ), |
| 437: | 'range' => array( |
| 438: | 'px' => array( |
| 439: | 'min' => 0, |
| 440: | 'max' => 200, |
| 441: | ), |
| 442: | ), |
| 443: | 'default' => array( |
| 444: | 'size' => 25, |
| 445: | 'unit' => 'px', |
| 446: | ), |
| 447: | 'selectors' => array( |
| 448: | '{{WRAPPER}} .epl-property-icons' => 'min-height: {{SIZE}}{{UNIT}};', |
| 449: | ), |
| 450: | ) |
| 451: | ); |
| 452: | |
| 453: | $this->add_responsive_control( |
| 454: | 'alignment', |
| 455: | array( |
| 456: | 'label' => esc_html__( 'Alignment', 'easy-property-listings' ), |
| 457: | 'type' => \Elementor\Controls_Manager::CHOOSE, |
| 458: | 'options' => array( |
| 459: | 'flex-start' => array( |
| 460: | 'title' => esc_html__( 'Left', 'easy-property-listings' ), |
| 461: | 'icon' => 'eicon-text-align-left', |
| 462: | ), |
| 463: | 'center' => array( |
| 464: | 'title' => esc_html__( 'Center', 'easy-property-listings' ), |
| 465: | 'icon' => 'eicon-text-align-center', |
| 466: | ), |
| 467: | 'flex-end' => array( |
| 468: | 'title' => esc_html__( 'Right', 'easy-property-listings' ), |
| 469: | 'icon' => 'eicon-text-align-right', |
| 470: | ), |
| 471: | ), |
| 472: | 'selectors' => array( |
| 473: | '{{WRAPPER}} .epl-property-icons' => 'justify-content: {{VALUE}};', |
| 474: | ), |
| 475: | ) |
| 476: | ); |
| 477: | |
| 478: | $this->end_controls_section(); |
| 479: | } |
| 480: | |
| 481: | |
| 482: | |
| 483: | |
| 484: | |
| 485: | protected function render() { |
| 486: | $property = EPL_Elementor::setup_listing_context(); |
| 487: | $is_editor = \Elementor\Plugin::$instance->editor->is_edit_mode(); |
| 488: | |
| 489: | if ( ! $property ) { |
| 490: | if ( $is_editor ) { |
| 491: | echo '<div class="epl-elementor-placeholder">' . esc_html__( 'Property Icons - No listings found.', 'easy-property-listings' ) . '</div>'; |
| 492: | } |
| 493: | EPL_Elementor::restore_listing_context(); |
| 494: | return; |
| 495: | } |
| 496: | |
| 497: | $settings = $this->get_settings_for_display(); |
| 498: | $layout_class = 'horizontal' === $settings['layout'] ? 'epl-icons-horizontal' : 'epl-icons-vertical'; |
| 499: | $show_labels = 'yes' === $settings['show_labels']; |
| 500: | $show_icons = 'yes' === $settings['show_icons']; |
| 501: | $show_divider = 'yes' === $settings['divider_switch']; |
| 502: | $divider_char = ! empty( $settings['divider_text'] ) ? $settings['divider_text'] : '|'; |
| 503: | $icon_list = $settings['icon_list']; |
| 504: | |
| 505: | if ( empty( $icon_list ) ) { |
| 506: | EPL_Elementor::restore_listing_context(); |
| 507: | return; |
| 508: | } |
| 509: | |
| 510: | echo '<div class="epl-property-icons ' . esc_attr( $layout_class ) . '">'; |
| 511: | |
| 512: | $visible_items = array(); |
| 513: | |
| 514: | |
| 515: | foreach ( $icon_list as $index => $item ) { |
| 516: | $icon_data = $this->get_icon_data( $property, $item['icon_type'] ); |
| 517: | |
| 518: | |
| 519: | if ( 'yes' === $item['hide_if_empty'] && empty( $icon_data['value'] ) ) { |
| 520: | continue; |
| 521: | } |
| 522: | |
| 523: | $item['data'] = $icon_data; |
| 524: | $visible_items[] = $item; |
| 525: | } |
| 526: | |
| 527: | $total_visible = count( $visible_items ); |
| 528: | |
| 529: | foreach ( $visible_items as $index => $item ) { |
| 530: | $icon_data = $item['data']; |
| 531: | $value = $icon_data['value']; |
| 532: | $label = ! empty( $item['custom_label'] ) ? $item['custom_label'] : $icon_data['label']; |
| 533: | |
| 534: | echo '<span class="epl-icon-item elementor-repeater-item-' . esc_attr( $item['_id'] ) . '">'; |
| 535: | |
| 536: | |
| 537: | if ( $show_icons && ! empty( $item['selected_icon']['value'] ) ) { |
| 538: | \Elementor\Icons_Manager::render_icon( $item['selected_icon'], array( 'aria-hidden' => 'true' ) ); |
| 539: | } |
| 540: | |
| 541: | |
| 542: | echo '<span class="epl-icon-value">' . esc_html( $value ) . '</span>'; |
| 543: | |
| 544: | |
| 545: | if ( $show_labels && ! empty( $label ) ) { |
| 546: | echo '<span class="epl-icon-label">' . esc_html( $label ) . '</span>'; |
| 547: | } |
| 548: | |
| 549: | echo '</span>'; |
| 550: | |
| 551: | |
| 552: | if ( $show_divider && $index < ( $total_visible - 1 ) ) { |
| 553: | echo '<span class="epl-icon-divider" aria-hidden="true">' . esc_html( $divider_char ) . '</span>'; |
| 554: | } |
| 555: | } |
| 556: | |
| 557: | echo '</div>'; |
| 558: | |
| 559: | EPL_Elementor::restore_listing_context(); |
| 560: | } |
| 561: | |
| 562: | |
| 563: | |
| 564: | |
| 565: | |
| 566: | |
| 567: | |
| 568: | |
| 569: | |
| 570: | private function get_icon_data( $property, $type ) { |
| 571: | $data = array( |
| 572: | 'value' => '', |
| 573: | 'label' => '', |
| 574: | ); |
| 575: | |
| 576: | switch ( $type ) { |
| 577: | case 'bed': |
| 578: | $data['value'] = $property->get_property_meta( 'property_bedrooms' ); |
| 579: | $data['label'] = esc_html__( 'Beds', 'easy-property-listings' ); |
| 580: | break; |
| 581: | |
| 582: | case 'bath': |
| 583: | $data['value'] = $property->get_property_meta( 'property_bathrooms' ); |
| 584: | $data['label'] = esc_html__( 'Baths', 'easy-property-listings' ); |
| 585: | break; |
| 586: | |
| 587: | case 'parking': |
| 588: | $garage = intval( $property->get_property_meta( 'property_garage' ) ); |
| 589: | $carport = intval( $property->get_property_meta( 'property_carport' ) ); |
| 590: | $data['value'] = $garage + $carport; |
| 591: | $data['label'] = esc_html__( 'Parking', 'easy-property-listings' ); |
| 592: | break; |
| 593: | |
| 594: | case 'land': |
| 595: | $land_value = $property->get_property_meta( 'property_land_area' ); |
| 596: | $land_unit = $this->format_area_unit( $property->get_property_meta( 'property_land_area_unit' ), $land_value ); |
| 597: | $land_unit = apply_filters( 'epl_property_land_area_unit_label', $land_unit ); |
| 598: | $data['value'] = ! empty( $land_value ) ? $land_value . ( ! empty( $land_unit ) ? ' ' . $land_unit : '' ) : ''; |
| 599: | $data['label'] = esc_html__( 'Land', 'easy-property-listings' ); |
| 600: | break; |
| 601: | |
| 602: | case 'building': |
| 603: | $building_value = $property->get_property_meta( 'property_building_area' ); |
| 604: | $building_unit = $this->format_area_unit( $property->get_property_meta( 'property_building_area_unit' ), $building_value ); |
| 605: | $building_unit = apply_filters( 'epl_property_building_area_unit_label', $building_unit ); |
| 606: | $data['value'] = ! empty( $building_value ) ? $building_value . ( ! empty( $building_unit ) ? ' ' . $building_unit : '' ) : ''; |
| 607: | $data['label'] = esc_html__( 'Building', 'easy-property-listings' ); |
| 608: | break; |
| 609: | |
| 610: | case 'rooms': |
| 611: | $data['value'] = $property->get_property_meta( 'property_rooms' ); |
| 612: | $data['label'] = esc_html__( 'Rooms', 'easy-property-listings' ); |
| 613: | break; |
| 614: | |
| 615: | case 'pool': |
| 616: | $pool = strtolower( (string) $property->get_property_meta( 'property_pool' ) ); |
| 617: | $data['value'] = ( '1' === $pool || epl_value_bool_checker( $pool ) ) ? esc_html__( 'Yes', 'easy-property-listings' ) : ''; |
| 618: | $data['label'] = esc_html__( 'Pool', 'easy-property-listings' ); |
| 619: | break; |
| 620: | |
| 621: | case 'ac': |
| 622: | $ac = strtolower( (string) $property->get_property_meta( 'property_air_conditioning' ) ); |
| 623: | $data['value'] = ( '1' === $ac || epl_value_bool_checker( $ac ) ) ? esc_html__( 'Yes', 'easy-property-listings' ) : ''; |
| 624: | $data['label'] = esc_html__( 'A/C', 'easy-property-listings' ); |
| 625: | break; |
| 626: | } |
| 627: | |
| 628: | return $data; |
| 629: | } |
| 630: | |
| 631: | |
| 632: | |
| 633: | |
| 634: | |
| 635: | |
| 636: | |
| 637: | |
| 638: | |
| 639: | |
| 640: | private function format_area_unit( $unit, $value ) { |
| 641: | $unit = (string) $unit; |
| 642: | |
| 643: | if ( 'squareMeter' === $unit ) { |
| 644: | $unit = html_entity_decode( __( 'm²', 'easy-property-listings' ), ENT_HTML5, 'UTF-8' ); |
| 645: | } elseif ( 'acre' === $unit ) { |
| 646: | $unit = floatval( $value ) > 1 ? __( 'acres', 'easy-property-listings' ) : __( 'acre', 'easy-property-listings' ); |
| 647: | } |
| 648: | |
| 649: | return $unit; |
| 650: | } |
| 651: | } |
| 652: | |