| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | function epl_get_author_meta() { |
| 24: | global $epl_author_meta_sent; |
| 25: | if ( $epl_author_meta_sent ) { |
| 26: | return; |
| 27: | } |
| 28: | |
| 29: | require_once EPL_PATH_LIB . 'templates/content/author-meta.php'; |
| 30: | $epl_author_meta_sent = true; |
| 31: | } |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | function epl_the_property_address( $post_ID = '' ) { |
| 42: | $address = epl_get_property_address( $post_ID ); |
| 43: | $address = apply_filters( 'epl_the_property_address_filter', $address ); |
| 44: | echo esc_attr( $address ); |
| 45: | } |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | function epl_get_property_address( $post_ID = '' ) { |
| 57: | if ( empty( $post_ID ) ) { |
| 58: | $post_ID = get_the_ID(); |
| 59: | } |
| 60: | $property_meta = (array) epl_get_property_meta( $post_ID ); |
| 61: | $post = get_post( $post_ID ); |
| 62: | $hidden = array(); |
| 63: | |
| 64: | if ( $post ) { |
| 65: | $listing = new EPL_Property_Meta( $post ); |
| 66: | |
| 67: | if ( ! $listing->show_street_address() ) { |
| 68: | $hidden[] = 'property_address_street_number'; |
| 69: | $hidden[] = 'property_address_street'; |
| 70: | } |
| 71: | |
| 72: | if ( ! $listing->show_suburb() ) { |
| 73: | $hidden[] = 'property_address_suburb'; |
| 74: | } |
| 75: | } |
| 76: | |
| 77: | $property_meta = array_diff_key( $property_meta, array_flip( $hidden ) ); |
| 78: | |
| 79: | $address = ''; |
| 80: | |
| 81: | if ( isset( $property_meta['property_address_street_number'] ) && ! empty( $property_meta['property_address_street_number'] ) ) { |
| 82: | $property_address_street_number = $property_meta['property_address_street_number'][0]; |
| 83: | if ( ! empty( $property_address_street_number ) ) { |
| 84: | $address .= $property_address_street_number . ', '; |
| 85: | } |
| 86: | } |
| 87: | |
| 88: | if ( isset( $property_meta['property_address_street'] ) && ! empty( $property_meta['property_address_street'] ) ) { |
| 89: | $property_address_street = $property_meta['property_address_street'][0]; |
| 90: | if ( ! empty( $property_address_street ) ) { |
| 91: | $address .= $property_address_street . ', '; |
| 92: | } |
| 93: | } |
| 94: | |
| 95: | if ( isset( $property_meta['property_address_suburb'] ) && ! empty( $property_meta['property_address_suburb'] ) ) { |
| 96: | $property_address_suburb = $property_meta['property_address_suburb'][0]; |
| 97: | if ( ! empty( $property_address_suburb ) ) { |
| 98: | $address .= $property_address_suburb . ', '; |
| 99: | } |
| 100: | } |
| 101: | |
| 102: | if ( isset( $property_meta['property_address_state'] ) && ! empty( $property_meta['property_address_state'] ) ) { |
| 103: | $property_address_state = $property_meta['property_address_state'][0]; |
| 104: | if ( ! empty( $property_address_state ) ) { |
| 105: | $address .= $property_address_state . ', '; |
| 106: | } |
| 107: | } |
| 108: | |
| 109: | if ( isset( $property_meta['property_address_postal_code'] ) && ! empty( $property_meta['property_address_postal_code'] ) ) { |
| 110: | $property_address_postal_code = $property_meta['property_address_postal_code'][0]; |
| 111: | if ( ! empty( $property_address_postal_code ) ) { |
| 112: | $address .= $property_address_postal_code . ', '; |
| 113: | } |
| 114: | } |
| 115: | |
| 116: | $address = trim( $address ); |
| 117: | $address = trim( $address, ',' ); |
| 118: | $address = trim( $address ); |
| 119: | return apply_filters( 'epl_get_property_address_filter', $address ); |
| 120: | } |
| 121: | |
| 122: | |
| 123: | |
| 124: | |
| 125: | |
| 126: | |
| 127: | |
| 128: | function epl_display_label_postcode() { |
| 129: | $epl_display_label_postcode = ''; |
| 130: | |
| 131: | global $epl_settings; |
| 132: | if ( ! empty( $epl_settings ) && isset( $epl_settings['label_postcode'] ) ) { |
| 133: | $epl_display_label_postcode = $epl_settings['label_postcode']; |
| 134: | } |
| 135: | return apply_filters( 'epl_display_label_postcode', $epl_display_label_postcode ); |
| 136: | } |
| 137: | |
| 138: | |
| 139: | |
| 140: | |
| 141: | |
| 142: | |
| 143: | |
| 144: | function epl_display_label_bond() { |
| 145: | $epl_display_label_bond = ''; |
| 146: | |
| 147: | global $epl_settings; |
| 148: | if ( ! empty( $epl_settings ) && isset( $epl_settings['label_bond'] ) ) { |
| 149: | $epl_display_label_bond = $epl_settings['label_bond']; |
| 150: | } |
| 151: | return apply_filters( 'epl_display_label_bond', $epl_display_label_bond ); |
| 152: | } |
| 153: | |
| 154: | |
| 155: | |
| 156: | |
| 157: | |
| 158: | |
| 159: | |
| 160: | function epl_display_label_suburb() { |
| 161: | $epl_display_label_suburb = ''; |
| 162: | |
| 163: | global $epl_settings; |
| 164: | if ( ! empty( $epl_settings ) && isset( $epl_settings['label_suburb'] ) ) { |
| 165: | $epl_display_label_suburb = $epl_settings['label_suburb']; |
| 166: | } |
| 167: | return apply_filters( 'epl_display_label_suburb', $epl_display_label_suburb ); |
| 168: | } |
| 169: | |
| 170: | |
| 171: | if ( ! is_admin() ) { |
| 172: | return; |
| 173: | } |
| 174: | |
| 175: | |
| 176: | |
| 177: | |
| 178: | |
| 179: | |
| 180: | |
| 181: | function epl_property_blog_default() { |
| 182: | |
| 183: | global $property, $epl_settings; |
| 184: | $property_status = $property->get_property_meta( 'property_status' ); |
| 185: | |
| 186: | |
| 187: | if ( ! in_array( $property_status, array( 'withdrawn', 'offmarket' ), true ) ) { |
| 188: | |
| 189: | $option = ''; |
| 190: | if ( ! empty( $epl_settings ) && isset( $epl_settings['epl_property_card_style'] ) ) { |
| 191: | $option = $epl_settings['epl_property_card_style']; |
| 192: | } |
| 193: | |
| 194: | $action_check = has_action( 'epl_loop_template' ); |
| 195: | if ( ! empty( $action_check ) && 0 !== $option ) { |
| 196: | do_action( 'epl_loop_template' ); |
| 197: | } else { |
| 198: | epl_get_template_part( 'loop-listing-blog-default.php' ); |
| 199: | } |
| 200: | } |
| 201: | } |
| 202: | |
| 203: | |
| 204: | |
| 205: | |
| 206: | |
| 207: | |
| 208: | |
| 209: | function epl_property_blog_slim() { |
| 210: | global $property, $epl_settings; |
| 211: | if ( is_null( $property ) ) { |
| 212: | return; |
| 213: | } |
| 214: | $property_status = $property->get_property_meta( 'property_status' ); |
| 215: | |
| 216: | if ( ! in_array( $property_status, array( 'withdrawn', 'offmarket' ), true ) ) { |
| 217: | |
| 218: | $option = ''; |
| 219: | if ( ! empty( $epl_settings ) && isset( $epl_settings['epl_property_card_style'] ) ) { |
| 220: | $option = $epl_settings['epl_property_card_style']; |
| 221: | } |
| 222: | |
| 223: | $action_check = has_action( 'epl_loop_template' ); |
| 224: | if ( ! empty( $action_check ) && 0 !== $option ) { |
| 225: | do_action( 'epl_loop_template' ); |
| 226: | } else { |
| 227: | epl_get_template_part( 'loop-listing-blog-slim.php' ); |
| 228: | } |
| 229: | } |
| 230: | } |
| 231: | |
| 232: | |
| 233: | |
| 234: | |
| 235: | |
| 236: | |
| 237: | function epl_property_blog_table() { |
| 238: | global $property, $epl_settings; |
| 239: | if ( is_null( $property ) ) { |
| 240: | return; |
| 241: | } |
| 242: | $property_status = $property->get_property_meta( 'property_status' ); |
| 243: | |
| 244: | if ( ! in_array( $property_status, array( 'withdrawn', 'offmarket' ), true ) ) { |
| 245: | |
| 246: | $option = ''; |
| 247: | if ( ! empty( $epl_settings ) && isset( $epl_settings['epl_property_card_style'] ) ) { |
| 248: | $option = $epl_settings['epl_property_card_style']; |
| 249: | } |
| 250: | |
| 251: | $action_check = has_action( 'epl_loop_template' ); |
| 252: | if ( ! empty( $action_check ) && 0 !== $option ) { |
| 253: | do_action( 'epl_loop_template' ); |
| 254: | } else { |
| 255: | epl_get_template_part( 'loop-listing-blog-table.php' ); |
| 256: | } |
| 257: | } |
| 258: | } |
| 259: | |
| 260: | |
| 261: | |
| 262: | |
| 263: | |
| 264: | |
| 265: | |
| 266: | |
| 267: | function epl_property_blog_table_open() { |
| 268: | global $property, $epl_settings; |
| 269: | if ( is_null( $property ) ) { |
| 270: | return; |
| 271: | } |
| 272: | $property_status = $property->get_property_meta( 'property_status' ); |
| 273: | |
| 274: | if ( ! in_array( $property_status, array( 'withdrawn', 'offmarket' ), true ) ) { |
| 275: | |
| 276: | $option = ''; |
| 277: | if ( ! empty( $epl_settings ) && isset( $epl_settings['epl_property_card_style'] ) ) { |
| 278: | $option = $epl_settings['epl_property_card_style']; |
| 279: | } |
| 280: | |
| 281: | $action_check = has_action( 'epl_loop_template' ); |
| 282: | if ( ! empty( $action_check ) && 0 !== $option ) { |
| 283: | do_action( 'epl_loop_template' ); |
| 284: | } else { |
| 285: | epl_get_template_part( 'loop-listing-blog-table-open.php' ); |
| 286: | } |
| 287: | } |
| 288: | } |
| 289: | |
| 290: | |
| 291: | |
| 292: | |
| 293: | |
| 294: | |
| 295: | |
| 296: | |
| 297: | function epl_property_sold_leased() { |
| 298: | $property_suburb = get_post_custom_values( 'property_address_suburb' ); |
| 299: | $post_id = $property_suburb[0]['ID']; |
| 300: | $post = get_post( $post_id ); |
| 301: | $terms = get_the_terms( $post->ID, 'location' ); |
| 302: | if ( ! empty( $terms ) ) { |
| 303: | global $post; |
| 304: | foreach ( $terms as $term ) { |
| 305: | $term->slug; |
| 306: | } |
| 307: | } |
| 308: | |
| 309: | $post_type = get_post_type(); |
| 310: | |
| 311: | if ( 'property' === $post_type ) { |
| 312: | $query = new WP_Query( |
| 313: | array( |
| 314: | 'post_type' => 'property', |
| 315: | 'location' => $term->slug, |
| 316: | 'meta_query' => array( |
| 317: | array( |
| 318: | 'key' => 'property_status', |
| 319: | 'value' => 'sold', |
| 320: | ), |
| 321: | ), |
| 322: | 'posts_per_page' => '5', |
| 323: | ) |
| 324: | ); |
| 325: | } elseif ( 'land' === $post_type ) { |
| 326: | $query = new WP_Query( |
| 327: | array( |
| 328: | 'post_type' => 'land', |
| 329: | 'meta_query' => array( |
| 330: | array( |
| 331: | 'key' => 'property_status', |
| 332: | 'value' => 'sold', |
| 333: | ), |
| 334: | ), |
| 335: | 'property_status' => 'sold', |
| 336: | 'posts_per_page' => '5', |
| 337: | ) |
| 338: | ); |
| 339: | } elseif ( 'rural' === $post_type ) { |
| 340: | $query = new WP_Query( |
| 341: | array( |
| 342: | 'post_type' => 'rural', |
| 343: | 'location' => $term->slug, |
| 344: | 'meta_query' => array( |
| 345: | array( |
| 346: | 'key' => 'property_status', |
| 347: | 'value' => 'sold', |
| 348: | ), |
| 349: | ), |
| 350: | 'posts_per_page' => '5', |
| 351: | ) |
| 352: | ); |
| 353: | } else { |
| 354: | $query = new WP_Query( |
| 355: | array( |
| 356: | 'post_type' => 'rental', |
| 357: | 'location' => $term->slug, |
| 358: | 'meta_query' => array( |
| 359: | array( |
| 360: | 'key' => 'property_status', |
| 361: | 'value' => 'leased', |
| 362: | ), |
| 363: | ), |
| 364: | 'posts_per_page' => '5', |
| 365: | ) |
| 366: | ); |
| 367: | } |
| 368: | |
| 369: | if ( $query->have_posts() ) { ?> |
| 370: | <div class="epl-tab-section epl-tab-section-listing-history"> |
| 371: | <?php if ( 'property' === $post_type || 'land' === $post_type || 'rural' === $post_type ) { ?> |
| 372: | <h5 class="epl-tab-title epl-tab-title-sales tab-title"><?php esc_html_e( 'Recently Sold', 'easy-property-listings' ); ?></h5> |
| 373: | <?php } else { ?> |
| 374: | <h5 class="epl-tab-title epl-tab-title-leased tab-title"><?php esc_html_e( 'Recently Leased', 'easy-property-listings' ); ?></h5> |
| 375: | <?php } ?> |
| 376: | <div class="tab-content"> |
| 377: | <ul> |
| 378: | <?php |
| 379: | while ( $query->have_posts() ) { |
| 380: | $query->the_post(); |
| 381: | ?> |
| 382: | |
| 383: | <!-- Suburb Tab --> |
| 384: | <li> |
| 385: | <a href="<?php the_permalink(); ?>"> |
| 386: | <?php the_title(); ?> |
| 387: | <?php echo esc_attr( $suburb[0] ); ?> |
| 388: | </a> |
| 389: | </li> |
| 390: | <?php |
| 391: | } |
| 392: | ?> |
| 393: | </ul> |
| 394: | </div> |
| 395: | </div> |
| 396: | <?php |
| 397: | } |
| 398: | wp_reset_postdata(); |
| 399: | } |
| 400: | |
| 401: | |
| 402: | |
| 403: | |
| 404: | |
| 405: | |
| 406: | |
| 407: | |
| 408: | |
| 409: | |
| 410: | |
| 411: | |
| 412: | function epl_property_author_card( $display, $image, $title, $icons ) { |
| 413: | global $property, $epl_author; |
| 414: | if ( is_null( $epl_author ) ) { |
| 415: | return; |
| 416: | } |
| 417: | $property_status = $property->get_property_meta( 'property_status' ); |
| 418: | |
| 419: | if ( ! in_array( $property_status, array( 'withdrawn', 'offmarket' ), true ) ) { |
| 420: | |
| 421: | |
| 422: | ?> |
| 423: | <div id="post-<?php the_ID(); ?>" style="width: 20%;margin-right: 1em;float: left;" class="epl-widget property-widget-image hentry"> |
| 424: | <div class="entry-header"> |
| 425: | <?php if ( has_post_thumbnail() ) : ?> |
| 426: | <div class="epl-img-widget"> |
| 427: | <a href="<?php the_permalink(); ?>"> |
| 428: | <?php the_post_thumbnail( $image ); ?> |
| 429: | </a> |
| 430: | </div> |
| 431: | <?php endif; ?> |
| 432: | </div> |
| 433: | |
| 434: | <div class="entry-content"> |
| 435: | <?php |
| 436: | |
| 437: | if ( 'on' === $title ) { |
| 438: | ?> |
| 439: | <h5 class="property-meta heading"><?php echo wp_kses( $the_property_heading ); ?></h5> |
| 440: | <?php |
| 441: | } |
| 442: | ?> |
| 443: | |
| 444: | <!-- Address --> |
| 445: | <div class="property-address"> |
| 446: | <?php do_action( 'epl_property_address' ); ?> |
| 447: | </div> |
| 448: | <!-- END Address --> |
| 449: | |
| 450: | <?php |
| 451: | |
| 452: | if ( 'all' === $icons ) { |
| 453: | ?> |
| 454: | <div class="property-meta property-feature-icons"><?php epl_property_icons(); ?></div> |
| 455: | <?php } elseif ( 'bb' === $icons ) { ?> |
| 456: | <div class="property-meta property-feature-icons"><?php echo wp_kses( epl_get_property_bb_icons(), array_merge( wp_kses_allowed_html( 'post' ), epl_get_svg_allowed_tags() ) ); ?></div> |
| 457: | <?php } ?> |
| 458: | |
| 459: | <div class="property-meta price"><?php epl_property_price(); ?></div> |
| 460: | <form class="epl-property-button" action="<?php the_permalink(); ?>" method="post"> |
| 461: | <input type=submit value="<?php esc_html_e( 'Read More', 'easy-property-listings' ); ?>" /> |
| 462: | </form> |
| 463: | </div> |
| 464: | </div> |
| 465: | |
| 466: | <?php |
| 467: | } |
| 468: | } |
| 469: | |
| 470: | |
| 471: | |
| 472: | |
| 473: | |
| 474: | |
| 475: | |
| 476: | |
| 477: | |
| 478: | |
| 479: | function epl_excerpt_length( $length ) { |
| 480: | global $post; |
| 481: | if ( 'property' === $post->post_type ) { |
| 482: | return 16; |
| 483: | } elseif ( 'rental' === $post->post_type ) { |
| 484: | return 16; |
| 485: | } elseif ( 'commercial' === $post->post_type ) { |
| 486: | return 16; |
| 487: | } elseif ( 'commercial_land' === $post->post_type ) { |
| 488: | return 16; |
| 489: | } elseif ( 'business' === $post->post_type ) { |
| 490: | return 16; |
| 491: | } elseif ( 'rural' === $post->post_type ) { |
| 492: | return 16; |
| 493: | } elseif ( 'land' === $post->post_type ) { |
| 494: | return 16; |
| 495: | } elseif ( 'suburb' === $post->post_type ) { |
| 496: | return 39; |
| 497: | } else { |
| 498: | return 55; |
| 499: | } |
| 500: | } |
| 501: | |
| 502: | |
| 503: | |
| 504: | |