1: <?php
2: /**
3: * Property Meta Fields
4: *
5: * @package EPL
6: * @subpackage Classes/PropertyMeta
7: * @copyright Copyright (c) 2020, Merv Barrett
8: * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9: * @since 2.0
10: */
11:
12: // Exit if accessed directly.
13: if ( ! defined( 'ABSPATH' ) ) {
14: exit;
15: }
16:
17: /**
18: * EPL_Property_Meta Class
19: *
20: * @since 3.5.3 Check for class
21: */
22: if ( ! class_exists( 'EPL_Property_Meta' ) ) :
23: /**
24: * EPL_Property_Meta Class
25: *
26: * @since 2.0
27: */
28: class EPL_Property_Meta {
29:
30: /**
31: * Global Instance
32: *
33: * @var $instance
34: * @since 2.0
35: */
36: public static $instance;
37:
38: /**
39: * Global post
40: *
41: * @var $post
42: *
43: * @since 2.0
44: */
45: public $post;
46:
47: /**
48: * Global epl_settings
49: *
50: * @var $epl_settings
51: *
52: * @since 2.0
53: */
54: public $epl_settings;
55:
56: /**
57: * Global meta
58: *
59: * @var $meta
60: *
61: * @since 2.0
62: */
63: public $meta;
64:
65: /**
66: * Global post type
67: *
68: * @var $post_type
69: *
70: * @since 2.0
71: */
72: public $post_type;
73:
74: /**
75: * Global EPL Post Type
76: *
77: * @var $property_post_type
78: *
79: * @since 2.0
80: */
81: public $property_post_type;
82:
83: /**
84: * Label New option
85: *
86: * @var $label_new
87: *
88: * @since 3.4.44
89: */
90: public $label_new;
91:
92: /**
93: * Sticker Range
94: *
95: * @var $sticker_new_range
96: *
97: * @since 3.4.44
98: */
99: public $sticker_new_range;
100:
101: /**
102: * Label: Home Open
103: *
104: * @var $label_home_open
105: *
106: * @since 3.4.44
107: */
108: public $label_home_open;
109:
110: /**
111: * Label: POA
112: *
113: * @var $label_poa
114: *
115: * @since 3.4.44
116: */
117: public $label_poa;
118:
119: /**
120: * Label: Under Offer
121: *
122: * @var $label_under_offer
123: *
124: * @since 3.4.44
125: */
126: public $label_under_offer;
127:
128: /**
129: * Label: Sold
130: *
131: * @var $label_sold
132: *
133: * @since 3.4.44
134: */
135: public $label_sold;
136:
137: /**
138: * Label: Leased
139: *
140: * @var $label_leased
141: *
142: * @since 3.4.44
143: */
144: public $label_leased;
145:
146: /**
147: * Label: Bond
148: *
149: * @var $label_bond
150: *
151: * @since 3.4.44
152: */
153: public $label_bond;
154:
155: /**
156: * Display Bond option
157: *
158: * @var $display_bond
159: *
160: * @since 3.4.44
161: */
162: public $display_bond;
163:
164: /**
165: * Under Offer Price Display option
166: *
167: * @var $display_price_under_offer
168: *
169: * @since 3.6
170: */
171: public $display_price_under_offer;
172:
173: /**
174: * Get things going
175: *
176: * @param object $post Post object.
177: * @since 2.0
178: */
179: public function __construct( $post ) {
180:
181: $this->post = $post;
182: $this->epl_settings = epl_settings();
183: $this->meta = get_post_custom( $post->ID );
184: $this->post_type = $this->post->post_type;
185: $this->property_post_type = $this->post->post_type;
186:
187: $this->epl_labels();
188: }
189:
190: /**
191: * Define Admin labels in epl_settings global variable
192: *
193: * @return void Adds the custom admin labels
194: * @since 2.0
195: */
196: public function epl_labels() {
197:
198: $field_groups = epl_get_admin_option_fields();
199:
200: foreach ( $field_groups as $field_group ) {
201: if ( 'labels' === $field_group['id'] ) {
202: $epl_labels = array_filter( $field_group['fields'] );
203: break;
204: }
205: }
206:
207: foreach ( $epl_labels as $label_key => $label ) {
208: $label_key = $label['name'];
209: if ( $label_key ) {
210: $default = isset( $label['default'] ) ? $label['default'] : '';
211:
212: if ( isset( $this->epl_settings[ $label_key ] ) && ! empty( $this->epl_settings[ $label_key ] ) ) {
213: $this->{$label_key} = $this->epl_settings[ $label_key ];
214: } else {
215: $this->{$label_key} = $default;
216: }
217: }
218: }
219: }
220:
221: /**
222: * Return the meta value based on the meta key.
223: *
224: * Usage is $property->get_property_meta('meta_key') with the global $property variable defined
225: *
226: * @param string $meta_key The meta key to get the value.
227: * @param bool $allowzero Return a 0 value or if false and a value of 0 return nothing. Default True.
228: *
229: * @return string|integer Return the value of the meta key, string, or integer.
230: *
231: * @since 2.0
232: * @since 3.5.22 Normalise yes/no meta values to lowercase for case-insensitive REAXML feed compatibility.
233: */
234: public function get_property_meta( $meta_key, $allowzero = true ) {
235: $value = null;
236: if ( isset( $this->meta[ $meta_key ] ) ) {
237: if ( isset( $this->meta[ $meta_key ][0] ) ) {
238: if ( true === $allowzero ) {
239: $value = maybe_unserialize( $this->meta[ $meta_key ][0] );
240: } elseif ( intval( $this->meta[ $meta_key ][0] ) === 0 ) {
241: $value = '';
242: } else {
243: $value = maybe_unserialize( $this->meta[ $meta_key ][0] );
244: }
245: }
246: }
247:
248: // Normalise yes/no meta values to lowercase for case-insensitive REAXML feed compatibility.
249: $boolean_meta_keys = array(
250: 'property_price_display',
251: 'property_rent_display',
252: 'property_under_offer',
253: 'property_address_display',
254: 'property_com_display_suburb',
255: 'property_featured',
256: );
257: if ( is_string( $value ) && in_array( $meta_key, $boolean_meta_keys, true ) ) {
258: $value = strtolower( $value );
259: }
260:
261: return apply_filters( 'epl_meta_filter_' . $meta_key, $value );
262: }
263:
264: /**
265: * Outputs the inspection times based on settings format
266: *
267: * @param bool $ical True to return link with iCal.
268: * @param string $meta_key The meta key to get the value from default is property_inspection_times.
269: *
270: * @return mixed Return formatted inspection times with a iCal link
271: *
272: * @since 2.0
273: * @since 3.4.27 Added filter for href, handling of non date inspection values.
274: * @since 3.4.44 Added filter for deciding whether to remove inspection entry.
275: * @since 3.5.3 Fix: Deprecation warning - Make sure inspection time is not null before passing through trim.
276: * @since 3.5.3 Update to use local timestamp.
277: * @since 3.5.13 Tweak: Target blank added to ical link.
278: * @since 3.5.21 Added a signed token to the iCal inspection link and switched URL generation to add_query_arg().
279: */
280: public function get_property_inspection_times( $ical = true, $meta_key = 'property_inspection_times' ) {
281: if ( 'leased' === $this->get_property_meta( 'property_status' ) || 'sold' === $this->get_property_meta( 'property_status' ) ) {
282: return null;
283: }
284:
285: $inspection_time = $this->get_property_meta( $meta_key );
286: $inspection_time = ! is_null( $inspection_time ) ? trim( $inspection_time ) : '';
287:
288: $not_date = array();
289:
290: if ( ! empty( $inspection_time ) ) {
291: $list = array_filter( explode( "\n", $inspection_time ) );
292: if ( ! empty( $list ) ) {
293: // There are inspection times.
294: $inspectarray = array();
295: foreach ( $list as $num => $item ) {
296: if ( is_numeric( $item[0] ) ) {
297: $timearr = explode( ' ', $item );
298: $endtime = current( $timearr ) . ' ' . end( $timearr );
299:
300: $maybe_delete_inspection = strtotime( $endtime ) < epl_get_local_timestamp();
301: $maybe_delete_inspection = apply_filters( 'epl_maybe_delete_inspection', $maybe_delete_inspection, $endtime, $item );
302: if ( ! $maybe_delete_inspection ) {
303: $item = trim( $item );
304: $inspectarray[ strtotime( $endtime ) ] = $item;
305: }
306: } else {
307: $not_date[ $num ] = $num;
308: $inspectarray[ $num ] = $item;
309: }
310: }
311: ksort( $inspectarray );
312: // Update inspection times by removing past dates.
313: $new_inspection_meta = implode( "\n", $inspectarray );
314: update_post_meta( $this->post->ID, 'property_inspection_times', $new_inspection_meta );
315:
316: $return = '';
317: if ( count( $inspectarray ) >= 1 ) {
318: // Unordered list for multiple inspection times.
319: foreach ( $inspectarray as $key => &$element ) {
320:
321: $return .= "<li class='home-open-date epl-no-inspection-date'>";
322:
323: if ( ! empty( $element ) ) {
324:
325: if ( in_array( $key, $not_date, true ) ) {
326:
327: // Handle inspections that are not date.
328: $return .= $element;
329:
330: } else {
331:
332: $href = add_query_arg(
333: array(
334: 'epl_cal_dl' => 1,
335: 'cal' => 'ical',
336: 'dt' => base64_encode( htmlspecialchars( $element, ENT_QUOTES, 'UTF-8' ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
337: 'propid' => $this->post->ID,
338: 'k' => epl_get_ical_download_token( $this->post->ID, $element ),
339: ),
340: home_url( '/' )
341: );
342:
343: $href = apply_filters( 'epl_inspection_link', $href );
344:
345: $element_formatted = apply_filters( 'epl_inspection_format', $element );
346:
347: if ( $ical ) {
348: //phpcs:disable
349: $return .= "<a
350: class ='epl_inspection_calendar'
351: href='" . $href . "'
352: target='_blank' >"
353: . $element_formatted . '
354: </a>';
355: //phpcs:enable
356: } else {
357: $return .= $element_formatted;
358: }
359: }
360:
361: $return .= '</li>';
362: }
363: }
364: if ( ! empty( $return ) ) {
365: $return = '<ul class="home-open-wrapper">' . $return . '</ul>';
366: }
367: }
368: return apply_filters( 'epl_property_inspection_time', $return );
369: }
370: }
371: }
372:
373: /**
374: * Get the setting based on the key
375: *
376: * Usage is $property->get_epl_settings('meta_key') with the global $property variable defined
377: *
378: * @param string $key Option key name.
379: * @return string Value of the setting or if not set nothing is returned
380: * @since 2.0
381: */
382: public function get_epl_settings( $key ) {
383: $value = '';
384: if ( ! empty( $this->epl_settings ) && isset( $this->epl_settings[ $key ] ) ) {
385: $value = $this->epl_settings[ $key ];
386: }
387: return $value;
388: }
389:
390: /**
391: * Process Property Features Taxonomy
392: *
393: * @since 2.0
394: * @return mixed List of features
395: */
396: public function get_property_feature_taxonomy() {
397: return apply_filters( 'epl_get_property_feature_taxonomy', get_the_term_list( $this->post->ID, 'tax_feature', '<li>', '</li><li>', '</li>' ) );
398: }
399:
400: /**
401: * Suburb profile
402: *
403: * @since 2.0
404: * @return string Suburb/Location name
405: */
406: public function get_suburb_profile() {
407: $profiles = get_the_terms( $this->post->ID, 'location' );
408: if ( is_array( $profiles ) ) {
409: $profile = end( $profiles );
410: return $profile->name;
411: }
412: }
413:
414: /**
415: * Auction Date/Time
416: *
417: * @param bool $admin true/false True will return on frontend.
418: * @return string formatted auction date
419: *
420: * @since 2.0.0
421: * @since 3.4.38 Added epl_get_property_auction_date_time_separator filter for date/time separator.
422: */
423: public function get_property_auction( $admin = false ) {
424:
425: $date_time_sep = apply_filters( 'epl_get_property_auction_date_time_separator', ' \a\t ' );
426:
427: $date_format = epl_get_inspection_date_format();
428: $time_format = epl_get_inspection_time_format();
429: $format = $date_format . $date_time_sep . $time_format;
430:
431: if ( $admin ) {
432: $format = apply_filters( 'epl_get_property_auction_date_admin', $format );
433: } else {
434: $format = apply_filters( 'epl_get_property_auction_date', $format );
435: }
436:
437: if ( isset( $this->meta['property_auction'] ) ) {
438: if ( isset( $this->meta['property_auction'][0] ) ) {
439: if ( ! empty( $this->meta['property_auction'][0] ) ) {
440: if ( strpos( $this->meta['property_auction'][0], 'T' ) === false ) {
441: $feed_format = apply_filters( 'epl_auction_feed_format', 'Y-m-d-H:i:s' );
442: $epl_date = DateTime::createFromFormat( $feed_format, $this->meta['property_auction'][0] );
443:
444: if ( $epl_date ) {
445: $primary_feed_format = apply_filters( 'epl_auction_primary_feed_format', 'Y-m-d\TH:i' );
446: $this->meta['property_auction'][0] = $epl_date->format( $primary_feed_format );
447: }
448: }
449: return apply_filters( 'epl_get_property_auction', gmdate( $format, strtotime( $this->meta['property_auction'][0] ) ) );
450: }
451: }
452: }
453: }
454:
455: /**
456: * Commercial Rent
457: *
458: * @since 2.0
459: * @return string Currency Formatted price
460: */
461: public function get_property_com_rent() {
462: $rent = epl_currency_formatted_amount( $this->get_property_meta( 'property_com_rent' ) );
463:
464: return apply_filters( 'epl_get_property_com_rent', $rent );
465: }
466:
467: /**
468: * Price Display
469: *
470: * @since 2.0
471: * @return string Return formatted price based on selected options
472: */
473: public function get_property_price_display() {
474: $property_price_search = $this->get_property_meta( 'property_price' );
475: $property_price_view = $this->get_property_meta( 'property_price_view' );
476: if ( empty( $property_price_search ) ) {
477: $property_price = '';
478: } elseif ( ! empty( $property_price_view ) ) {
479: $property_price = $property_price_view;
480: } else {
481: $property_price = epl_currency_formatted_amount( $property_price_search );
482: }
483: // Auction Details and Price override.
484: if ( 'auction' === $this->get_property_meta( 'property_authority' ) ) {
485: $property_price = apply_filters( 'epl_get_property_auction_label', __( 'Auction', 'easy-property-listings' ) ) . ' ' . $this->get_property_auction();
486: }
487: // Commercial Lease Override.
488: if ( 'lease' === $this->get_property_meta( 'property_com_listing_type' ) ) {
489: $property_price = $property_price_view;
490: }
491: // Commercial Both Override.
492: if ( 'both' === $this->get_property_meta( 'property_com_listing_type' ) && ! empty( $property_price_view ) ) {
493: $property_price = $property_price_view;
494: }
495: return apply_filters( 'epl_get_property_price_display', $property_price );
496: }
497:
498: /**
499: * Sold price display
500: *
501: * @since 2.0
502: * @param bool $admin True for frontend.
503: * @return string Return sold price if selected or nothing
504: */
505: public function get_property_price_sold_display( $admin = false ) {
506: $property_sold_price = $this->get_property_meta( 'property_sold_price', false );
507: $property_sold_display = $this->get_property_meta( 'property_sold_price_display' );
508:
509: if ( ! empty( $property_sold_price ) ) {
510: if ( 'yes' === $property_sold_display || true === $admin ) {
511: $property_sold_price = ' ' . epl_currency_formatted_amount( $property_sold_price );
512:
513: return apply_filters( 'epl_get_property_price_sold_display', $property_sold_price );
514: }
515: }
516: }
517:
518: /**
519: * Lease price display
520: *
521: * @since 3.1
522: * @param bool $admin True for front end usage.
523: * @return string Return lease price if selected or nothing
524: */
525: public function get_property_price_lease_display( $admin = false ) {
526: $property_lease_price = $this->get_property_price_display();
527: $property_lease_display = $this->get_property_meta( 'property_sold_price_display' );
528:
529: if ( ! empty( $property_lease_price ) ) {
530: if ( 'yes' === $property_lease_display || true === $admin ) {
531: return apply_filters( 'epl_get_property_price_lease_display', $property_lease_price );
532: }
533: }
534: }
535:
536: /**
537: * Sold date display
538: *
539: * @since 2.0
540: * @param integer $sold_price Sold price.
541: * @return string Return sold date if sold
542: */
543: public function get_property_price_sold_date( $sold_price = null ) {
544:
545: if ( null === $sold_price ) {
546: return;
547: }
548:
549: $property_sold_date = $this->get_property_meta( 'property_sold_date' );
550:
551: if ( ! empty( $property_sold_date ) ) {
552: return apply_filters( 'epl_get_property_price_sold_date', $sold_price . ' ' . $property_sold_date );
553: }
554: }
555:
556: /**
557: * Rental Price
558: *
559: * @since 2.0
560: * @return string Currency Formatted Rental Price
561: */
562: public function get_property_rent() {
563: if ( 'rental' !== $this->post_type ) {
564: return;
565: }
566:
567: $property_rent_search = $this->get_property_meta( 'property_rent' );
568: $property_rent_view = $this->get_property_meta( 'property_rent_view' );
569:
570: if ( empty( $property_rent_search ) ) {
571: $rental_price = '';
572: } elseif ( ! empty( $property_rent_view ) ) {
573: $rental_price = $property_rent_view;
574: } else {
575: $rental_price = epl_currency_formatted_amount( $property_rent_search );
576: }
577: return apply_filters( 'epl_get_property_rent', $rental_price );
578: }
579:
580: /**
581: * Rental Bond
582: *
583: * @since 2.0
584: * @return string Formatted Bond price
585: */
586: public function get_property_bond() {
587: if ( 'rental' !== $this->post_type ) {
588: return;
589: }
590:
591: $bond_position = apply_filters( 'epl_property_bond_position', 'after' );
592:
593: $bond = '';
594: $prop_bond = $this->get_property_meta( 'property_bond' );
595:
596: if ( ! empty( $prop_bond ) && 'before' === $bond_position ) {
597: $bond = $this->label_bond . ' ' . epl_currency_formatted_amount( $this->get_property_meta( 'property_bond' ) );
598: } elseif ( ! empty( $prop_bond ) ) {
599: $bond = epl_currency_formatted_amount( $this->get_property_meta( 'property_bond' ) ) . ' ' . $this->label_bond;
600: }
601: return apply_filters( 'epl_get_property_bond', $bond );
602: }
603:
604: /**
605: * Rental Available Date
606: *
607: * @param bool $admin True for front end usage.
608: * @return string Formatted date
609: *
610: * @since 2.0.0
611: * @since 3.4.38 Added epl_get_property_available_date_time_separator filter for date/time separator.
612: * @since 3.5.0 Fixed time shown when only date string.
613: */
614: public function get_property_available( $admin = false ) {
615:
616: if ( isset( $this->meta['property_date_available'] ) ) {
617: if ( isset( $this->meta['property_date_available'][0] ) ) {
618: if ( ! empty( $this->meta['property_date_available'][0] ) ) {
619:
620: $av_date_array = date_parse( $this->meta['property_date_available'][0] );
621: $date_format = epl_get_inspection_date_format();
622:
623: if ( isset( $av_date_array['hour'] ) && false === $av_date_array['hour'] ) {
624: $format = $date_format;
625: } else {
626:
627: $date_time_sep = apply_filters( 'epl_get_property_available_date_time_separator', ' \a\t ' );
628: $time_format = epl_get_inspection_time_format();
629: $format = $date_format . $date_time_sep . $time_format;
630: }
631:
632: if ( $admin ) {
633: $format = apply_filters( 'epl_property_available_date_format_admin', $format );
634: } else {
635: $format = apply_filters( 'epl_property_available_date_format', $format );
636: }
637:
638: $av_date = ( isset( $av_date_array['year'] ) && isset( $av_date_array['month'] ) && isset( $av_date_array['day'] ) ) ?
639: $av_date_array['year'] . '-' . $av_date_array['month'] . '-' . $av_date_array['day'] : $this->meta['property_date_available'][0];
640: if ( current_time( 'timestamp' ) > strtotime( $av_date ) ) { // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
641: return apply_filters( 'epl_property_sub_title_available_now_label', __( 'now', 'easy-property-listings' ) );
642: } else {
643: return apply_filters( 'epl_get_property_available', gmdate( $format, strtotime( $av_date ) ) );
644: }
645: }
646: }
647: }
648: }
649:
650: /**
651: * Land category
652: *
653: * @param string $tag HTML wrapper type, default div.
654: * @param string $class_name name, default land-category.
655: * @return string
656: *
657: * @since 2.0.0
658: * @since 3.4.42 Fix: Filter name was incorrect changed to epl_get_property_land_category.
659: */
660: public function get_property_land_category( $tag = 'div', $class_name = 'land-category' ) {
661: if ( ! in_array( $this->post_type, array( 'land', 'commercial_land' ), true ) ) {
662: return null;
663: }
664:
665: $land_category = epl_listing_meta_land_category_value( $this->get_property_meta( 'property_land_category' ) );
666:
667: if ( empty( $land_category ) ) {
668: $land_category = $land_category;
669: } elseif ( 'none' === $tag || 'value' === $tag ) {
670: $land_category = $land_category;
671: } else {
672: $land_category = '<' . $tag . ' class="' . $class_name . '">' . $land_category . '</' . $tag . '>';
673: }
674: return apply_filters( 'epl_get_property_land_category', $land_category );
675: }
676:
677: /**
678: * Formatted Street level address based on selected display option
679: *
680: * @param bool $street_separator Output a address separator after the street address.
681: * @param string $separator_symbol Symbol to use as the address separator, default is a comma.
682: *
683: * @return string formatted street address
684: *
685: * @since 2.0.0
686: * @since 3.4.8 Corrected spacing if value is present. Implemented separator with existing filter.
687: */
688: public function get_formatted_property_address( $street_separator = true, $separator_symbol = ',' ) {
689:
690: $street = '';
691:
692: $lot_number = $this->get_property_meta( 'property_address_lot_number' );
693: if ( ! empty( $lot_number ) ) {
694: $street .= $lot_number . ' ';
695: }
696:
697: $sub_number = $this->get_property_meta( 'property_address_sub_number' );
698: if ( ! empty( $sub_number ) ) {
699: $street .= $sub_number . '/';
700: }
701:
702: $street_number = $this->get_property_meta( 'property_address_street_number' );
703: if ( ! empty( $street_number ) ) {
704: $street .= $street_number . ' ';
705: }
706:
707: $street_name = $this->get_property_meta( 'property_address_street' );
708: if ( ! empty( $street_name ) ) {
709: $street .= $street_name;
710:
711: if ( true === $street_separator ) {
712: $separator_symbol = apply_filters( 'epl_property_address_separator', $separator_symbol );
713: $street .= $separator_symbol;
714: }
715: }
716: return apply_filters( 'epl_get_formatted_property_address', $street );
717: }
718:
719: /**
720: * Show the street address?
721: *
722: * True when the listing's Display Street Address box is ticked. The street address is
723: * the lot, unit, street number and street name.
724: *
725: * @since 3.6 New: one rule for every address function.
726: *
727: * @return bool
728: */
729: public function show_street_address() {
730: $show = 'yes' === $this->get_property_meta( 'property_address_display' );
731:
732: /**
733: * Filters whether the listing shows its street address.
734: *
735: * @since 3.6
736: *
737: * @param bool $show True to show the street address.
738: * @param EPL_Property_Meta $property The listing.
739: */
740: return (bool) apply_filters( 'epl_listing_show_street_address', $show, $this );
741: }
742:
743: /**
744: * Show the suburb?
745: *
746: * Always for residential listings. Commercial, commercial land and business listings
747: * have a Display Suburb box: their suburb shows when it's ticked or when the street
748: * address shows. The same rule as the REST API.
749: *
750: * @since 3.6 New: one rule for every address function.
751: *
752: * @return bool
753: */
754: public function show_suburb() {
755: $show = true;
756:
757: if ( in_array( $this->post_type, array( 'commercial', 'commercial_land', 'business' ), true ) ) {
758: $show = $this->show_street_address() || 'yes' === $this->get_property_meta( 'property_com_display_suburb' );
759: }
760:
761: /**
762: * Filters whether the listing shows its suburb.
763: *
764: * @since 3.6
765: *
766: * @param bool $show True to show the suburb.
767: * @param EPL_Property_Meta $property The listing.
768: */
769: return (bool) apply_filters( 'epl_listing_show_suburb', $show, $this );
770: }
771:
772: /**
773: * Show the city in the address?
774: *
775: * True when Settings > Address > Additional Address Field (the city) is enabled.
776: *
777: * @since 3.6 New: one rule for every address function.
778: *
779: * @return bool
780: */
781: public function show_address_city() {
782: return (bool) apply_filters( 'epl_listing_show_address_city', 'yes' === $this->get_epl_settings( 'epl_enable_city_field' ), $this );
783: }
784:
785: /**
786: * Show the country in the address?
787: *
788: * True when Settings > Address > Display Country is enabled.
789: *
790: * @since 3.6 New: one rule for every address function.
791: *
792: * @return bool
793: */
794: public function show_address_country() {
795: return (bool) apply_filters( 'epl_listing_show_address_country', 'yes' === $this->get_epl_settings( 'epl_enable_country_field' ), $this );
796: }
797:
798: /**
799: * Listing Category
800: *
801: * @since 2.0
802: * @param string $tag HTML wrapper type, default div.
803: * @param string $class_name name, default property-category.
804: * @return string
805: */
806: public function get_property_category( $tag = 'div', $class_name = 'property-category' ) {
807:
808: $property_category = epl_listing_meta_property_category_value( $this->get_property_meta( 'property_category' ) );
809:
810: if ( empty( $property_category ) ) {
811: $property_category = $property_category;
812: } elseif ( 'none' === $tag || 'value' === $tag ) {
813: $property_category = $property_category;
814: } else {
815: $property_category = '<' . $tag . ' class="' . $class_name . '">' . $property_category . '</' . $tag . '>';
816: }
817: return apply_filters( 'epl_get_property_category', $property_category );
818: }
819:
820: /**
821: * Get Commercial Category
822: *
823: * @since 2.0
824: * @param string $tag HTML wrapper type, default div.
825: * @param string $class_name name, default commercial-category.
826: * @return string
827: */
828: public function get_property_commercial_category( $tag = 'div', $class_name = 'commercial-category' ) {
829: $property_commercial_category = epl_listing_load_meta_commercial_category_value( $this->get_property_meta( 'property_commercial_category' ) );
830:
831: if ( empty( $property_commercial_category ) ) {
832: $property_commercial_category = $property_commercial_category;
833: } elseif ( 'none' === $tag || 'value' === $tag ) {
834: $property_commercial_category = $property_commercial_category;
835: } else {
836: $property_commercial_category = '<' . $tag . ' class="' . $class_name . '">' . $property_commercial_category . '</' . $tag . '>';
837: }
838: return apply_filters( 'epl_get_property_commercial_category', $property_commercial_category );
839: }
840:
841: /**
842: * Get Rural Category
843: *
844: * @since 3.1.12
845: * @param string $tag HTML wrapper type, default div.
846: * @param string $class_name name, default rural-category.
847: * @return string
848: */
849: public function get_property_rural_category( $tag = 'div', $class_name = 'rural-category' ) {
850: $property_rural_category = epl_listing_load_meta_rural_category_value( $this->get_property_meta( 'property_rural_category' ) );
851:
852: if ( empty( $property_rural_category ) ) {
853: $property_rural_category = $property_rural_category;
854: } elseif ( 'none' === $tag || 'value' === $tag ) {
855: $property_rural_category = $property_rural_category;
856: } else {
857: $property_rural_category = '<' . $tag . ' class="' . $class_name . '">' . $property_rural_category . '</' . $tag . '>';
858: }
859: return apply_filters( 'epl_get_property_rural_category', $property_rural_category );
860: }
861:
862: /**
863: * Price Class
864: *
865: * @since 2.0
866: * @return string
867: */
868: public function get_price_class() {
869: if ( $this->get_property_meta( 'property_status' ) === 'sold' ) {
870: return apply_filters( 'property_price_class', 'epl-price sold' );
871: }
872: }
873:
874: /**
875: * Tax
876: *
877: * @since 2.0
878: * @return string
879: */
880: public function get_property_tax() {
881:
882: $property_tax = $this->get_property_meta( 'property_tax' );
883:
884: if ( 'exempt' === $property_tax ) {
885: $property_tax = ' ' . __( 'Inc. GST', 'easy-property-listings' );
886: } elseif ( 'inclusive' === $property_tax ) {
887: $property_tax = ' ' . __( 'Inc. GST', 'easy-property-listings' );
888: } elseif ( 'exclusive' === $property_tax ) {
889: $property_tax = ' + ' . __( 'GST', 'easy-property-listings' );
890: } else {
891: $property_tax = '';
892: }
893: return apply_filters( 'epl_get_property_tax', $property_tax );
894: }
895:
896: /**
897: * Is the listing under offer?
898: *
899: * A listing is under offer when it is marked under offer and is not sold.
900: *
901: * @since 3.6
902: *
903: * @return bool
904: */
905: public function is_under_offer() {
906: $under_offer = 'yes' === $this->get_property_meta( 'property_under_offer' ) && 'sold' !== $this->get_property_meta( 'property_status' );
907:
908: /**
909: * Filters whether the listing is under offer.
910: *
911: * @since 3.6
912: *
913: * @param bool $under_offer True when the listing is under offer.
914: * @param EPL_Property_Meta $property The listing.
915: */
916: return (bool) apply_filters( 'epl_is_under_offer', $under_offer, $this );
917: }
918:
919: /**
920: * Does the listing advertise a price?
921: *
922: * True when the listing is set to display its price, has a price to display and is
923: * not an auction. Listings showing the No Price label (POA) or an auction date
924: * advertise no price.
925: *
926: * @since 3.6
927: *
928: * @return bool
929: */
930: public function has_advertised_price() {
931: $advertised = false;
932:
933: if ( 'property' === $this->post_type || 'land' === $this->post_type || 'rural' === $this->post_type || 'business' === $this->post_type ) {
934: $advertised = 'auction' !== $this->get_property_meta( 'property_authority' )
935: && 'yes' === $this->get_property_meta( 'property_price_display' )
936: && '' !== (string) $this->get_property_price_display();
937: } elseif ( 'commercial' === $this->post_type || 'commercial_land' === $this->post_type ) {
938: $advertised = 'auction' !== $this->get_property_meta( 'property_com_authority' )
939: && 'yes' === $this->get_property_meta( 'property_price_display' )
940: && ( '' !== (string) $this->get_property_price_display() || '' !== (string) $this->get_property_com_rent() );
941: }
942:
943: /**
944: * Filters whether the listing advertises a price.
945: *
946: * @since 3.6
947: *
948: * @param bool $advertised True when the listing advertises a price.
949: * @param EPL_Property_Meta $property The listing.
950: */
951: return (bool) apply_filters( 'epl_listing_has_advertised_price', $advertised, $this );
952: }
953:
954: /**
955: * Show the price on listings that are under offer?
956: *
957: * Only when the Under Offer Price Display setting is set to show the price. Off by
958: * default, so under offer listings show only the Under Offer label, as before 3.6.
959: *
960: * @since 3.6
961: * @since 3.6.1 Off by default. NSW paused its price advertising rules on 16 November 2026, the day before they were due to start, so 3.6 showing the price on every site by default was no longer needed.
962: *
963: * @return bool
964: */
965: public function show_price_under_offer() {
966: $show = 'yes' === $this->get_epl_settings( 'display_price_under_offer' );
967:
968: /**
969: * Filters whether under offer listings show their price.
970: *
971: * @since 3.6
972: *
973: * @param bool $show True to show the price with the Under Offer label.
974: * @param EPL_Property_Meta $property The listing.
975: */
976: return (bool) apply_filters( 'epl_show_price_under_offer', $show, $this );
977: }
978:
979: /**
980: * No Price (POA) label from the settings.
981: *
982: * @since 3.6
983: *
984: * Reads the setting with epl_get_saved_option(), so a label saved empty stays empty and
985: * the epl_get_option_label_poa filter applies.
986: *
987: * @param string|null $fallback Returned when the label setting has never been saved.
988: * @return string|null
989: */
990: public function get_poa_label( $fallback = null ) {
991: return epl_get_saved_option( 'label_poa', $fallback );
992: }
993:
994: /**
995: * Under offer price.
996: *
997: * Keeps the advertised price visible next to the Under Offer label, for example
998: * "Under Offer | $360,000 - $390,000". Returns the Under Offer label on its own when
999: * the listing advertises no price or the site hides the price under offer.
1000: *
1001: * @since 3.6
1002: * @since 3.6 With the price shown, the wrapper has the class epl-under-offer-has-price so only the label is coloured.
1003: *
1004: * @param string $price The price shown when the listing is not under offer.
1005: * @param string $format Output format: span, div, li or text.
1006: * @return string
1007: */
1008: public function get_under_offer_price( $price, $format = 'span' ) {
1009: $label = $this->label_under_offer;
1010: $price = (string) $price;
1011:
1012: if ( ! $this->show_price_under_offer() || ! $this->has_advertised_price() || '' === trim( wp_strip_all_tags( $price ) ) ) {
1013: if ( 'text' === $format ) {
1014: $output = $label;
1015: } else {
1016: $output = '<' . $format . ' class="page-price under-offer-status">' . $label . '</' . $format . '>';
1017: }
1018: } else {
1019: /**
1020: * Filters the separator between the Under Offer label and the price.
1021: *
1022: * @since 3.6
1023: *
1024: * @param string $separator Default ' | '.
1025: */
1026: $separator = apply_filters( 'epl_under_offer_price_separator', ' | ' );
1027:
1028: if ( 'text' === $format ) {
1029: $output = $label . $separator . $price;
1030: } else {
1031: $output = '<' . $format . ' class="page-price under-offer-status epl-under-offer-has-price">'
1032: . '<span class="epl-under-offer-label">' . $label . '</span>'
1033: . '<span class="epl-under-offer-separator">' . $separator . '</span>'
1034: . '<span class="epl-under-offer-price">' . $price . '</span>'
1035: . '</' . $format . '>';
1036: }
1037: }
1038:
1039: /**
1040: * Filters the under offer price.
1041: *
1042: * @since 3.6
1043: *
1044: * @param string $output Under Offer label, with the price when shown.
1045: * @param string $price The price shown when the listing is not under offer.
1046: * @param string $format Output format: span, div, li or text.
1047: * @param EPL_Property_Meta $property The listing.
1048: */
1049: return apply_filters( 'epl_get_under_offer_price', $output, $price, $format, $this );
1050: }
1051:
1052: /**
1053: * Plain price value
1054: *
1055: * @since 2.0.0
1056: * @since 3.4.38 Using label_poa for no rental price. Added epl_price_rent_period filter. Added filter epl_pa_price for P.A label.
1057: * @since 3.5.22 Applying string to lower case on the yes values.
1058: * @since 3.6 Under offer listings keep the advertised price next to the Under Offer label unless hidden in the settings. Uses is_under_offer(), get_poa_label() and get_under_offer_price().
1059: *
1060: * @return string
1061: */
1062: public function get_price_plain_value() {
1063:
1064: $price_plain_value = '';
1065:
1066: if ( 'property' === $this->post_type || 'land' === $this->post_type || 'rural' === $this->post_type || 'business' === $this->post_type ) {
1067: $price_display = $this->get_property_price_display();
1068: if ( 'sold' === $this->get_property_meta( 'property_status' ) ) {
1069: $price_plain_value = $this->label_sold;
1070: } elseif ( ! empty( $price_display ) && 'yes' === $this->get_property_meta( 'property_price_display' ) ) { // Property.
1071: $price_plain_value = $this->get_property_price_display();
1072: } else {
1073: $price_plain_value = $this->get_poa_label( __( 'POA', 'easy-property-listings' ) );
1074: }
1075: if ( $this->is_under_offer() ) {
1076: $price_plain_value = $this->get_under_offer_price( $this->get_property_price_display(), 'text' );
1077: }
1078: } elseif ( 'rental' === $this->post_type ) {
1079: $prop_rent = $this->get_property_rent();
1080: if ( ! empty( $prop_rent ) && 'yes' === $this->get_property_meta( 'property_rent_display' ) && 'leased' !== $this->get_property_meta( 'property_status' ) ) {
1081:
1082: $price_rent_period = $this->get_property_meta( 'property_rent_period' );
1083: $price_rent_period = apply_filters( 'epl_price_rent_period', $price_rent_period );
1084: $price_plain_value = $this->get_property_rent() . '/' . ucfirst( $price_rent_period );
1085: $prop_rent_view = $this->get_property_meta( 'property_rent_view' );
1086: if ( ! empty( $prop_rent_view ) ) {
1087: $price_plain_value = $this->get_property_meta( 'property_rent_view' );
1088: }
1089: $prop_bond = $this->get_property_bond();
1090: if ( ! empty( $prop_bond ) && 'yes' === $this->epl_settings['display_bond'] ) {
1091: $price_plain_value = $this->get_property_bond();
1092: }
1093: } elseif ( 'leased' === $this->get_property_meta( 'property_status' ) ) {
1094: $price_plain_value = $this->label_leased . ' ' . $this->get_property_rent();
1095:
1096: } else {
1097: $price_plain_value = $this->get_poa_label( __( 'TBA', 'easy-property-listings' ) );
1098: }
1099: } elseif ( 'commercial' === $this->post_type || 'commercial_land' === $this->post_type ) {
1100: $price_display = $this->get_property_price_display();
1101: $prop_rent_period = $this->get_property_meta( 'property_com_rent_period' );
1102: $rent_lease_type =
1103: ! empty( $prop_rent_period ) ? epl_listing_load_meta_commercial_rent_period_value( $this->get_property_meta( 'property_com_rent_period' ) ) : apply_filters( 'epl_pa_label', __( 'P.A.', 'easy-property-listings' ) );
1104: // Sale or Both.
1105: $price_plain_value = '';
1106: if ( $this->get_property_meta( 'property_com_listing_type' ) === 'sale' || $this->get_property_meta( 'property_com_listing_type' ) === 'both' ) {
1107:
1108: if ( $this->get_property_meta( 'property_com_authority' ) === 'auction' ) { // Auction.
1109: $price_plain_value = '<span class="page-price auction">' . apply_filters( 'epl_commercial_auction_label', __( 'Auction', 'easy-property-listings' ) ) . ' ' . $this->get_property_auction() . '</span>';
1110: } elseif ( ! empty( $price_display ) && 'yes' === $this->get_property_meta( 'property_price_display' ) ) { // Property.
1111: $price_plain_value = apply_filters( 'epl_commercial_for_sale_label', __( 'For Sale', 'easy-property-listings' ) ) . ': ' . $this->get_property_price_display() . $this->get_property_tax();
1112: } else {
1113: $poa_label = $this->get_poa_label();
1114: if ( null !== $poa_label ) {
1115: $price_plain_value = apply_filters( 'epl_commercial_for_sale_label', __( 'For Sale', 'easy-property-listings' ) ) . ' ' . $poa_label;
1116: }
1117: }
1118: }
1119: // Lease or Both.
1120: if ( $this->get_property_meta( 'property_com_listing_type' ) === 'lease' || $this->get_property_meta( 'property_com_listing_type' ) === 'both' ) { // Both.
1121: $both = $this->get_property_meta( 'property_com_listing_type' ) === 'both' ? '<div class="epl-clear"></div>' : '';
1122: $prop_com_rent = $this->get_property_com_rent();
1123: if ( ! empty( $prop_com_rent ) && empty( $price_display ) ) {
1124: $price_plain_value .= $both . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . ' ' . $this->get_property_com_rent() . ' ' . $rent_lease_type;
1125: } elseif ( ! empty( $price_display ) && $this->get_property_meta( 'property_com_listing_type' ) === 'lease' ) {
1126: $price_plain_value .= $both . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . ' ' . $this->get_property_price_display();
1127: } elseif ( $this->get_property_meta( 'property_com_listing_type' ) === 'both' ) {
1128: $price_plain_value .= $both . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . ' ' . $this->get_property_com_rent() . ' ' . $rent_lease_type;
1129: } else {
1130: $poa_label = $this->get_poa_label();
1131: if ( null !== $poa_label ) {
1132: $price_plain_value .= $both . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . ' ' . $poa_label;
1133: }
1134: }
1135: }
1136: // Status.
1137: if ( 'sold' === $this->get_property_meta( 'property_status' ) ) {
1138: $price_plain_value = $this->label_sold;
1139: }
1140: // Under Offer.
1141: if ( $this->is_under_offer() ) {
1142: $price_plain_value = $this->get_under_offer_price( $price_plain_value, 'text' );
1143: }
1144: // Leased.
1145: if ( 'leased' === $this->get_property_meta( 'property_status' ) ) {
1146: $price_plain_value = $this->label_leased;
1147: }
1148: }
1149: return apply_filters( 'epl_get_price_plain_value', $price_plain_value );
1150: }
1151:
1152: /**
1153: * Get Price
1154: *
1155: * @since 2.0
1156: * @since 3.4.27 Fixed rent period translation.
1157: * @since 3.4.28 Using label_poa for no rental price. Added epl_price_rent_period filter. Added filter epl_pa_price for P.A label.
1158: * @since 3.4.38 Commercial listing type "both" now shows sale & lease prices.
1159: * @since 3.6 Under offer listings keep the advertised price next to the Under Offer label unless hidden in the settings. Uses is_under_offer(), get_poa_label() and get_under_offer_price().
1160: * @return string
1161: */
1162: public function get_price() {
1163:
1164: $price_display = $this->get_property_price_display();
1165: $prop_rent = $this->get_property_rent();
1166: $prop_rent_view = $this->get_property_meta( 'property_rent_view' );
1167: $prop_price_view = $this->get_property_meta( 'property_price_view' );
1168: $prop_com_rent = $this->get_property_com_rent();
1169: $price = '';
1170: if ( 'property' === $this->post_type || 'land' === $this->post_type || 'rural' === $this->post_type || 'business' === $this->post_type ) {
1171: if ( 'sold' === $this->get_property_meta( 'property_status' ) ) {
1172: $price = '<span class="page-price sold-status">' . $this->label_sold . $this->get_property_price_sold_display() . '</span>';
1173: } elseif ( ! empty( $price_display ) && 'yes' === $this->get_property_meta( 'property_price_display' ) ) { // Property.
1174: $price = '<span class="page-price">' . $this->get_property_price_display() . '</span>';
1175:
1176: } elseif ( 'auction' === $this->get_property_meta( 'property_authority' ) && 'no' === $this->get_property_meta( 'property_price_display' ) ) { // Auction.
1177: $price = '<span class="page-price auction">' . apply_filters( 'epl_get_property_auction_label', __( 'Auction', 'easy-property-listings' ) ) . ' ' . $this->get_property_auction() . '</span>';
1178: } else {
1179: $price = '<span class="page-price">' . $this->get_poa_label( __( 'POA', 'easy-property-listings' ) ) . '</span>';
1180: }
1181: if ( $this->is_under_offer() ) {
1182: $price = $this->get_under_offer_price( $this->get_property_price_display(), 'span' );
1183: }
1184: } elseif ( 'rental' === $this->post_type ) {
1185: if ( ! empty( $prop_rent ) && 'yes' === $this->get_property_meta( 'property_rent_display' ) && 'leased' !== $this->get_property_meta( 'property_status' ) ) {
1186:
1187: $rent_separator = apply_filters( 'epl_property_price_rent_separator', '/' );
1188:
1189: $price = '<span class="page-price-rent">';
1190: $price .= '<span class="page-price" style="margin-right:0;">' . $this->get_property_rent() . '</span>';
1191: if ( empty( $prop_rent_view ) ) {
1192: $rent_period_value = $this->get_property_meta( 'property_rent_period' );
1193: $rent_period_value = apply_filters( 'epl_price_rent_period', $rent_period_value );
1194: $rent_options = epl_get_property_rent_period_opts();
1195: $rent_period_label = isset( $rent_options[ $rent_period_value ] ) ? $rent_options[ $rent_period_value ] : ucfirst( $rent_period_value );
1196: $price .= '<span class="rent-period">' . $rent_separator . '' . $rent_period_label . '</span>';
1197: }
1198: $price .= '</span>';
1199: $prop_bond = $this->get_property_bond();
1200: if ( ! empty( $prop_bond ) && in_array( $this->get_epl_settings( 'display_bond' ), array( 1, 'yes' ) ) ) { // phpcs:ignore
1201: $price .= '<span class="bond">' . $this->get_property_bond() . '</span>';
1202: }
1203: } elseif ( 'leased' === $this->get_property_meta( 'property_status' ) ) {
1204: $price = '<span class="page-price sold-status">' . $this->label_leased . '</span>';
1205:
1206: } else {
1207: $price = '<span class="page-price">' . $this->get_poa_label( __( 'TBA', 'easy-property-listings' ) ) . '</span>';
1208: }
1209: } elseif ( 'commercial' === $this->post_type || 'commercial_land' === $this->post_type ) {
1210: $prop_com_rent_period = $this->get_property_meta( 'property_com_rent_period' );
1211: $rent_lease_type =
1212: ! empty( $prop_com_rent_period ) ? epl_listing_load_meta_commercial_rent_period_value( $this->get_property_meta( 'property_com_rent_period' ) ) : apply_filters( 'epl_pa_label', __( 'P.A.', 'easy-property-listings' ) );
1213:
1214: // Sale or both.
1215: $price = '';
1216: if ( $this->get_property_meta( 'property_com_listing_type' ) === 'sale' || $this->get_property_meta( 'property_com_listing_type' ) === 'both' ) {
1217:
1218: if ( $this->get_property_meta( 'property_com_authority' ) === 'auction' ) { // Auction.
1219: $price = '<span class="page-price auction">' . apply_filters( 'epl_commercial_auction_label', __( 'Auction', 'easy-property-listings' ) ) . ' ' . $this->get_property_auction() . '</span>';
1220: } elseif ( ! empty( $prop_price_view ) && $this->get_property_meta( 'property_com_listing_type' ) === 'both' ) {
1221: $price = '<span class="page-price">
1222: <span class="page-price-prefix">
1223: <span class="page-price-prefix">' .
1224: apply_filters( 'epl_commercial_for_sale_label', __( 'For Sale', 'easy-property-listings' ) ) . ':
1225: </span> ' . $this->get_property_price_display() . '
1226: </span>
1227: <span class="epl-clear"></span>
1228: <span class="page-price-prefix">
1229: <span class="page-price-prefix">' .
1230: apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . ':
1231: </span> ' . $this->get_property_com_rent() . ' ' . $rent_lease_type . '
1232: </span>
1233: </span>
1234: ';
1235: } elseif ( ! empty( $price_display ) && 'yes' === $this->get_property_meta( 'property_price_display' ) ) { // Property.
1236: $price = '<span class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_sale_label', __( 'For Sale', 'easy-property-listings' ) ) . '</span> ' . $this->get_property_price_display() . $this->get_property_tax() . '</span>';
1237: } else {
1238: $price = '<span class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_sale_label', __( 'For Sale', 'easy-property-listings' ) ) . '</span> ' . $this->get_poa_label( '' ) . '</span>';
1239: }
1240: }
1241:
1242: // Lease.
1243: if ( $this->get_property_meta( 'property_com_listing_type' ) === 'lease' ) {
1244: $both = $this->get_property_meta( 'property_com_listing_type' ) === 'both' ? '<div class="epl-clear"></div>' : '';
1245:
1246: // Show Price.
1247: if ( $this->get_property_meta( 'property_price_display' ) === 'yes' ) {
1248: if ( ! empty( $price_display ) ) {
1249: $price .= $both . '<span class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . '</span> ' . $this->get_property_price_display() . '</span>';
1250:
1251: } elseif ( ! empty( $prop_com_rent ) ) {
1252: $price .= $both . '<span class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . '</span> ' . $this->get_property_com_rent() . ' ' . $rent_lease_type . '</span>';
1253: }
1254: } else {
1255: // Hide Price.
1256: $poa_label = $this->get_poa_label();
1257: if ( null !== $poa_label ) {
1258: $price .= $both . '<span class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . '</span> ' . $poa_label . '</span>';
1259: }
1260: }
1261:
1262: // Price text override.
1263: if ( ! empty( $prop_price_view ) ) {
1264: $price = '<span class="page-price"><span class="page-price-prefix">' . $this->get_property_price_display() . '</span>';
1265: }
1266: }
1267:
1268: // Both (Add Lease Price Details).
1269: if ( $this->get_property_meta( 'property_com_listing_type' ) === 'both' ) {
1270: $both = $this->get_property_meta( 'property_com_listing_type' ) === 'both' ? '<div class="epl-clear"></div>' : '';
1271:
1272: // Show Price.
1273: if ( $this->get_property_meta( 'property_price_display' ) === 'yes' && empty( $prop_price_view ) ) {
1274:
1275: if ( ! empty( $prop_com_rent ) ) {
1276: $price .= $both . '<span class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . '</span> ' . $this->get_property_com_rent() . ' ' . $rent_lease_type . '</span>';
1277: }
1278: } else {
1279: // Hide Price.
1280: $poa_label = $this->get_poa_label();
1281: if ( null !== $poa_label && empty( $prop_price_view ) ) {
1282: $price .= $both . '<span class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . '</span> ' . $poa_label . '</span>';
1283: }
1284: }
1285: }
1286:
1287: // Status.
1288: if ( 'sold' === $this->get_property_meta( 'property_status' ) ) {
1289: $price = '<span class="page-price sold-status">' . $this->label_sold . '</span>' . $this->get_property_price_sold_display();
1290: }
1291: if ( $this->is_under_offer() ) { // Under Offer.
1292: $price = $this->get_under_offer_price( $price, 'div' );
1293: }
1294: if ( 'leased' === $this->get_property_meta( 'property_status' ) ) {
1295: $price = '<span class="page-price leased-status sold-status">' . $this->label_leased . '</span>' . $this->get_property_price_lease_display();
1296: }
1297: }
1298: return apply_filters( 'epl_get_price', $price );
1299: }
1300:
1301: /**
1302: * Price Sticker
1303: *
1304: * @return string
1305: * @throws Exception PHP 5.3 notice.
1306: * @since 2.0
1307: * @since 3.5 Added fix for trim when string string is null.
1308: * @since 3.5.14 Added missing new status sticker for commercial listings.
1309: * @since 3.6 Uses is_under_offer(). Sticker output unchanged.
1310: */
1311: public function get_price_sticker() {
1312: $price_sticker = '';
1313: $date = new DateTime( $this->post->post_date );
1314: $now = new DateTime();
1315:
1316: // php > 5.3.
1317: if ( method_exists( $now, 'diff' ) ) {
1318:
1319: $diff = $now->diff( $date );
1320: $diff = $diff->days;
1321: } else {
1322: $diff = strtotime( $now->format( 'M d Y ' ) ) - strtotime( $date->format( 'M d Y ' ) );
1323: $diff = floor( $diff / 3600 / 24 );
1324:
1325: }
1326:
1327: $inspection_time = ! is_null( $this->get_property_meta( 'property_inspection_times' ) ) ? $this->get_property_meta( 'property_inspection_times' ) : '';
1328: $inspection_time = trim( $inspection_time );
1329: if ( 'property' === $this->post_type || 'land' === $this->post_type || 'rural' === $this->post_type || 'business' === $this->post_type ) {
1330: $price_sticker = '';
1331: if ( 'sold' === $this->get_property_meta( 'property_status' ) ) {
1332: $price_sticker .= '<span class="status-sticker sold">' . $this->label_sold . '</span>';
1333: } else {
1334: // Property.
1335: $price_sticker = '';
1336:
1337: if ( $this->get_epl_settings( 'sticker_new_range' ) >= $diff ) {
1338: $price_sticker .= '<span class="status-sticker new">' . $this->get_epl_settings( 'label_new' ) . '</span>';
1339: }
1340:
1341: if ( ! empty( $inspection_time ) ) {
1342: $price_sticker .= '<span class="status-sticker open">' . $this->get_epl_settings( 'label_home_open' ) . '</span>';
1343: }
1344: }
1345: if ( $this->is_under_offer() ) {
1346: $price_sticker = '';
1347: $price_sticker .= '<span class="status-sticker under-offer">' . $this->label_under_offer . '</span>';
1348: }
1349: } elseif ( 'rental' === $this->post_type ) {
1350:
1351: if ( 'leased' === $this->get_property_meta( 'property_status' ) ) {
1352: $price_sticker = '';
1353: $price_sticker .= '<span class="status-sticker leased">' . $this->label_leased . '</span>';
1354:
1355: } else {
1356: $price_sticker = '';
1357: if ( $this->get_epl_settings( 'sticker_new_range' ) >= $diff ) {
1358: $price_sticker .= '<span class="status-sticker new">' . $this->get_epl_settings( 'label_new' ) . '</span>';
1359: }
1360:
1361: if ( ! empty( $inspection_time ) ) {
1362: $price_sticker .= '<span class="status-sticker open">' . $this->get_epl_settings( 'label_home_open' ) . '</span>';
1363: }
1364: }
1365: } elseif ( 'commercial' === $this->post_type || 'commercial_land' === $this->post_type ) {
1366: $price_sticker = '';
1367:
1368: if ( 'sold' !== $this->get_property_meta( 'property_status' ) || 'leased' !== $this->get_property_meta( 'property_status' ) ) {
1369: if ( $this->get_epl_settings( 'sticker_new_range' ) >= $diff ) {
1370: $price_sticker .= '<span class="status-sticker new">' . $this->get_epl_settings( 'label_new' ) . '</span>';
1371: }
1372: }
1373:
1374: if ( 'sold' === $this->get_property_meta( 'property_status' ) ) {
1375: $price_sticker .= '<span class="status-sticker sold">' . $this->label_sold . '</span>';
1376: }
1377:
1378: if ( 'leased' === $this->get_property_meta( 'property_status' ) ) {
1379: $price_sticker .= '<span class="status-sticker leased">' . $this->label_leased . '</span>';
1380: }
1381:
1382: if ( $this->is_under_offer() ) {
1383: $price_sticker = '';
1384: $price_sticker .= '<span class="status-sticker under-offer">' . $this->label_under_offer . '</span>';
1385: }
1386: }
1387:
1388: do_action( 'epl_property_stickers', $this ); // Add more stickers.
1389: return apply_filters( 'epl_get_price_sticker', $price_sticker );
1390: }
1391:
1392: /**
1393: * Get list style price
1394: *
1395: * @return string
1396: *
1397: * @since 2.0.0
1398: * @since 3.4.38 Added epl_price_rent_period filter. Added filter epl_pa_price for P.A label.
1399: * @since 3.6 Under offer listings keep the advertised price next to the Under Offer label unless hidden in the settings. Uses is_under_offer(), get_poa_label() and get_under_offer_price(). Fixed the undefined $price_plain_value warning when the No Price label setting is missing.
1400: */
1401: public function get_l_price() {
1402: $price_display = $this->get_property_price_display();
1403: $l_price = '';
1404:
1405: if ( 'property' === $this->post_type || 'land' === $this->post_type || 'rural' === $this->post_type || 'business' === $this->post_type ) {
1406: if ( 'sold' === $this->get_property_meta( 'property_status' ) ) {
1407: $l_price = '<li class="page-price sold-status">' . $this->label_sold . '</li>';
1408: } elseif ( ! empty( $price_display ) && 'yes' === $this->get_property_meta( 'property_price_display' ) ) { // Property.
1409: $l_price = '<li class="page-price">' . $this->get_property_price_display() . '</li>';
1410: } else {
1411: $l_price = '<li class="page-price">' . $this->get_poa_label( __( 'POA', 'easy-property-listings' ) ) . '</li>';
1412: }
1413: if ( $this->is_under_offer() ) {
1414: $l_price = $this->get_under_offer_price( $this->get_property_price_display(), 'li' );
1415: }
1416: } elseif ( 'rental' === $this->post_type ) {
1417: $prop_rent = $this->get_property_rent();
1418: if ( ! empty( $prop_rent ) && 'yes' === $this->get_property_meta( 'property_rent_display' ) && 'leased' !== $this->get_property_meta( 'property_status' ) ) {
1419: $price_rent_period = $this->get_property_meta( 'property_rent_period' );
1420: $price_rent_period = apply_filters( 'epl_price_rent_period', $price_rent_period );
1421: $l_price = '<li class="page-price-rent">
1422: <span class="page-price" style="margin-right:0;">' . $this->get_property_rent() . '</span>
1423: <span class="rent-period">/' . $price_rent_period . '</span>
1424: </li>';
1425:
1426: } elseif ( 'leased' === $this->get_property_meta( 'property_status' ) ) {
1427: $l_price = '<li class="page-price sold-status">' . $this->label_leased . '</li>';
1428: }
1429: } elseif ( 'commercial' === $this->post_type || 'commercial_land' === $this->post_type ) {
1430: $prop_com_rent_period = $this->get_property_meta( 'property_com_rent_period' );
1431: $prop_com_rent = $this->get_property_com_rent();
1432: $rent_lease_type =
1433: ! empty( $prop_com_rent_period ) ? epl_listing_load_meta_commercial_rent_period_value( $this->get_property_meta( 'property_com_rent_period' ) ) : apply_filters( 'epl_pa_label', __( 'P.A.', 'easy-property-listings' ) );
1434: if ( 'sold' === $this->get_property_meta( 'property_status' ) ) {
1435: $l_price = '<li class="status-sticker sold">' . $this->label_sold . '</li>';
1436: } elseif ( ! empty( $price_display ) && 'yes' === $this->get_property_meta( 'property_price_display' ) ) { // Property.
1437: $l_price = '<li class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_sale_label', __( 'For Sale', 'easy-property-listings' ) ) . '</span> ' . $this->get_property_price_display() . $this->get_property_tax() . '</li>';
1438: } else {
1439: $l_price = '<li class="page-price">' . $this->get_poa_label( '' ) . '</li>';
1440: }
1441: if ( $this->is_under_offer() ) {
1442: $l_price = $this->get_under_offer_price( trim( wp_strip_all_tags( $l_price ) ), 'li' );
1443: }
1444: if ( ! empty( $prop_com_rent ) && $this->get_property_meta( 'property_com_listing_type' ) === 'both' ) {
1445:
1446: $l_price .= '<li class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . '</span> ' . $this->get_property_com_rent() . ' ' . $rent_lease_type . '</li>';
1447: } elseif ( ! empty( $prop_com_rent ) && $this->get_property_meta( 'property_com_listing_type' ) === 'lease' ) {
1448: $l_price = '<li class="page-price"><span class="page-price-prefix">' . apply_filters( 'epl_commercial_for_lease_label', __( 'For Lease', 'easy-property-listings' ) ) . '</span> ' . $this->get_property_com_rent() . ' ' . $rent_lease_type . '</li>';
1449: }
1450: }
1451: return apply_filters( 'epl_get_price_in_list', $l_price );
1452: }
1453:
1454: /**
1455: * Get Year Built
1456: *
1457: * @since 2.0
1458: * @param string $returntype Options i = span, v = value, d = string, l = list item, t = text.
1459: * @return string
1460: *
1461: * @since 3.5.0 Added filter for empty values.
1462: */
1463: public function get_property_year_built( $returntype = 'i' ) {
1464:
1465: $year_built = $this->get_property_meta( 'property_year_built', false );
1466: $label = apply_filters( 'epl_get_property_year_built_label', __( 'Built', 'easy-property-listings' ) );
1467:
1468: if ( empty( $year_built ) ) {
1469: return apply_filters( 'epl_get_year_built_empty_value', null, $returntype, $year_built, $label );
1470: }
1471:
1472: $returntype = apply_filters( 'epl_get_property_year_built_return_type', $returntype );
1473: $value = $this->get_property_meta( 'property_year_built' );
1474:
1475: $return = '';
1476:
1477: switch ( $returntype ) {
1478:
1479: case 'i':
1480: $return = '<span title="' . $label . '" class="icon year-built"><span class="icon-value">' . $value . '</span></span>';
1481: break;
1482:
1483: case 'v':
1484: $return = $value;
1485: break;
1486:
1487: case 't':
1488: $return = '<div class="epl-text-icon-container epl-text-icon-container-year-built">
1489: <span class="epl-text-icon-label year-built">' . $label . '</span>
1490: <span class="epl-text-icon-value year-built">' . $value . '</span>
1491: </div>';
1492: break;
1493:
1494: case 'd':
1495: $return = $label . ' ' . $value . ' ';
1496: break;
1497:
1498: case 'l':
1499: $return = '<li class="year-built">' . $label . ' ' . $value . '</li>';
1500: break;
1501: }
1502: return apply_filters( 'epl_get_property_year_built', $return, $returntype, $value, $label );
1503: }
1504:
1505: /**
1506: * Get Bedrooms
1507: *
1508: * @since 2.0
1509: * @param string $returntype Options i = span, v = value, d = string, l = list item, t = text, s = svg icon.
1510: * @return string
1511: *
1512: * @since 3.5.0 Added filter for empty values.
1513: */
1514: public function get_property_bed( $returntype = 'i' ) {
1515:
1516: $value = $this->get_property_meta( 'property_bedrooms' );
1517: $label = apply_filters( 'epl_get_property_bedrooms_label', __( 'Bedrooms', 'easy-property-listings' ) );
1518:
1519: if ( empty( $value ) ) {
1520: return apply_filters( 'epl_get_property_bed_empty_value', null, $returntype, $value, $label );
1521: }
1522:
1523: $returntype = 'i' === $returntype && epl_get_option( 'epl_icons_svg_listings' ) === 'on' ? 's' : $returntype;
1524: $returntype = apply_filters( 'epl_get_property_bedrooms_return_type', $returntype );
1525:
1526: $singular = apply_filters( 'epl_get_property_bed_label', __( 'bed', 'easy-property-listings' ) );
1527:
1528: $return = '';
1529:
1530: switch ( $returntype ) {
1531:
1532: case 'i':
1533: $return = '<span title="' . $label . '" class="icon beds"><span class="icon-value">' . $value . '</span></span>';
1534: break;
1535:
1536: case 'v':
1537: $return = $value;
1538: break;
1539:
1540: case 't':
1541: $return = '<div class="epl-text-icon-container epl-text-icon-container-bed">
1542: <span class="epl-text-icon-label bed">' . $label . '</span>
1543: <span class="epl-text-icon-value bed">' . $value . '</span>
1544: </div>';
1545: break;
1546:
1547: case 'd':
1548: $return = $singular . ' ' . $value . ' ';
1549: break;
1550:
1551: case 'l':
1552: $return = '<li class="bedrooms">' . $value . ' ' . $singular . '</li>';
1553: break;
1554:
1555: case 's':
1556: $svg = '<svg viewBox="0 0 100 100" class="epl-icon-svg-bed"><use xlink:href="#epl-icon-svg-bed"></use></svg>';
1557: $return = '<div class="epl-icon-svg-container epl-icon-container-bed">
1558: <div class="epl-icon epl-icon-svg bed" title="' . $label . '">' . $svg . '</div>
1559: <div class="icon-value">' . $value . '</div>
1560: </div>';
1561: break;
1562: }
1563: return apply_filters( 'epl_get_property_bed', $return, $returntype, $value, $label, $singular );
1564: }
1565:
1566: /**
1567: * Get Bathrooms
1568: *
1569: * @since 2.0
1570: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item, s = svg icon.
1571: * @return string
1572: *
1573: * @since 3.5.0 Added filter for empty values.
1574: */
1575: public function get_property_bath( $returntype = 'i' ) {
1576:
1577: $bathrooms = $this->get_property_meta( 'property_bathrooms', false );
1578: $label = apply_filters( 'epl_get_property_bathrooms_label', __( 'Bathrooms', 'easy-property-listings' ) );
1579:
1580: if ( empty( $bathrooms ) ) {
1581: return apply_filters( 'epl_get_property_bath_empty_value', null, $returntype, $bathrooms, $label );
1582: }
1583:
1584: $returntype = 'i' === $returntype && epl_get_option( 'epl_icons_svg_listings' ) === 'on' ? 's' : $returntype;
1585: $returntype = apply_filters( 'epl_get_property_bathrooms_return_type', $returntype );
1586:
1587: $singular = apply_filters( 'epl_get_property_bath_label', __( 'bath', 'easy-property-listings' ) );
1588: $value = $this->get_property_meta( 'property_bathrooms' );
1589: $return = '';
1590:
1591: switch ( $returntype ) {
1592:
1593: case 'i':
1594: $return = '<span title="' . $label . '" class="icon bath"><span class="icon-value">' . $value . '</span></span>';
1595: break;
1596:
1597: case 'v':
1598: $return = $value;
1599: break;
1600:
1601: case 't':
1602: $return = '<div class="epl-text-icon-container epl-text-icon-container-bath">
1603: <span class="epl-text-icon-label bath">' . $label . '</span>
1604: <span class="epl-text-icon-value bath">' . $value . '</span>
1605: </div>';
1606: break;
1607:
1608: case 'd':
1609: $return = $singular . ' ' . $value . ' ';
1610: break;
1611:
1612: case 'l':
1613: $return = '<li class="bathrooms">' . $value . ' ' . $singular . '</li>';
1614: break;
1615:
1616: case 's':
1617: $svg = '<svg viewBox="0 0 100 100" class="epl-icon-svg-bath"><use xlink:href="#epl-icon-svg-bath"></use></svg>';
1618: $return = '<div class="epl-icon-svg-container epl-icon-container-bath">
1619: <div class="epl-icon epl-icon-svg bath" title="' . $label . '">' . $svg . '</div>
1620: <div class="icon-value">' . $value . '</div>
1621: </div>';
1622: break;
1623:
1624: }
1625: return apply_filters( 'epl_get_property_bath', $return, $returntype, $value, $label, $singular );
1626: }
1627:
1628: /**
1629: * Get Rooms
1630: *
1631: * @since 2.0
1632: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
1633: * @return string
1634: *
1635: * @since 3.5.0 Added filter for empty values.
1636: */
1637: public function get_property_rooms( $returntype = 'i' ) {
1638:
1639: $rooms = $this->get_property_meta( 'property_rooms', false );
1640: $label = apply_filters( 'epl_get_property_rooms_label', __( 'Rooms', 'easy-property-listings' ) );
1641:
1642: if ( empty( $rooms ) ) {
1643: return apply_filters( 'epl_get_property_rooms_empty_value', null, $returntype, $rooms, $label );
1644: }
1645:
1646: $returntype = apply_filters( 'epl_get_property_rooms_return_type', $returntype );
1647:
1648: $value = $this->get_property_meta( 'property_rooms' );
1649: $return = '';
1650:
1651: switch ( $returntype ) {
1652:
1653: case 'i':
1654: $return = '<span title="' . $label . '" class="icon rooms"><span class="icon-value">' . $value . '</span></span>';
1655: break;
1656:
1657: case 'v':
1658: $return = $value;
1659: break;
1660:
1661: case 't':
1662: $return = '<div class="epl-text-icon-container epl-text-icon-container-rooms">
1663: <span class="epl-text-icon-label rooms">' . $label . '</span>
1664: <span class="epl-text-icon-value rooms">' . $value . '</span>
1665: </div>';
1666: break;
1667:
1668: case 'd':
1669: $return = $label . ' ' . $value . ' ';
1670: break;
1671:
1672: case 'l':
1673: $return = '<li class="rooms">' . $value . ' ' . $label . '</li>';
1674: break;
1675: }
1676: return apply_filters( 'epl_get_property_rooms', $return, $returntype, $value, $label );
1677: }
1678:
1679: /**
1680: * Get Parking
1681: *
1682: * Caluclated value based on number of garages + carports
1683: *
1684: * @since 2.0
1685: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item, s = svg icon.
1686: * @return string
1687: * @since 3.4.20 New filter epl_total_parking_spaces for value.
1688: * @since 3.4.21 Removed first check.
1689: * @since 3.5.0 Added filter for empty values.
1690: */
1691: public function get_property_parking( $returntype = 'i' ) {
1692:
1693: $prop_garage = $this->get_property_meta( 'property_garage' );
1694: $prop_carport = $this->get_property_meta( 'property_carport' );
1695:
1696: $returntype = 'i' === $returntype && epl_get_option( 'epl_icons_svg_listings' ) === 'on' ? 's' : $returntype;
1697: $returntype = apply_filters( 'epl_get_property_parking_spaces_return_type', $returntype );
1698:
1699: $property_garage = intval( $this->get_property_meta( 'property_garage' ) );
1700: $property_carport = intval( $this->get_property_meta( 'property_carport' ) );
1701: $value = $property_carport + $property_garage;
1702: $value = apply_filters( 'epl_total_parking_spaces', $value );
1703: $label = apply_filters( 'epl_get_parking_spaces_label', __( 'Parking Spaces', 'easy-property-listings' ) );
1704:
1705: if ( 0 === $value ) {
1706: return apply_filters( 'epl_get_parking_spaces_empty_value', null, $returntype, $value, $label );
1707: }
1708:
1709: $return = '';
1710:
1711: switch ( $returntype ) {
1712:
1713: case 'i':
1714: $return = '<span title="' . $label . '" class="icon parking"><span class="icon-value">' . $value . '</span></span>';
1715: break;
1716:
1717: case 'v':
1718: $return = $value;
1719: break;
1720:
1721: case 't':
1722: $return = '<div class="epl-text-icon-container epl-text-icon-container-parking">
1723: <span class="epl-text-icon-label parking">' . $label . '</span>
1724: <span class="epl-text-icon-value parking">' . $value . '</span>
1725: </div>';
1726: break;
1727:
1728: case 'd':
1729: $return = $label . ' ' . $value . ' ';
1730: break;
1731:
1732: case 'l':
1733: $return = '<li class="parking">' . $value . ' ' . $label . '</li>';
1734: break;
1735:
1736: case 's':
1737: $svg = '<svg viewBox="0 0 100 100" class="epl-icon-svg-car"><use xlink:href="#epl-icon-svg-car"></use></svg>';
1738: $return = '<div class="epl-icon-svg-container epl-icon-container-car">
1739: <div class="epl-icon epl-icon-svg car" title="' . $label . '">' . $svg . '</div>
1740: <div class="icon-value">' . $value . '</div>
1741: </div>';
1742: break;
1743: }
1744: return apply_filters( 'epl_get_property_parking', $return, $returntype, $value, $label );
1745: }
1746:
1747: /**
1748: * Get Garage
1749: *
1750: * @since 2.0
1751: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
1752: * @return string
1753: *
1754: * @since 3.5.0 Added filter for empty values.
1755: */
1756: public function get_property_garage( $returntype = 'i' ) {
1757:
1758: $prop_garage = $this->get_property_meta( 'property_garage' );
1759: $label = apply_filters( 'epl_get_property_garage_label', __( 'garage', 'easy-property-listings' ) );
1760:
1761: if ( empty( $prop_garage ) ) {
1762: return apply_filters( 'epl_get_property_garage_empty_value', null, $returntype, $prop_garage, $label );
1763: }
1764:
1765: $returntype = apply_filters( 'epl_get_property_garage_return_type', $returntype );
1766:
1767: $value = $this->get_property_meta( 'property_garage' );
1768: $return = '';
1769:
1770: switch ( $returntype ) {
1771:
1772: case 'i':
1773: $return = '<span title="' . $label . '" class="icon parking"><span class="icon-value">' . $value . '</span></span>';
1774: break;
1775:
1776: case 'v':
1777: $return = $value;
1778: break;
1779:
1780: case 't':
1781: $return = '<div class="epl-text-icon-container epl-text-icon-container-garage">
1782: <span class="epl-text-icon-label garage">' . $label . '</span>
1783: <span class="epl-text-icon-value garage">' . $value . '</span>
1784: </div>';
1785: break;
1786:
1787: case 'd':
1788: $return = $label . ' ' . $value . ' ';
1789: break;
1790:
1791: case 'l':
1792: $return = '<li class="garage">' . $value . ' ' . $label . '</li>';
1793: break;
1794: }
1795: return apply_filters( 'epl_get_property_garage', $return, $returntype, $value, $label );
1796: }
1797:
1798: /**
1799: * Get Carport
1800: *
1801: * @since 2.0
1802: * @since 3.4.5 Fixed the incorrect meta key
1803: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
1804: * @return string
1805: *
1806: * @since 3.5.0 Added filter for empty values.
1807: */
1808: public function get_property_carport( $returntype = 'i' ) {
1809:
1810: $prop_carport = $this->get_property_meta( 'property_carport' );
1811: $label = apply_filters( 'epl_get_property_carport_label', __( 'carport', 'easy-property-listings' ) );
1812:
1813: if ( empty( $prop_carport ) ) {
1814: return apply_filters( 'epl_get_property_carport_empty_value', null, $returntype, $prop_carport, $label );
1815: }
1816:
1817: $returntype = apply_filters( 'epl_get_property_carport_return_type', $returntype );
1818:
1819: $value = $this->get_property_meta( 'property_carport' );
1820: $return = '';
1821:
1822: switch ( $returntype ) {
1823:
1824: case 'i':
1825: $return = '<span title="' . $label . '" class="icon parking"><span class="icon-value">' . $value . '</span></span>';
1826: break;
1827:
1828: case 'v':
1829: $return = $value;
1830: break;
1831:
1832: case 't':
1833: $return = '<div class="epl-text-icon-container epl-text-icon-container-carport">
1834: <span class="epl-text-icon-label carport">' . $label . '</span>
1835: <span class="epl-text-icon-value carport">' . $value . '</span>
1836: </div>';
1837: break;
1838:
1839: case 'd':
1840: $return = $label . ' ' . $value . ' ';
1841: break;
1842:
1843: case 'l':
1844: $return = '<li class="carport">' . $value . ' ' . $label . '</li>';
1845: break;
1846: }
1847: return apply_filters( 'epl_get_property_carport', $return, $returntype, $value, $label );
1848: }
1849:
1850: /**
1851: * Get Air Conditioning
1852: *
1853: * @since 2.0
1854: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item, s = svg icon.
1855: * @return string
1856: *
1857: * @since 3.5.0 Added filter for empty values.
1858: */
1859: public function get_property_air_conditioning( $returntype = 'i' ) {
1860:
1861: $prop_ac = $this->get_property_meta( 'property_air_conditioning' );
1862: $label = apply_filters( 'epl_get_property_air_conditioning_label', __( 'Air Conditioning', 'easy-property-listings' ) );
1863:
1864: if ( empty( $prop_ac ) ) {
1865: return apply_filters( 'epl_get_air_conditioning_empty_value', null, $returntype, $prop_ac, $label );
1866: }
1867:
1868: $returntype = 'i' === $returntype && epl_get_option( 'epl_icons_svg_listings' ) === 'on' ? 's' : $returntype;
1869: $returntype = apply_filters( 'epl_get_property_air_conditioning_return_type', $returntype );
1870:
1871: $value = $this->get_property_meta( 'property_air_conditioning' );
1872: $return = '';
1873:
1874: if ( epl_value_bool_checker( $value ) ) {
1875:
1876: switch ( $returntype ) {
1877:
1878: case 'i':
1879: $return = '<span title="' . $label . '" class="icon air"></span>';
1880: break;
1881:
1882: case 'v':
1883: $return = $value;
1884: break;
1885:
1886: case 't':
1887: $return = '<div class="epl-text-icon-container epl-text-icon-container-air">
1888: <span class="epl-text-icon-label air">' . $label . '</span>
1889: </div>';
1890: break;
1891:
1892: case 'd':
1893: $return = $label . ' ' . $value . ' ';
1894: break;
1895:
1896: case 'l':
1897: $return = '<li class="air">' . $label . '</li>';
1898: break;
1899:
1900: case 's':
1901: $svg = '<svg viewBox="0 0 100 100" class="epl-icon-svg-air"><use xlink:href="#epl-icon-svg-air"></use></svg>';
1902: $return = '<div class="epl-icon-svg-container epl-icon-container-air">
1903: <div class="epl-icon epl-icon-svg air" title="' . $label . '">' . $svg . '</div>
1904: </div>';
1905: break;
1906: }
1907: return apply_filters( 'epl_get_property_air_conditioning', $return, $returntype, $value, $label );
1908: }
1909: }
1910:
1911: /**
1912: * Get Pool
1913: *
1914: * @since 2.0
1915: * @param string $returntype Options Options i = span, v = raw value, t = text, d = string, l = list item, s = svg icon.
1916: * @return string
1917: *
1918: * @since 3.5.0 Added filter for empty values.
1919: */
1920: public function get_property_pool( $returntype = 'i' ) {
1921:
1922: $prop_pool = $this->get_property_meta( 'property_pool' );
1923: $label = apply_filters( 'epl_get_property_pool_label', __( 'Pool', 'easy-property-listings' ) );
1924:
1925: if ( empty( $prop_pool ) ) {
1926: return apply_filters( 'epl_get_property_pool_empty_value', null, $returntype, $prop_pool, $label );
1927: }
1928:
1929: $returntype = 'i' === $returntype && epl_get_option( 'epl_icons_svg_listings' ) === 'on' ? 's' : $returntype;
1930: $returntype = apply_filters( 'epl_get_property_pool_return_type', $returntype );
1931:
1932: $value = $this->get_property_meta( 'property_pool' );
1933: $return = '';
1934:
1935: if ( epl_value_bool_checker( $value ) ) {
1936:
1937: switch ( $returntype ) {
1938:
1939: case 'i':
1940: $return = '<span title="' . $label . '" class="icon pool"></span>';
1941: break;
1942:
1943: case 'v':
1944: $return = $value;
1945: break;
1946:
1947: case 't':
1948: $return = '<div class="epl-text-icon-container epl-text-icon-container-pool">
1949: <span class="epl-text-icon-label pool">' . $label . '</span>
1950: </div>';
1951: break;
1952:
1953: case 'd':
1954: $return = $label . ' ' . $value . ' ';
1955: break;
1956:
1957: case 'l':
1958: $return = '<li class="pool">' . $label . '</li>';
1959: break;
1960:
1961: case 's':
1962: $svg = '<svg viewBox="0 0 100 100" class="epl-icon-svg-pool"><use xlink:href="#epl-icon-svg-pool"></use></svg>';
1963: $return = '<div class="epl-icon-svg-container epl-icon-container-pool">
1964: <div class="epl-icon epl-icon-svg pool" title="' . $label . '">' . $svg . '</div>
1965: </div>';
1966: break;
1967: }
1968: return apply_filters( 'epl_get_property_pool', $return, $returntype, $value, $label );
1969: }
1970: }
1971:
1972: /**
1973: * Get Security System
1974: *
1975: * @since 2.0
1976: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
1977: * @return string
1978: *
1979: * @since 3.5.0 Added filter for empty values.
1980: */
1981: public function get_property_security_system( $returntype = 'i' ) {
1982:
1983: $value = $this->get_property_meta( 'property_security_system' );
1984: $label = apply_filters( 'epl_get_property_security_system_label', __( 'Alarm System', 'easy-property-listings' ) );
1985:
1986: if ( empty( $value ) ) {
1987: return apply_filters( 'epl_get_security_system_empty_value', null, $returntype, $value, $label );
1988: }
1989:
1990: $returntype = apply_filters( 'epl_get_property_security_system_return_type', $returntype );
1991:
1992: $return = '';
1993:
1994: if ( epl_value_bool_checker( $value ) ) {
1995:
1996: switch ( $returntype ) {
1997:
1998: case 'i':
1999: $return = '<span title="' . $label . '" class="icon alarm"></span>';
2000: break;
2001:
2002: case 'v':
2003: $return = $value;
2004: break;
2005:
2006: case 't':
2007: $return = '<div class="epl-text-icon-container epl-text-icon-container-alarm">
2008: <span class="epl-text-icon-label alarm">' . $label . '</span>
2009: </div>';
2010: break;
2011:
2012: case 'd':
2013: $return = $label . ' ' . $value . ' ';
2014: break;
2015:
2016: case 'l':
2017: $return = '<li class="alarm">' . $label . '</li>';
2018: break;
2019: }
2020: return apply_filters( 'epl_get_property_security_system', $return, $returntype, $value, $label );
2021: }
2022: }
2023:
2024: /**
2025: * Get Land Value
2026: *
2027: * @since 2.0
2028: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
2029: * @return string
2030: *
2031: * @since 3.4.38 Fix: Don't display land area when it's < 0.
2032: * @since 3.4.42 Fix : Fatal error if area is non numeric.
2033: */
2034: public function get_property_land_value( $returntype = 'i' ) {
2035:
2036: $property_land_area = $this->get_property_meta( 'property_land_area' );
2037:
2038: $property_land_area_unit = $this->get_property_meta( 'property_land_area_unit' );
2039: if ( 'squareMeter' === $property_land_area_unit ) {
2040: $property_land_area_unit = __( 'm&#178;', 'easy-property-listings' );
2041: } elseif ( 'acre' === $property_land_area_unit ) {
2042: $property_land_area_unit = $property_land_area > 1 ? 'acres' : 'acre';
2043: $property_land_area_unit = $property_land_area_unit;
2044: } else {
2045: // translation for land area unit.
2046: $property_land_area_unit = $property_land_area_unit;
2047: }
2048:
2049: $property_land_area_unit = apply_filters( 'epl_property_land_area_unit_label', $property_land_area_unit );
2050:
2051: if ( is_numeric( $this->get_property_meta( 'property_land_area' ) ) && 0 < $this->get_property_meta( 'property_land_area' ) ) {
2052:
2053: $label = apply_filters( 'epl_get_property_land_area_label', __( 'Land is', 'easy-property-listings' ) );
2054:
2055: // Decimal.
2056: if ( fmod( floatval( $property_land_area ), 1 ) !== 0.00 ) {
2057: $property_land_area_format = apply_filters( 'epl_property_land_area_format_decimal', number_format_i18n( $property_land_area, 2 ) );
2058: } else {
2059: // No decimal.
2060: $property_land_area_format = apply_filters( 'epl_property_land_area_format', number_format_i18n( $property_land_area ) );
2061: }
2062:
2063: $return = '<li class="land-size">' . $label . ' ' . $property_land_area_format . ' ' . $property_land_area_unit . '</li>';
2064:
2065: $label = apply_filters( 'epl_get_property_land_area_label', __( 'Land is', 'easy-property-listings' ) );
2066: $value = $property_land_area_format . ' ' . $property_land_area_unit;
2067: $return = '';
2068:
2069: switch ( $returntype ) {
2070:
2071: case 'i':
2072: $return = '<span title="' . $label . '" class="icon land-size"><span class="icon-value">' . $value . '</span></span>';
2073: break;
2074:
2075: case 'v':
2076: $return = $value;
2077: break;
2078:
2079: case 't':
2080: $return = '<div class="epl-text-icon-container epl-text-icon-container-land-size">
2081: <span class="epl-text-icon-label land-size">' . $label . '</span>
2082: <span class="epl-text-icon-value land-size">' . $value . '</span>
2083: </div>';
2084: break;
2085:
2086: case 'd':
2087: $return = $label . ' ' . $value . ' ';
2088: break;
2089:
2090: case 'l':
2091: $return = '<li class="land-size">' . $label . ' ' . $value . '</li>';
2092: break;
2093: }
2094: return apply_filters( 'epl_get_property_land_value', $return, $returntype, $value, $label );
2095: }
2096: }
2097:
2098: /**
2099: * Get Building area
2100: *
2101: * @since 2.0
2102: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
2103: * @return string
2104: * @since 3.4.42 Fix : Fatal error if area is non numeric.
2105: */
2106: public function get_property_building_area_value( $returntype = 'i' ) {
2107:
2108: $building_area = $this->get_property_meta( 'property_building_area' );
2109:
2110: $building_unit = $this->get_property_meta( 'property_building_area_unit' );
2111: if ( 'squareMeter' === $building_unit ) {
2112: $building_unit = __( 'm&#178;', 'easy-property-listings' );
2113: } elseif ( 'acre' === $building_unit ) {
2114: $building_unit = $building_area > 1 ? 'acres' : 'acre';
2115: $building_unit = $building_unit;
2116: } else {
2117: // Translation for building area unit.
2118: $building_unit = $building_unit;
2119: }
2120:
2121: $building_unit = apply_filters( 'epl_property_building_area_unit_label', $building_unit );
2122:
2123: if ( intval( $this->get_property_meta( 'property_building_area' ) ) !== 0 ) {
2124:
2125: $label = apply_filters( 'epl_get_property_building_area_label', __( 'Floor Area is', 'easy-property-listings' ) );
2126:
2127: // Decimal.
2128: if ( fmod( floatval( $building_area ), 1 ) !== 0.00 ) {
2129: $building_area_format = apply_filters( 'epl_property_building_area_format_decimal', number_format_i18n( $building_area, 2 ) );
2130: } else {
2131: // No decimal.
2132: $building_area_format = apply_filters( 'epl_property_building_area_format', number_format_i18n( $building_area ) );
2133: }
2134:
2135: $return = '<li class="building-size">' . $label . ' ' . $building_area_format . ' ' . $building_unit . '</li>';
2136:
2137: $label = apply_filters( 'epl_get_property_building_area_label', __( 'Floor Area is', 'easy-property-listings' ) );
2138: $value = $building_area_format . ' ' . $building_unit;
2139: $return = '';
2140:
2141: switch ( $returntype ) {
2142:
2143: case 'i':
2144: $return = '<span title="' . $label . '" class="icon building-size"><span class="icon-value">' . $value . '</span></span>';
2145: break;
2146:
2147: case 'v':
2148: $return = $value;
2149: break;
2150:
2151: case 't':
2152: $return = '<div class="epl-text-icon-container epl-text-icon-container-building-size">
2153: <span class="epl-text-icon-label building-size">' . $label . '</span>
2154: <span class="epl-text-icon-value building-size">' . $value . '</span>
2155: </div>';
2156: break;
2157:
2158: case 'd':
2159: $return = $label . ' ' . $value . ' ';
2160: break;
2161:
2162: case 'l':
2163: $return = '<li class="building-size">' . $label . ' ' . $value . '</li>';
2164: break;
2165: }
2166: return apply_filters( 'epl_get_property_building_area_value', $return, $returntype, $value, $label );
2167: }
2168: }
2169:
2170: /**
2171: * Get Building Energy Rating
2172: *
2173: * @since 3.1.20
2174: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
2175: * @return string
2176: */
2177: public function get_property_energy_rating( $returntype = 'i' ) {
2178:
2179: $value = $this->get_property_meta( 'property_energy_rating' );
2180: $return = '';
2181: $returntype = apply_filters( 'epl_get_property_energy_rating_return_type', $returntype );
2182:
2183: if ( ! empty( $value ) ) {
2184:
2185: $label = apply_filters( 'epl_get_property_energy_rating_label', __( 'Energy Rating', 'easy-property-listings' ) );
2186: switch ( $returntype ) {
2187:
2188: case 'i':
2189: $return = '<span title="' . $label . '" class="icon energy_rating"><span class="icon-value">' . $value . '</span></span>';
2190: break;
2191:
2192: case 'v':
2193: $return = $value;
2194: break;
2195:
2196: case 't':
2197: $return = '<div class="epl-text-icon-container epl-text-icon-container-energy_rating">
2198: <span class="epl-text-icon-label energy_rating">' . $label . '</span>
2199: <span class="epl-text-icon-value energy_rating">' . $value . '</span>
2200: </div>';
2201: break;
2202:
2203: case 'd':
2204: $return = $label . ' ' . $value . ' ';
2205: break;
2206:
2207: case 'l':
2208: $return = '<li class="energy_rating">' . $label . ' ' . $value . '</li>';
2209: break;
2210: }
2211: return apply_filters( 'epl_get_property_energy_rating', $return, $returntype, $value, $label );
2212: }
2213: }
2214:
2215: /**
2216: * Get New Construction
2217: *
2218: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
2219: *
2220: * @return string
2221: *
2222: * @since 2.0
2223: * @since 3.5.13 Using value bool checker function.
2224: */
2225: public function get_property_new_construction( $returntype = 'i' ) {
2226:
2227: $value = $this->get_property_meta( 'property_new_construction' );
2228: $return = '';
2229: $returntype = apply_filters( 'epl_get_property_new_construction_return_type', $returntype );
2230:
2231: if ( epl_value_bool_checker( $value ) ) {
2232:
2233: $label = apply_filters( 'epl_get_property_new_construction_label', __( 'New Construction', 'easy-property-listings' ) );
2234:
2235: switch ( $returntype ) {
2236:
2237: case 'i':
2238: $return = '<span title="' . $label . '" class="icon new_construction"></span>';
2239: break;
2240:
2241: case 'v':
2242: $return = $value;
2243: break;
2244:
2245: case 't':
2246: $return = '<div class="epl-text-icon-container epl-text-icon-container-new_construction">
2247: <span class="epl-text-icon-label new_construction">' . $label . '</span>
2248: </div>';
2249: break;
2250:
2251: case 'd':
2252: $return = $label . ' ' . $value . ' ';
2253: break;
2254:
2255: case 'l':
2256: $return = '<li class="new_construction">' . $label . '</li>';
2257: break;
2258: }
2259:
2260: return apply_filters( 'epl_get_property_new_construction', $return, $returntype, $value, $label );
2261: }
2262: }
2263:
2264: /**
2265: * Get Holiday Rental
2266: *
2267: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
2268: *
2269: * @return string
2270: *
2271: * @since 3.2
2272: * @since 3.5.13 Using value bool checker function.
2273: */
2274: public function get_property_holiday_rental( $returntype = 'i' ) {
2275:
2276: $label = apply_filters( 'epl_get_property_holiday_rental_label', __( 'Holiday Rental', 'easy-property-listings' ) );
2277: $value = $this->get_property_meta( 'property_holiday_rental' );
2278: $return = '';
2279: $returntype = apply_filters( 'epl_get_property_holiday_rental_return_type', $returntype );
2280:
2281: if ( epl_value_bool_checker( $value ) ) {
2282:
2283: switch ( $returntype ) {
2284:
2285: case 'i':
2286: $return = '<span title="' . $label . '" class="icon holiday_rental"></span>';
2287: break;
2288:
2289: case 'v':
2290: $return = $value;
2291: break;
2292:
2293: case 't':
2294: $return = '<div class="epl-text-icon-container epl-text-icon-container-holiday_rental">
2295: <span class="epl-text-icon-label holiday_rental">' . $label . '</span>
2296: </div>';
2297: break;
2298:
2299: case 'd':
2300: $return = $label . ' ' . $value . ' ';
2301: break;
2302:
2303: case 'l':
2304: $return = '<li class="holiday_rental">' . $label . '</li>';
2305: break;
2306: }
2307: return apply_filters( 'epl_get_property_holiday_rental', $return, $returntype, $value, $label );
2308: }
2309: }
2310:
2311: /**
2312: * Get Furnished
2313: *
2314: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
2315: *
2316: * @return string
2317: *
2318: * @since 3.2
2319: * @since 3.5.13 Using value bool checker function.
2320: */
2321: public function get_property_furnished( $returntype = 'i' ) {
2322:
2323: $value = $this->get_property_meta( 'property_furnished' );
2324: $returntype = apply_filters( 'epl_get_property_furnished_return_type', $returntype );
2325: $return = '';
2326:
2327: if ( epl_value_bool_checker( $value ) ) {
2328:
2329: $label = apply_filters( 'epl_get_property_furnished_label', __( 'Furnished', 'easy-property-listings' ) );
2330:
2331: switch ( $returntype ) {
2332:
2333: case 'i':
2334: $return = '<span title="' . $label . '" class="icon furnished"></span>';
2335: break;
2336:
2337: case 'v':
2338: $return = $value;
2339: break;
2340:
2341: case 't':
2342: $return = '<div class="epl-text-icon-container epl-text-icon-container-furnished">
2343: <span class="epl-text-icon-label furnished">' . $label . '</span>
2344: </div>';
2345: break;
2346:
2347: case 'd':
2348: $return = $label . ' ' . $value . ' ';
2349: break;
2350:
2351: case 'l':
2352: $return = '<li class="furnished">' . $label . '</li>';
2353: break;
2354:
2355: }
2356: return apply_filters( 'epl_get_property_furnished', $return, $returntype, $value, $label );
2357: }
2358: }
2359:
2360: /**
2361: * Get Pets
2362: *
2363: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
2364: *
2365: * @return string
2366: *
2367: * @since 3.3
2368: * @since 3.5.13 Using value bool checker function.
2369: */
2370: public function get_property_pets( $returntype = 'i' ) {
2371:
2372: $value = $this->get_property_meta( 'property_pet_friendly' );
2373: $returntype = apply_filters( 'epl_get_property_pet_friendly_return_type', $returntype );
2374: $return = '';
2375:
2376: if ( epl_value_bool_checker( $value ) ) {
2377:
2378: $label = apply_filters( 'epl_get_property_pet_friendly_label', __( 'Pet Friendly', 'easy-property-listings' ) );
2379:
2380: switch ( $returntype ) {
2381:
2382: case 'i':
2383: $return = '<span title="' . $label . '" class="icon pet-friendly"></span>';
2384: break;
2385:
2386: case 'v':
2387: $return = $value;
2388: break;
2389:
2390: case 't':
2391: $return = '<div class="epl-text-icon-container epl-text-icon-container-pet-friendly">
2392: <span class="epl-text-icon-label pet-friendly">' . $label . '</span>
2393: </div>';
2394: break;
2395:
2396: case 'd':
2397: $return = $label . ' ' . $value . ' ';
2398: break;
2399:
2400: case 'l':
2401: $return = '<li class="pet-friendly">' . $label . '</li>';
2402: break;
2403:
2404: }
2405: return apply_filters( 'epl_get_property_pet_friendly', $return, $returntype, $value, $label );
2406: }
2407: }
2408:
2409: /**
2410: * Get Featured
2411: *
2412: * @param string $returntype Options i = span, v = raw value, t = text, d = string, l = list item.
2413: *
2414: * @return string
2415: *
2416: * @since 3.3
2417: * @since 3.5.13 Using value bool checker function.
2418: */
2419: public function get_property_featured( $returntype = 'i' ) {
2420:
2421: $value = $this->get_property_meta( 'property_featured' );
2422: $returntype = apply_filters( 'epl_get_property_featured_return_type', $returntype );
2423: $return = '';
2424:
2425: if ( epl_value_bool_checker( $value ) ) {
2426:
2427: $label = apply_filters( 'epl_get_property_featured_label', __( 'Featured', 'easy-property-listings' ) );
2428:
2429: switch ( $returntype ) {
2430:
2431: case 'i':
2432: $return = '<span title="' . $label . '" class="icon featured"></span>';
2433: break;
2434:
2435: case 'v':
2436: $return = $value;
2437: break;
2438:
2439: case 't':
2440: $return = '<div class="epl-text-icon-container epl-text-icon-container-featured">
2441: <span class="epl-text-icon-label featured">' . $label . '</span>
2442: </div>';
2443: break;
2444:
2445: case 'd':
2446: $return = $label . ' ' . $value . ' ';
2447: break;
2448:
2449: case 'l':
2450: $return = '<li class="featured">' . $label . '</li>';
2451: break;
2452:
2453: }
2454: return apply_filters( 'epl_get_property_property_featured', $return, $returntype, $value, $label );
2455: }
2456: }
2457:
2458: /**
2459: * Get Additional Features by meta key
2460: *
2461: * @since 2.0
2462: * @param string $metakey Meta key name.
2463: * @return mixed Value wrapped in a list item
2464: * @since 3.4.35 Tweak: Support for true/false values in features checklist.
2465: * @since 3.4.44 Parking Comments Label before value.
2466: * @since 3.5.22 Added support for Yes, No syntax values.
2467: */
2468: public function get_additional_features_html( $metakey ) {
2469:
2470: $metavalue = $this->get_property_meta( $metakey );
2471:
2472: $return = '';
2473:
2474: if ( ! empty( $metavalue ) || intval( $metavalue ) !== 0 ) {
2475:
2476: // Commercial Car Spaces : Label Issue (Returning 50 Com Car Spaces. Need to remove com.
2477: if ( 'property_com_car_spaces' === $metakey ) {
2478: $metavalue = $metavalue . apply_filters( 'epl_get_property_com_car_spaces_label', '' );
2479: }
2480:
2481: switch ( $metavalue ) {
2482:
2483: case 1:
2484: case 'yes':
2485: case 'Yes':
2486: case 'YES':
2487: case 'Y':
2488: case 'y':
2489: case 'on':
2490: case 'true':
2491: $return = '<li class="' . $this->get_class_from_metakey( $metakey ) . '">' . apply_filters( 'epl_get_' . $metakey . '_label', $this->get_label_from_metakey( $metakey ) ) . '</li>';
2492: break;
2493:
2494: case 0:
2495: case 'no':
2496: case 'No':
2497: case 'NO':
2498: case 'N':
2499: case 'n':
2500: case 'off':
2501: case 'false':
2502: $return = '';
2503: break;
2504:
2505: default:
2506: if ( 'property_com_parking_comments' === $metakey ) {
2507: $return = '<li class="' . $this->get_class_from_metakey( $metakey ) . '">' . apply_filters( 'epl_get_' . $metakey . '_label', $this->get_label_from_metakey( $metakey ) ) . ' ' . $metavalue . '</li>';
2508: } else {
2509: $return = '<li class="' . $this->get_class_from_metakey( $metakey ) . '">' . $metavalue . ' ' . apply_filters( 'epl_get_' . $metakey . '_label', $this->get_label_from_metakey( $metakey ) ) . '</li>';
2510: }
2511:
2512: break;
2513: }
2514: }
2515: return apply_filters( 'epl_get_additional_features_html', $return );
2516: }
2517:
2518: /**
2519: * Get Additional Rural Features by meta key
2520: *
2521: * @since 2.0
2522: * @param string $metakey Meta key name.
2523: * @return mixed Value formatted and wrapped in div with title
2524: */
2525: public function get_additional_rural_features_html( $metakey ) {
2526: $metavalue = $this->get_property_meta( $metakey );
2527: if ( isset( $metavalue ) && ! empty( $metavalue ) ) {
2528: $return = '<div class="' . $this->get_class_from_metakey( $metakey, $search = 'property_rural_' ) . '">
2529: <h6>' . $this->get_label_from_metakey( $metakey, 'property_rural_' ) . '</h6>' .
2530: '<p>' . $metavalue . '</p>' .
2531: '</div>';
2532: return apply_filters( 'epl_get_additional_rural_features_html', $return );
2533: }
2534: }
2535:
2536: /**
2537: * Get Additional Commercial Features by meta key
2538: *
2539: * @since 2.0.0
2540: * @since 3.4.27
2541: * @param string $metakey Meta key name.
2542: * @return mixed Value formatted and wrapped in div with title
2543: */
2544: public function get_additional_commercial_features_html( $metakey ) {
2545: $metavalue = $this->get_property_meta( $metakey );
2546: if ( isset( $metavalue ) && ! empty( $metavalue ) ) {
2547: $return = '<div class="' . $this->get_class_from_metakey( $metakey, $search = 'property_com_' ) . '">
2548: <h6>' . $this->get_label_from_metakey( $metakey, 'property_com_' ) . '</h6>' .
2549: '<p>' . $metavalue . '</p>' .
2550: '</div>';
2551: return apply_filters( 'epl_get_additional_commercial_features_html', $return );
2552: }
2553: }
2554:
2555: /**
2556: * Get Additional Commercial Features by meta key.
2557: *
2558: * Spelling error in this function. Retained to prevent issues.
2559: *
2560: * @since 2.0.0
2561: * @param string $metakey Meta key name.
2562: * @return mixed Value formatted and wrapped in div with title
2563: */
2564: public function get_additional_commerical_features_html( $metakey ) {
2565: $metavalue = $this->get_property_meta( $metakey );
2566: if ( isset( $metavalue ) && ! empty( $metavalue ) ) {
2567: $return = '<div class="' . $this->get_class_from_metakey( $metakey, $search = 'property_com_' ) . '">
2568: <h6>' . $this->get_label_from_metakey( $metakey, 'property_com_' ) . '</h6>' .
2569: '<p>' . $metavalue . '</p>' .
2570: '</div>';
2571: return apply_filters( 'epl_get_additional_commerical_features_html', $return );
2572: }
2573: }
2574:
2575: /**
2576: * Get class name from meta key
2577: *
2578: * @since 2.0
2579: * @param string $key Meta key.
2580: * @param string $search Meta key prefix to search for and remove from class, property_ is default.
2581: * @return string Formatted class name
2582: */
2583: public function get_class_from_metakey( $key, $search = 'property_' ) {
2584: return str_replace( 'property_', '', $key );
2585: }
2586:
2587: /**
2588: * Get Label from meta key
2589: *
2590: * @since 2.0
2591: * @param string $key Meta key.
2592: * @param string $search Meta key prefix to search for and remove from class, property_ is default.
2593: * @return string Formatted uppercase words
2594: * @depricated since 3.2
2595: */
2596: public function get_label_from_metakey( $key, $search = 'property_' ) {
2597: return epl_get_meta_field_label( $key );
2598: }
2599:
2600: /**
2601: * Get features from taxonomy
2602: *
2603: * @since 2.0
2604: * @return mixed Formatted list items
2605: */
2606: public function get_features_from_taxonomy() {
2607: $property_feature_taxonomy = '';
2608: if ( taxonomy_exists( 'tax_feature' ) ) {
2609: global $post;
2610: $property_feature_taxonomy = epl_get_the_term_list( $this->post->ID, 'tax_feature' );
2611: }
2612: return apply_filters( 'epl_get_features_from_taxonomy', $property_feature_taxonomy );
2613: }
2614: }
2615: endif; // End class_exists check.
2616: