| 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: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | function epl_reset_property_object( $post ) { |
| 29: | |
| 30: | global $epl_author, $epl_author_secondary, $epl_author_third, $epl_author_fourth; |
| 31: | |
| 32: | if ( ! is_epl_post() ) { |
| 33: | return; |
| 34: | } |
| 35: | |
| 36: | global $property; |
| 37: | $property = new EPL_Property_Meta( $post ); |
| 38: | $ID = epl_listing_has_primary_agent(); |
| 39: | if ( $ID ) { |
| 40: | $epl_author = new EPL_Author_meta( $ID ); |
| 41: | |
| 42: | } else { |
| 43: | $epl_author = new EPL_Author_meta( $post->post_author ); |
| 44: | } |
| 45: | |
| 46: | $SEC_ID = epl_listing_has_secondary_author(); |
| 47: | |
| 48: | if ( $SEC_ID ) { |
| 49: | $epl_author_secondary = new EPL_Author_meta( $SEC_ID ); |
| 50: | } |
| 51: | |
| 52: | $third_ID = epl_listing_has_third_agent(); |
| 53: | |
| 54: | if ( $third_ID ) { |
| 55: | $epl_author_third = new EPL_Author_meta( $third_ID ); |
| 56: | } |
| 57: | |
| 58: | $fourth_ID = epl_listing_has_fourth_agent(); |
| 59: | |
| 60: | if ( $fourth_ID ) { |
| 61: | $epl_author_fourth = new EPL_Author_meta( $fourth_ID ); |
| 62: | } |
| 63: | } |
| 64: | add_action( 'the_post', 'epl_reset_property_object' ); |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | function epl_create_property_object() { |
| 73: | |
| 74: | global $post, $property, $epl_author, $epl_author_secondary, $epl_author_third, $epl_author_fourth; |
| 75: | |
| 76: | if ( is_author() ) { |
| 77: | $author_id = get_query_var( 'author' ); |
| 78: | $epl_author = new EPL_Author_meta( $author_id ); |
| 79: | } |
| 80: | if ( is_null( $post ) ) { |
| 81: | return; |
| 82: | } |
| 83: | $epl_author = new EPL_Author_meta( $post->post_author ); |
| 84: | |
| 85: | if ( is_epl_post() ) { |
| 86: | $property = new EPL_Property_Meta( $post ); |
| 87: | $ID = epl_listing_has_secondary_author(); |
| 88: | if ( $ID ) { |
| 89: | $epl_author_secondary = new EPL_Author_meta( $ID ); |
| 90: | } |
| 91: | $third_ID = epl_listing_has_third_agent(); |
| 92: | |
| 93: | if ( $third_ID ) { |
| 94: | $epl_author_third = new EPL_Author_meta( $third_ID ); |
| 95: | } |
| 96: | |
| 97: | $fourth_ID = epl_listing_has_fourth_agent(); |
| 98: | |
| 99: | if ( $fourth_ID ) { |
| 100: | $epl_author_fourth = new EPL_Author_meta( $fourth_ID ); |
| 101: | } |
| 102: | } |
| 103: | |
| 104: | add_filter( 'excerpt_length', 'epl_archive_custom_excerpt_length', 999 ); |
| 105: | } |
| 106: | |
| 107: | add_action( 'wp', 'epl_create_property_object' ); |
| 108: | |
| 109: | |
| 110: | |
| 111: | |
| 112: | |
| 113: | |
| 114: | |
| 115: | function epl_property_single() { |
| 116: | global $epl_settings; |
| 117: | |
| 118: | $action_check = has_action( 'epl_single_template' ); |
| 119: | if ( ! empty( $action_check ) ) { |
| 120: | do_action( 'epl_single_template' ); |
| 121: | } else { |
| 122: | epl_property_single_default(); |
| 123: | } |
| 124: | } |
| 125: | add_action( 'epl_property_single', 'epl_property_single', 10, 1 ); |
| 126: | |
| 127: | |
| 128: | |
| 129: | |
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | |
| 135: | |
| 136: | |
| 137: | |
| 138: | |
| 139: | function epl_property_featured_image( $image_size = 'index_thumbnail', $image_class = 'index-thumbnail', $link = true ) { |
| 140: | |
| 141: | $args = apply_filters( |
| 142: | 'epl_property_featured_image_args', |
| 143: | array( |
| 144: | 'image_size' => $image_size, |
| 145: | 'image_class' => $image_class, |
| 146: | 'link' => $link, |
| 147: | ) |
| 148: | ); |
| 149: | |
| 150: | |
| 151: | |
| 152: | $args['link'] = apply_filters( 'epl_property_featured_image_link', $args['link'] ); |
| 153: | |
| 154: | if ( has_post_thumbnail() ) { ?> |
| 155: | <div class="entry-image"> |
| 156: | <div class="epl-featured-image it-featured-image"> |
| 157: | <?php if ( true === $args['link'] ) { ?> |
| 158: | <a href="<?php the_permalink(); ?>"> |
| 159: | <?php } ?> |
| 160: | <?php the_post_thumbnail( $args['image_size'], array( 'class' => $args['image_class'] ) ); ?> |
| 161: | <?php if ( true === $args['link'] ) { ?> |
| 162: | </a> |
| 163: | <?php } ?> |
| 164: | </div> |
| 165: | </div> |
| 166: | <?php |
| 167: | } else { |
| 168: | do_action( 'epl_no_property_featured_image', $args ); |
| 169: | } |
| 170: | } |
| 171: | add_action( 'epl_property_featured_image', 'epl_property_featured_image', 10, 3 ); |
| 172: | add_action( 'epl_single_featured_image', 'epl_property_featured_image', 10, 3 ); |
| 173: | |
| 174: | |
| 175: | |
| 176: | |
| 177: | |
| 178: | |
| 179: | |
| 180: | |
| 181: | |
| 182: | |
| 183: | |
| 184: | |
| 185: | |
| 186: | |
| 187: | |
| 188: | function epl_property_archive_featured_image( $image_size = 'epl-image-medium-crop', $image_class = 'teaser-left-thumb', $link = true, $stickers = true ) { |
| 189: | |
| 190: | if ( empty( $image_size ) ) { |
| 191: | $image_size = 'epl-image-medium-crop'; |
| 192: | } |
| 193: | |
| 194: | $args = apply_filters( |
| 195: | 'epl_property_archive_featured_image_args', |
| 196: | array( |
| 197: | 'image_size' => $image_size, |
| 198: | 'image_class' => $image_class, |
| 199: | 'link' => $link, |
| 200: | 'stickers' => $stickers, |
| 201: | ) |
| 202: | ); |
| 203: | |
| 204: | |
| 205: | |
| 206: | $args['link'] = apply_filters( 'epl_property_archive_featured_image_link', $args['link'] ); |
| 207: | |
| 208: | if ( has_post_thumbnail() ) { |
| 209: | ?> |
| 210: | <div class="epl-archive-entry-image"> |
| 211: | <?php if ( true === $args['link'] ) { ?> |
| 212: | <a href="<?php the_permalink(); ?>"> |
| 213: | <?php } ?> |
| 214: | <div class="epl-blog-image"> |
| 215: | <?php do_action( 'epl_stickers_featured_image', $args ); ?> |
| 216: | <?php the_post_thumbnail( $args['image_size'], array( 'class' => $args['image_class'] ) ); ?> |
| 217: | </div> |
| 218: | <?php if ( true === $args['link'] ) { ?> |
| 219: | </a> |
| 220: | <?php } ?> |
| 221: | </div> |
| 222: | <?php |
| 223: | } else { |
| 224: | do_action( 'epl_no_archive_featured_image', $args ); |
| 225: | } |
| 226: | } |
| 227: | add_action( 'epl_property_archive_featured_image', 'epl_property_archive_featured_image', 10, 4 ); |
| 228: | |
| 229: | |
| 230: | |
| 231: | |
| 232: | |
| 233: | |
| 234: | |
| 235: | |
| 236: | function epl_stickers_featured_image( $args ) { |
| 237: | if ( $args['stickers'] ) : |
| 238: | ?> |
| 239: | <div class="epl-stickers-wrapper"> |
| 240: | <?php echo wp_kses_post( epl_get_price_sticker() ); ?> |
| 241: | </div> |
| 242: | <?php |
| 243: | endif; |
| 244: | } |
| 245: | add_action( 'epl_stickers_featured_image', 'epl_stickers_featured_image' ); |
| 246: | |
| 247: | |
| 248: | |
| 249: | |
| 250: | |
| 251: | |
| 252: | |
| 253: | |
| 254: | |
| 255: | |
| 256: | function epl_property_widgets_featured_image( $image_size = 'epl-image-medium-crop', $image_class = 'teaser-left-thumb', $link = true ) { |
| 257: | |
| 258: | if ( has_post_thumbnail() ) { |
| 259: | ?> |
| 260: | <div class="epl-archive-entry-image"> |
| 261: | <?php if ( $link ) { ?> |
| 262: | <a href="<?php the_permalink(); ?>"> |
| 263: | <?php } ?> |
| 264: | <div class="epl-blog-image"> |
| 265: | <?php the_post_thumbnail( $image_size, array( 'class' => $image_class ) ); ?> |
| 266: | </div> |
| 267: | <?php if ( $link ) { ?> |
| 268: | </a> |
| 269: | <?php } ?> |
| 270: | </div> |
| 271: | <?php |
| 272: | } |
| 273: | } |
| 274: | add_action( 'epl_property_widgets_featured_image', 'epl_property_widgets_featured_image', 10, 3 ); |
| 275: | |
| 276: | |
| 277: | |
| 278: | |
| 279: | |
| 280: | |
| 281: | function epl_property_single_default() { |
| 282: | |
| 283: | global $epl_settings; |
| 284: | if ( isset( $epl_settings['epl_feeling_lucky'] ) && 'on' === $epl_settings['epl_feeling_lucky'] ) { |
| 285: | epl_get_template_part( 'content-listing-single-compatibility.php' ); |
| 286: | } else { |
| 287: | $single_tpl = 'content-listing-single.php'; |
| 288: | $single_tpl = apply_filters( 'epl_property_single_default', $single_tpl ); |
| 289: | epl_get_template_part( $single_tpl ); |
| 290: | } |
| 291: | } |
| 292: | |
| 293: | |
| 294: | |
| 295: | |
| 296: | |
| 297: | |
| 298: | |
| 299: | |
| 300: | function epl_get_content_path() { |
| 301: | return apply_filters( 'epl_templates_base_path', EPL_PATH_TEMPLATES_CONTENT ); |
| 302: | } |
| 303: | |
| 304: | |
| 305: | |
| 306: | |
| 307: | |
| 308: | |
| 309: | |
| 310: | function epl_get_fallback_content_path() { |
| 311: | return apply_filters( 'epl_templates_fallback_base_path', EPL_PATH_TEMPLATES_CONTENT ); |
| 312: | } |
| 313: | |
| 314: | |
| 315: | |
| 316: | |
| 317: | |
| 318: | |
| 319: | |
| 320: | |
| 321: | |
| 322: | |
| 323: | |
| 324: | |
| 325: | |
| 326: | |
| 327: | |
| 328: | function epl_get_template_part( $template, $arguments = array(), $default_template = false ) { |
| 329: | |
| 330: | |
| 331: | if ( 0 !== validate_file( (string) $template ) || ( $default_template && 0 !== validate_file( (string) $default_template ) ) ) { |
| 332: | return; |
| 333: | } |
| 334: | |
| 335: | $original_template = $template; |
| 336: | $base_path = epl_get_content_path(); |
| 337: | $default = $default_template ? $default_template : $template; |
| 338: | $find[] = epl_template_path() . $template; |
| 339: | $find = apply_filters( 'epl_template_part_find', $find, $template, $arguments, $default_template ); |
| 340: | $template_location = locate_template( array_unique( $find ) ); |
| 341: | |
| 342: | if ( ! $template_location ) { |
| 343: | $template = $base_path . $template; |
| 344: | $original_template = $template; |
| 345: | if ( ! file_exists( $template ) ) { |
| 346: | |
| 347: | $base_path = epl_get_fallback_content_path(); |
| 348: | $template = $base_path . $default; |
| 349: | } |
| 350: | } else { |
| 351: | $template = $template_location; |
| 352: | } |
| 353: | |
| 354: | if ( ! isset( $arguments['epl_author'] ) ) { |
| 355: | global $epl_author; |
| 356: | } |
| 357: | |
| 358: | foreach ( $arguments as $key => $val ) { |
| 359: | ${$key} = $val; |
| 360: | } |
| 361: | |
| 362: | include apply_filters( 'epl_get_template_part', $template, $arguments, $default_template, $original_template ); |
| 363: | } |
| 364: | |
| 365: | |
| 366: | |
| 367: | |
| 368: | |
| 369: | |
| 370: | |
| 371: | |
| 372: | |
| 373: | function epl_archive_custom_excerpt_length( $length ) { |
| 374: | |
| 375: | if ( ! is_epl_post() ) { |
| 376: | return $length; |
| 377: | } |
| 378: | |
| 379: | return epl_get_option( 'display_excerpt_length', 22 ); |
| 380: | } |
| 381: | |
| 382: | |
| 383: | |
| 384: | |
| 385: | |
| 386: | |
| 387: | |
| 388: | |
| 389: | |
| 390: | function epl_hide_listing_statuses() { |
| 391: | return apply_filters( 'epl_hide_listing_statuses', array( 'withdrawn', 'offmarket', 'deleted' ) ); |
| 392: | } |
| 393: | |
| 394: | |
| 395: | |
| 396: | |
| 397: | |
| 398: | |
| 399: | |
| 400: | |
| 401: | |
| 402: | |
| 403: | |
| 404: | |
| 405: | |
| 406: | |
| 407: | |
| 408: | function epl_is_front_end_listing_query( $query ) { |
| 409: | $is = false; |
| 410: | |
| 411: | if ( ! is_admin() && ! $query->is_singular() ) { |
| 412: | |
| 413: | $is = (bool) $query->get( 'is_epl_shortcode' ) || (bool) $query->get( 'is_epl_widget' ) || (bool) $query->get( 'epl_elementor_loop' ); |
| 414: | |
| 415: | if ( ! $is && $query->is_main_query() ) { |
| 416: | $is = is_post_type_archive( epl_all_post_types() ) || is_tax( array( 'location', 'tax_feature', 'tax_business_listing' ) ) || epl_is_search(); |
| 417: | } |
| 418: | } |
| 419: | |
| 420: | |
| 421: | |
| 422: | |
| 423: | |
| 424: | |
| 425: | |
| 426: | |
| 427: | |
| 428: | return (bool) apply_filters( 'epl_is_front_end_listing_query', $is, $query ); |
| 429: | } |
| 430: | |
| 431: | |
| 432: | |
| 433: | |
| 434: | |
| 435: | |
| 436: | |
| 437: | |
| 438: | |
| 439: | |
| 440: | |
| 441: | |
| 442: | |
| 443: | |
| 444: | |
| 445: | function epl_exclude_hidden_listing_statuses( $query ) { |
| 446: | if ( ! epl_is_front_end_listing_query( $query ) ) { |
| 447: | return; |
| 448: | } |
| 449: | |
| 450: | $hidden_ids = epl_get_hidden_listing_ids(); |
| 451: | if ( empty( $hidden_ids ) ) { |
| 452: | return; |
| 453: | } |
| 454: | |
| 455: | $not_in = $query->get( 'post__not_in' ); |
| 456: | $not_in = is_array( $not_in ) ? $not_in : array(); |
| 457: | |
| 458: | $query->set( 'post__not_in', array_values( array_unique( array_merge( array_map( 'absint', $not_in ), $hidden_ids ) ) ) ); |
| 459: | } |
| 460: | add_action( 'pre_get_posts', 'epl_exclude_hidden_listing_statuses', 20 ); |
| 461: | |
| 462: | |
| 463: | |
| 464: | |
| 465: | |
| 466: | |
| 467: | |
| 468: | |
| 469: | |
| 470: | |
| 471: | |
| 472: | |
| 473: | function epl_get_hidden_listing_ids() { |
| 474: | global $wpdb; |
| 475: | |
| 476: | $hidden = array_values( array_filter( array_map( 'strval', (array) epl_hide_listing_statuses() ) ) ); |
| 477: | if ( empty( $hidden ) ) { |
| 478: | return array(); |
| 479: | } |
| 480: | |
| 481: | $placeholders = implode( ', ', array_fill( 0, count( $hidden ), '%s' ) ); |
| 482: | $sql = $wpdb->prepare( "SELECT DISTINCT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'property_status' AND meta_value IN ( $placeholders )", $hidden ); |
| 483: | |
| 484: | return array_map( 'absint', epl_listing_query_cache( $sql ) ); |
| 485: | } |
| 486: | |
| 487: | |
| 488: | |
| 489: | |
| 490: | |
| 491: | |
| 492: | |
| 493: | |
| 494: | |
| 495: | |
| 496: | |
| 497: | |
| 498: | |
| 499: | |
| 500: | |
| 501: | |
| 502: | |
| 503: | function epl_property_blog( $template = '', $default_value = 'default' ) { |
| 504: | |
| 505: | if ( empty( $template ) || 'blog' === $template ) { |
| 506: | $template = 'default'; |
| 507: | } |
| 508: | $template = str_replace( '_', '-', $template ); |
| 509: | |
| 510: | global $epl_settings, $property; |
| 511: | |
| 512: | if ( is_null( $property ) ) { |
| 513: | return; |
| 514: | } |
| 515: | |
| 516: | $property_status = $property->get_property_meta( 'property_status' ); |
| 517: | |
| 518: | if ( ! in_array( $property_status, epl_hide_listing_statuses(), true ) ) { |
| 519: | |
| 520: | |
| 521: | $action_check_type = has_action( 'epl_loop_template_' . $property->post->post_type ); |
| 522: | $action_check = has_action( 'epl_loop_template' ); |
| 523: | $action_check_core = false; |
| 524: | $action_exists = false; |
| 525: | |
| 526: | if ( in_array( $property->post->post_type, epl_get_core_post_types(), true ) ) { |
| 527: | $action_check_core = has_action( 'epl_loop_template_listing' ); |
| 528: | } |
| 529: | |
| 530: | |
| 531: | if ( ! empty( $action_check_type ) ) { |
| 532: | do_action( 'epl_loop_template_' . $property->post->post_type, get_defined_vars() ); |
| 533: | $action_exists = true; |
| 534: | } elseif ( ! empty( $action_check_core ) ) { |
| 535: | do_action( 'epl_loop_template_listing', get_defined_vars() ); |
| 536: | $action_exists = true; |
| 537: | } elseif ( ! empty( $action_check ) ) { |
| 538: | do_action( 'epl_loop_template', get_defined_vars() ); |
| 539: | $action_exists = true; |
| 540: | } |
| 541: | |
| 542: | |
| 543: | if ( ! $action_exists ) { |
| 544: | $tpl_name = 'loop-listing-blog-' . $template . '.php'; |
| 545: | $tpl_name = apply_filters( 'epl_property_blog_template', $tpl_name, get_defined_vars() ); |
| 546: | epl_get_template_part( $tpl_name, array(), 'loop-listing-blog-' . $default_value . '.php' ); |
| 547: | } |
| 548: | } |
| 549: | } |
| 550: | add_action( 'epl_property_blog', 'epl_property_blog', 10, 2 ); |
| 551: | |
| 552: | |
| 553: | |
| 554: | |
| 555: | |
| 556: | |
| 557: | |
| 558: | function epl_property_author_default() { |
| 559: | global $epl_author_secondary, $epl_author_third, $epl_author_fourth; |
| 560: | epl_get_template_part( 'content-author-box.php' ); |
| 561: | if ( is_epl_post() ) { |
| 562: | if ( epl_listing_has_secondary_author() ) { |
| 563: | epl_get_template_part( 'content-author-box.php', array( 'epl_author' => $epl_author_secondary ) ); |
| 564: | } |
| 565: | if ( epl_listing_has_third_agent() ) { |
| 566: | epl_get_template_part( 'content-author-box.php', array( 'epl_author' => $epl_author_third ) ); |
| 567: | } |
| 568: | if ( epl_listing_has_fourth_agent() ) { |
| 569: | epl_get_template_part( 'content-author-box.php', array( 'epl_author' => $epl_author_fourth ) ); |
| 570: | } |
| 571: | epl_reset_post_author(); |
| 572: | } |
| 573: | } |
| 574: | |
| 575: | |
| 576: | |
| 577: | |
| 578: | |
| 579: | function epl_property_author_box() { |
| 580: | |
| 581: | if ( has_action( 'epl_author_template' ) ) { |
| 582: | do_action( 'epl_author_template' ); |
| 583: | } else { |
| 584: | epl_property_author_default(); |
| 585: | } |
| 586: | } |
| 587: | add_action( 'epl_single_author', 'epl_property_author_box', 10 ); |
| 588: | |
| 589: | |
| 590: | |
| 591: | |
| 592: | |
| 593: | |
| 594: | function epl_reset_post_author() { |
| 595: | global $post, $epl_author; |
| 596: | if ( class_exists( 'EPL_Author_meta' ) ) { |
| 597: | |
| 598: | $ID = epl_listing_has_primary_agent(); |
| 599: | |
| 600: | if ( is_epl_post() && $ID ) { |
| 601: | $epl_author = new EPL_Author_meta( $ID ); |
| 602: | } else { |
| 603: | $epl_author = new EPL_Author_meta( $post->post_author ); |
| 604: | } |
| 605: | } |
| 606: | } |
| 607: | |
| 608: | |
| 609: | |
| 610: | |
| 611: | |
| 612: | |
| 613: | |
| 614: | function epl_property_author_box_simple_card() { |
| 615: | |
| 616: | global $epl_author_secondary, $epl_author_third, $epl_author_fourth; |
| 617: | epl_get_template_part( 'content-author-box-simple-card.php' ); |
| 618: | if ( is_epl_post() ) { |
| 619: | if ( epl_listing_has_secondary_author() ) { |
| 620: | epl_get_template_part( 'content-author-box-simple-card.php', array( 'epl_author' => $epl_author_secondary ) ); |
| 621: | } |
| 622: | if ( epl_listing_has_third_agent() ) { |
| 623: | epl_get_template_part( 'content-author-box-simple-card.php', array( 'epl_author' => $epl_author_third ) ); |
| 624: | } |
| 625: | if ( epl_listing_has_fourth_agent() ) { |
| 626: | epl_get_template_part( 'content-author-box-simple-card.php', array( 'epl_author' => $epl_author_fourth ) ); |
| 627: | } |
| 628: | epl_reset_post_author(); |
| 629: | } |
| 630: | } |
| 631: | |
| 632: | |
| 633: | |
| 634: | |
| 635: | |
| 636: | |
| 637: | |
| 638: | function epl_property_author_box_simple_grav() { |
| 639: | |
| 640: | global $epl_author_secondary, $epl_author_third, $epl_author_fourth; |
| 641: | epl_get_template_part( 'content-author-box-simple-grav.php' ); |
| 642: | if ( is_epl_post() ) { |
| 643: | if ( epl_listing_has_secondary_author() ) { |
| 644: | epl_get_template_part( 'content-author-box-simple-grav.php', array( 'epl_author' => $epl_author_secondary ) ); |
| 645: | } |
| 646: | if ( epl_listing_has_third_agent() ) { |
| 647: | epl_get_template_part( 'content-author-box-simple-grav.php', array( 'epl_author' => $epl_author_third ) ); |
| 648: | } |
| 649: | if ( epl_listing_has_fourth_agent() ) { |
| 650: | epl_get_template_part( 'content-author-box-simple-grav.php', array( 'epl_author' => $epl_author_fourth ) ); |
| 651: | } |
| 652: | epl_reset_post_author(); |
| 653: | } |
| 654: | } |
| 655: | |
| 656: | |
| 657: | |
| 658: | |
| 659: | |
| 660: | |
| 661: | |
| 662: | |
| 663: | |
| 664: | |
| 665: | |
| 666: | |
| 667: | |
| 668: | |
| 669: | |
| 670: | |
| 671: | |
| 672: | |
| 673: | |
| 674: | |
| 675: | |
| 676: | |
| 677: | function epl_property_widget( $display, $image, $title, $icons, $more_text, $d_excerpt, $d_suburb, $d_street, $d_price, $d_more, $d_inspection_time, $d_ical_link ) { |
| 678: | global $property; |
| 679: | |
| 680: | if ( is_null( $property ) ) { |
| 681: | return; |
| 682: | } |
| 683: | |
| 684: | if ( empty( $more_text ) ) { |
| 685: | $more_text = apply_filters( 'epl_property_widget_read_more', __( 'Read More', 'easy-property-listings' ) ); |
| 686: | } |
| 687: | |
| 688: | $property_status = $property->get_property_meta( 'property_status' ); |
| 689: | |
| 690: | switch ( $display ) { |
| 691: | case 'list': |
| 692: | $tpl = 'widget-content-listing-list.php'; |
| 693: | break; |
| 694: | case 'hide-image': |
| 695: | $tpl = 'widget-content-listing-hide-image.php'; |
| 696: | break; |
| 697: | case 'image-only': |
| 698: | $tpl = 'widget-content-listing-image.php'; |
| 699: | break; |
| 700: | case 'image': |
| 701: | $tpl = 'widget-content-listing.php'; |
| 702: | break; |
| 703: | default: |
| 704: | $tpl = $display; |
| 705: | if ( ! epl_starts_with( $tpl, 'widget-content-listing' ) ) { |
| 706: | $tpl = 'widget-content-listing-' . $tpl; |
| 707: | } |
| 708: | if ( ! epl_ends_with( $tpl, '.php' ) ) { |
| 709: | $tpl .= '.php'; |
| 710: | } |
| 711: | break; |
| 712: | } |
| 713: | |
| 714: | |
| 715: | if ( ! in_array( $property_status, epl_hide_listing_statuses(), true ) ) { |
| 716: | |
| 717: | $arg_list = get_defined_vars(); |
| 718: | if ( has_action( 'epl_listing_widget_template' ) ) { |
| 719: | do_action( 'epl_listing_widget_template', $tpl, $arg_list ); |
| 720: | } else { |
| 721: | epl_get_template_part( $tpl, $arg_list ); |
| 722: | } |
| 723: | } |
| 724: | } |
| 725: | |
| 726: | |
| 727: | |
| 728: | |
| 729: | |
| 730: | |
| 731: | function epl_property_widget_list_option() { |
| 732: | $property_status = get_post_meta( get_the_ID(), 'property_status', true ); |
| 733: | |
| 734: | if ( ! in_array( $property_status, epl_hide_listing_statuses(), true ) ) { |
| 735: | epl_get_template_part( 'widget-content-listing-list.php' ); |
| 736: | } |
| 737: | } |
| 738: | |
| 739: | |
| 740: | |
| 741: | |
| 742: | |
| 743: | |
| 744: | |
| 745: | |
| 746: | function epl_property_widget_image_only_option( $image ) { |
| 747: | $property_status = get_post_meta( get_the_ID(), 'property_status', true ); |
| 748: | |
| 749: | if ( ! in_array( $property_status, epl_hide_listing_statuses(), true ) ) { |
| 750: | $arg_list = get_defined_vars(); |
| 751: | } |
| 752: | epl_get_template_part( 'widget-content-listing-image.php', $arg_list ); |
| 753: | } |
| 754: | |
| 755: | |
| 756: | |
| 757: | |
| 758: | |
| 759: | |
| 760: | |
| 761: | |
| 762: | |
| 763: | |
| 764: | |
| 765: | |
| 766: | |
| 767: | function epl_property_author_box_simple_card_tall( $d_image, $d_icons, $d_bio, $username ) { |
| 768: | |
| 769: | if ( ! empty( $username ) ) { |
| 770: | epl_show_author_widget_by_username( $d_image, $d_icons, $d_bio, $username ); |
| 771: | return; |
| 772: | } |
| 773: | |
| 774: | global $property, $epl_author, $epl_author_secondary, $epl_author_third, $epl_author_fourth; |
| 775: | if ( is_null( $epl_author ) ) { |
| 776: | return; |
| 777: | } |
| 778: | |
| 779: | $arg_list = get_defined_vars(); |
| 780: | epl_get_template_part( 'widget-content-author-tall.php', $arg_list ); |
| 781: | |
| 782: | |
| 783: | if ( is_single() && ! is_null( $property ) ) { |
| 784: | |
| 785: | if ( is_epl_post() ) { |
| 786: | if ( epl_listing_has_secondary_author() ) { |
| 787: | $epl_author = $epl_author_secondary; |
| 788: | epl_get_template_part( 'widget-content-author-tall.php', $arg_list ); |
| 789: | } |
| 790: | if ( epl_listing_has_third_agent() ) { |
| 791: | $epl_author = $epl_author_third; |
| 792: | epl_get_template_part( 'widget-content-author-tall.php', $arg_list ); |
| 793: | } |
| 794: | if ( epl_listing_has_fourth_agent() ) { |
| 795: | $epl_author = $epl_author_fourth; |
| 796: | epl_get_template_part( 'widget-content-author-tall.php', $arg_list ); |
| 797: | } |
| 798: | epl_reset_post_author(); |
| 799: | } |
| 800: | } |
| 801: | } |
| 802: | |
| 803: | |
| 804: | |
| 805: | |
| 806: | |
| 807: | |
| 808: | |
| 809: | |
| 810: | |
| 811: | |
| 812: | |
| 813: | function epl_show_author_widget_by_username( $d_image, $d_icons, $d_bio, $username ) { |
| 814: | $username = explode( ',', $username ); |
| 815: | $username = array_filter( $username ); |
| 816: | foreach ( $username as $uname ) { |
| 817: | $author = get_user_by( 'login', sanitize_user( $uname ) ); |
| 818: | if ( false !== $author ) { |
| 819: | $epl_author = new EPL_Author_meta( $author->ID ); |
| 820: | $arg_list = get_defined_vars(); |
| 821: | epl_get_template_part( 'widget-content-author-tall.php', $arg_list ); |
| 822: | } |
| 823: | } |
| 824: | } |
| 825: | |
| 826: | |
| 827: | |
| 828: | |
| 829: | |
| 830: | |
| 831: | |
| 832: | |
| 833: | function epl_property_get_the_full_address() { |
| 834: | global $property; |
| 835: | |
| 836: | $address = ''; |
| 837: | $sub_num = $property->get_property_meta( 'property_address_sub_number' ); |
| 838: | if ( ! empty( $sub_num ) ) { |
| 839: | $address .= $property->get_property_meta( 'property_address_sub_number' ) . '/'; |
| 840: | } |
| 841: | $address .= $property->get_property_meta( 'property_address_street_number' ) . ' '; |
| 842: | $address .= $property->get_property_meta( 'property_address_street' ) . ' '; |
| 843: | $address .= $property->get_property_meta( 'property_address_suburb' ) . ' '; |
| 844: | $address .= $property->get_property_meta( 'property_address_city' ) . ', '; |
| 845: | $address .= $property->get_property_meta( 'property_address_state' ) . ' '; |
| 846: | $address .= $property->get_property_meta( 'property_address_postal_code' ) . ' '; |
| 847: | $address .= $property->get_property_meta( 'property_address_country' ); |
| 848: | |
| 849: | return $address; |
| 850: | } |
| 851: | |
| 852: | |
| 853: | |
| 854: | |
| 855: | |
| 856: | |
| 857: | |
| 858: | |
| 859: | |
| 860: | |
| 861: | |
| 862: | |
| 863: | |
| 864: | |
| 865: | |
| 866: | |
| 867: | |
| 868: | |
| 869: | function epl_property_the_address( $full = true, $street_separator = true, $separator_symbol = ',' ) { |
| 870: | |
| 871: | global $property, $epl_settings; |
| 872: | |
| 873: | if ( ! is_bool( $full ) ) { |
| 874: | $full = true; |
| 875: | } |
| 876: | |
| 877: | $epl_property_address_separator = apply_filters( 'epl_property_address_separator', ',' ); |
| 878: | $epl_property_address_separator_suburb = apply_filters( 'epl_property_address_separator_suburb', false ); |
| 879: | $epl_property_address_separator_city = apply_filters( 'epl_property_address_separator_city', false ); |
| 880: | |
| 881: | ?> |
| 882: | <?php if ( $property->show_street_address() ) { ?> |
| 883: | <span class="item-street"><?php echo wp_kses_post( $property->get_formatted_property_address( $street_separator, $separator_symbol ) ); ?></span> |
| 884: | <?php } ?> |
| 885: | |
| 886: | <?php |
| 887: | if ( true === $full ) { |
| 888: | ?> |
| 889: | <span class="entry-title-sub"> |
| 890: | <?php |
| 891: | if ( $property->show_suburb() ) { |
| 892: | ?> |
| 893: | <span class="item-suburb"><?php echo esc_html( $property->get_property_meta( 'property_address_suburb' ) ); ?></span> |
| 894: | <?php |
| 895: | if ( true === $epl_property_address_separator_suburb && strlen( trim( $property->get_property_meta( 'property_address_suburb' ) ) ) ) { |
| 896: | echo '<span class="item-separator">' . esc_html( $epl_property_address_separator ) . '</span>'; |
| 897: | } |
| 898: | } |
| 899: | ?> |
| 900: | |
| 901: | <?php |
| 902: | if ( $property->show_address_city() ) { |
| 903: | ?> |
| 904: | <span class="item-city"><?php echo esc_html( $property->get_property_meta( 'property_address_city' ) ); ?></span> |
| 905: | <?php |
| 906: | if ( true === $epl_property_address_separator_city && strlen( trim( $property->get_property_meta( 'property_address_city' ) ) ) ) { |
| 907: | echo '<span class="item-separator">' . esc_html( $epl_property_address_separator ) . '</span>'; |
| 908: | } |
| 909: | } |
| 910: | ?> |
| 911: | <span class="item-state"><?php echo esc_html( $property->get_property_meta( 'property_address_state' ) ); ?></span> |
| 912: | <span class="item-pcode"><?php echo esc_html( $property->get_property_meta( 'property_address_postal_code' ) ); ?></span> |
| 913: | <?php |
| 914: | if ( $property->show_address_country() ) { |
| 915: | ?> |
| 916: | <span class="item-country"><?php echo esc_html( $property->get_property_meta( 'property_address_country' ) ); ?></span> |
| 917: | <?php |
| 918: | } |
| 919: | ?> |
| 920: | </span> |
| 921: | <?php |
| 922: | } |
| 923: | } |
| 924: | add_action( 'epl_property_title', 'epl_property_the_address', 10, 3 ); |
| 925: | add_action( 'epl_property_tab_address', 'epl_property_the_address', 10, 3 ); |
| 926: | add_action( 'epl_property_address', 'epl_property_the_address', 10, 3 ); |
| 927: | |
| 928: | |
| 929: | |
| 930: | |
| 931: | |
| 932: | |
| 933: | |
| 934: | |
| 935: | |
| 936: | |
| 937: | |
| 938: | function epl_property_suburb() { |
| 939: | global $property; |
| 940: | |
| 941: | if ( $property->show_suburb() ) { |
| 942: | ?> |
| 943: | <span class="entry-title-sub"> |
| 944: | <span class="item-suburb"><?php echo esc_html( $property->get_property_meta( 'property_address_suburb' ) ); ?></span> |
| 945: | </span> |
| 946: | <?php |
| 947: | } else { |
| 948: | ?> |
| 949: | |
| 950: | <span class="entry-title-sub"> |
| 951: | <?php $prop_addr_city = $property->get_property_meta( 'property_address_city' ); ?> |
| 952: | <?php if ( ! empty( $prop_addr_city ) ) { ?> |
| 953: | <span class="item-city"><?php echo esc_html( $property->get_property_meta( 'property_address_city' ) ) . ' '; ?></span> |
| 954: | <?php } ?> |
| 955: | |
| 956: | <span class="item-state"><?php echo esc_html( $property->get_property_meta( 'property_address_state' ) ) . ' '; ?></span> |
| 957: | <span class="item-pcode"><?php echo esc_html( $property->get_property_meta( 'property_address_postal_code' ) ); ?></span> |
| 958: | </span> |
| 959: | |
| 960: | <?php |
| 961: | } |
| 962: | } |
| 963: | add_action( 'epl_property_suburb', 'epl_property_suburb' ); |
| 964: | |
| 965: | |
| 966: | |
| 967: | |
| 968: | |
| 969: | |
| 970: | |
| 971: | function epl_property_price() { |
| 972: | echo wp_kses_post( epl_get_property_price() ); |
| 973: | } |
| 974: | add_action( 'epl_property_price', 'epl_property_price' ); |
| 975: | add_action( 'epl_property_price_content', 'epl_property_price' ); |
| 976: | |
| 977: | |
| 978: | |
| 979: | |
| 980: | |
| 981: | |
| 982: | |
| 983: | |
| 984: | |
| 985: | |
| 986: | |
| 987: | |
| 988: | function epl_get_property_icons( $args = array(), $returntype = 'i' ) { |
| 989: | |
| 990: | global $property; |
| 991: | |
| 992: | $defaults = array( 'bed', 'bath', 'parking', 'ac', 'pool' ); |
| 993: | |
| 994: | $icons = apply_filters( 'epl_get_property_icons', $defaults ); |
| 995: | $returntype = apply_filters( 'epl_icons_return_type', $returntype ); |
| 996: | |
| 997: | ob_start(); |
| 998: | |
| 999: | foreach ( $icons as $icon ) { |
| 1000: | |
| 1001: | if ( ! empty( $args ) && ! in_array( $icon, $args, true ) ) { |
| 1002: | continue; |
| 1003: | } |
| 1004: | |
| 1005: | switch ( $icon ) { |
| 1006: | |
| 1007: | case 'bed': |
| 1008: | echo $property->get_property_bed( $returntype ); |
| 1009: | break; |
| 1010: | |
| 1011: | case 'bath': |
| 1012: | echo $property->get_property_bath( $returntype ); |
| 1013: | break; |
| 1014: | |
| 1015: | case 'parking': |
| 1016: | echo $property->get_property_parking( $returntype ); |
| 1017: | break; |
| 1018: | |
| 1019: | case 'ac': |
| 1020: | echo $property->get_property_air_conditioning( $returntype ); |
| 1021: | break; |
| 1022: | |
| 1023: | case 'pool': |
| 1024: | echo $property->get_property_pool( $returntype ); |
| 1025: | break; |
| 1026: | |
| 1027: | default: |
| 1028: | |
| 1029: | do_action( 'epl_get_property_icon_' . $icon ); |
| 1030: | break; |
| 1031: | } |
| 1032: | } |
| 1033: | |
| 1034: | return ob_get_clean(); |
| 1035: | } |
| 1036: | |
| 1037: | |
| 1038: | |
| 1039: | |
| 1040: | |
| 1041: | |
| 1042: | |
| 1043: | |
| 1044: | |
| 1045: | function epl_property_icons( $returntype = 'i' ) { |
| 1046: | $returntype = empty( $returntype ) ? 'i' : $returntype; |
| 1047: | echo epl_get_property_icons( array(), $returntype ); |
| 1048: | } |
| 1049: | add_action( 'epl_property_icons', 'epl_property_icons', 10, 1 ); |
| 1050: | |
| 1051: | |
| 1052: | |
| 1053: | |
| 1054: | |
| 1055: | |
| 1056: | |
| 1057: | |
| 1058: | function epl_get_property_bb_icons() { |
| 1059: | global $property; |
| 1060: | return $property->get_property_bed() . ' ' . |
| 1061: | $property->get_property_bath(); |
| 1062: | } |
| 1063: | |
| 1064: | |
| 1065: | |
| 1066: | |
| 1067: | |
| 1068: | |
| 1069: | |
| 1070: | |
| 1071: | |
| 1072: | function epl_property_land_category() { |
| 1073: | global $property; |
| 1074: | $land_category = $property->get_property_land_category(); |
| 1075: | |
| 1076: | if ( empty( $land_category ) ) { |
| 1077: | return $land_category; |
| 1078: | } |
| 1079: | |
| 1080: | echo wp_kses_post( $land_category ); |
| 1081: | } |
| 1082: | add_action( 'epl_property_land_category', 'epl_property_land_category' ); |
| 1083: | |
| 1084: | |
| 1085: | |
| 1086: | |
| 1087: | |
| 1088: | |
| 1089: | function epl_property_commercial_category() { |
| 1090: | global $property; |
| 1091: | if ( 'commercial' === $property->post_type ) { |
| 1092: | if ( 1 === (int) $property->get_property_meta( 'property_com_plus_outgoings' ) ) { |
| 1093: | echo '<div class="price-type">' . esc_html( apply_filters( 'epl_property_sub_title_plus_outgoings_label', __( 'Plus Outgoings', 'easy-property-listings' ) ) ) . '</div>'; |
| 1094: | } |
| 1095: | echo wp_kses_post( $property->get_property_commercial_category() ); |
| 1096: | } |
| 1097: | } |
| 1098: | add_action( 'epl_property_commercial_category', 'epl_property_commercial_category' ); |
| 1099: | |
| 1100: | |
| 1101: | |
| 1102: | |
| 1103: | |
| 1104: | |
| 1105: | function epl_property_available_dates() { |
| 1106: | global $property; |
| 1107: | $date_avail = $property->get_property_meta( 'property_date_available' ); |
| 1108: | if ( 'rental' === $property->post_type && |
| 1109: | ! empty( $date_avail ) |
| 1110: | && 'leased' !== $property->get_property_meta( 'property_status' ) ) { |
| 1111: | |
| 1112: | echo '<div class="property-meta date-available">' . wp_kses_post( apply_filters( 'epl_property_sub_title_available_from_label', __( 'Available from', 'easy-property-listings' ) ) ) . ' ', wp_kses_post( $property->get_property_available() ), '</div>'; |
| 1113: | } |
| 1114: | } |
| 1115: | add_action( 'epl_property_available_dates', 'epl_property_available_dates' ); |
| 1116: | |
| 1117: | |
| 1118: | |
| 1119: | |
| 1120: | |
| 1121: | |
| 1122: | |
| 1123: | function epl_property_inspection_times() { |
| 1124: | global $property; |
| 1125: | $property_inspection_times = $property->get_property_inspection_times(); |
| 1126: | $label_home_open = ''; |
| 1127: | |
| 1128: | if ( ! empty( $property_inspection_times ) ) { |
| 1129: | $property_inspection_times = trim( $property_inspection_times ); |
| 1130: | } else { |
| 1131: | return; |
| 1132: | } |
| 1133: | |
| 1134: | if ( ! empty( $property_inspection_times ) ) { |
| 1135: | $label_home_open = $property->get_epl_settings( 'label_home_open' ); |
| 1136: | |
| 1137: | $label_home_open = apply_filters( 'epl_inspection_times_label', $label_home_open ); |
| 1138: | ?> |
| 1139: | <div class="epl-inspection-times"> |
| 1140: | <span class="epl-inspection-times-label"> |
| 1141: | <?php echo wp_kses_post( $label_home_open ); ?> |
| 1142: | </span> |
| 1143: | <?php echo wp_kses_post( $property_inspection_times ); ?> |
| 1144: | </div> |
| 1145: | <?php |
| 1146: | } |
| 1147: | } |
| 1148: | add_action( 'epl_property_inspection_times', 'epl_property_inspection_times' ); |
| 1149: | |
| 1150: | |
| 1151: | |
| 1152: | |
| 1153: | |
| 1154: | |
| 1155: | |
| 1156: | |
| 1157: | |
| 1158: | |
| 1159: | |
| 1160: | function epl_get_property_heading( $listing = null ) { |
| 1161: | if ( null === $listing ) { |
| 1162: | global $property; |
| 1163: | } elseif ( $listing instanceof EPL_Property_Meta ) { |
| 1164: | $property = $listing; |
| 1165: | } elseif ( $listing instanceof WP_Post ) { |
| 1166: | $property = new EPL_Property_Meta( $listing ); |
| 1167: | } else { |
| 1168: | $property = get_post( $listing ); |
| 1169: | $property = new EPL_Property_Meta( $property ); |
| 1170: | } |
| 1171: | |
| 1172: | if ( $property ) { |
| 1173: | $property_heading = $property->get_property_meta( 'property_heading' ); |
| 1174: | if ( null === $property_heading ) { |
| 1175: | $property_heading = ''; |
| 1176: | } |
| 1177: | if ( strlen( trim( $property_heading ) ) ) { |
| 1178: | return $property_heading; |
| 1179: | } |
| 1180: | return get_the_title( $property->post->ID ); |
| 1181: | } |
| 1182: | return ''; |
| 1183: | } |
| 1184: | |
| 1185: | |
| 1186: | |
| 1187: | |
| 1188: | |
| 1189: | |
| 1190: | |
| 1191: | |
| 1192: | |
| 1193: | function epl_property_heading( $listing = null ) { |
| 1194: | echo wp_kses_post( epl_get_property_heading( $listing ) ); |
| 1195: | } |
| 1196: | add_action( 'epl_property_heading', 'epl_property_heading' ); |
| 1197: | |
| 1198: | |
| 1199: | |
| 1200: | |
| 1201: | |
| 1202: | |
| 1203: | |
| 1204: | |
| 1205: | |
| 1206: | function epl_property_secondary_heading() { |
| 1207: | global $property; |
| 1208: | |
| 1209: | if ( in_array( $property->post_type, array( 'rental', 'property' ), true ) ) { |
| 1210: | echo wp_kses_post( $property->get_property_category( 'span', 'epl-property-category' ) ); |
| 1211: | } |
| 1212: | |
| 1213: | if ( 'rural' === $property->post_type ) { |
| 1214: | echo wp_kses_post( $property->get_property_rural_category( 'span', 'epl-rural-category' ) ); |
| 1215: | } |
| 1216: | |
| 1217: | if ( 'land' === $property->post_type ) { |
| 1218: | echo wp_kses_post( $property->get_property_land_category( 'span', 'epl-land-category' ) ); |
| 1219: | } |
| 1220: | |
| 1221: | if ( 'commercial' === $property->post_type || 'commercial_land' === $property->post_type ) { |
| 1222: | echo wp_kses_post( $property->get_property_commercial_category( 'span', 'epl-commercial-category' ) ); |
| 1223: | } |
| 1224: | |
| 1225: | if ( 'sold' === $property->get_property_meta( 'property_status' ) ) { |
| 1226: | echo ' <span class="sold-status">' . esc_html( $property->label_sold ) . '</span>'; |
| 1227: | } |
| 1228: | |
| 1229: | $suburb = $property->get_property_meta( 'property_address_suburb' ); |
| 1230: | if ( null === $suburb ) { |
| 1231: | $suburb = ''; |
| 1232: | } |
| 1233: | |
| 1234: | $state = $property->get_property_meta( 'property_address_state' ); |
| 1235: | if ( null === $state ) { |
| 1236: | $state = ''; |
| 1237: | } |
| 1238: | |
| 1239: | echo ' <span class="suburb"> - ' . wp_kses_post( $suburb ) . ' </span>'; |
| 1240: | echo ' <span class="state">' . wp_kses_post( $state ) . '</span>'; |
| 1241: | } |
| 1242: | add_action( 'epl_property_secondary_heading', 'epl_property_secondary_heading' ); |
| 1243: | |
| 1244: | |
| 1245: | |
| 1246: | |
| 1247: | |
| 1248: | |
| 1249: | |
| 1250: | |
| 1251: | |
| 1252: | |
| 1253: | function epl_property_category( $tag = 'div', $classname = 'property-category' ) { |
| 1254: | global $property; |
| 1255: | |
| 1256: | if ( empty( $tag ) ) { |
| 1257: | $tag = 'div'; |
| 1258: | } |
| 1259: | |
| 1260: | echo wp_kses_post( $property->get_property_category( $tag, $classname ) ); |
| 1261: | } |
| 1262: | add_action( 'epl_property_category', 'epl_property_category', 10, 2 ); |
| 1263: | |
| 1264: | |
| 1265: | |
| 1266: | |
| 1267: | |
| 1268: | |
| 1269: | |
| 1270: | |
| 1271: | |
| 1272: | |
| 1273: | function epl_get_video_host( $url ) { |
| 1274: | |
| 1275: | $host = 'unknown'; |
| 1276: | $url = (string) $url; |
| 1277: | |
| 1278: | if ( strpos( $url, 'youtu' ) > 0 ) { |
| 1279: | $host = 'youtube'; |
| 1280: | } elseif ( strpos( $url, 'vimeo' ) > 0 ) { |
| 1281: | $host = 'vimeo'; |
| 1282: | } |
| 1283: | |
| 1284: | return $host; |
| 1285: | } |
| 1286: | |
| 1287: | |
| 1288: | |
| 1289: | |
| 1290: | |
| 1291: | |
| 1292: | |
| 1293: | |
| 1294: | |
| 1295: | |
| 1296: | |
| 1297: | |
| 1298: | |
| 1299: | |
| 1300: | function epl_get_video_html( $property_video_url = '', $width = 600 ) { |
| 1301: | |
| 1302: | $property_video_url = apply_filters( 'epl_property_video_url', $property_video_url ); |
| 1303: | |
| 1304: | |
| 1305: | if ( 'youtube' === epl_get_video_host( $property_video_url ) ) { |
| 1306: | |
| 1307: | $property_video_url = epl_convert_youtube_embed_url( $property_video_url ); |
| 1308: | |
| 1309: | if ( strpos( $property_video_url, '?' ) > 0 ) { |
| 1310: | $property_video_url .= '&rel=0'; |
| 1311: | } else { |
| 1312: | $property_video_url .= '?rel=0'; |
| 1313: | } |
| 1314: | } |
| 1315: | $width = epl_get_option( 'epl_video_width', $width ); |
| 1316: | if ( ! empty( $property_video_url ) ) { |
| 1317: | $video_html = '<div class="epl-video-container videoContainer">'; |
| 1318: | |
| 1319: | $video_embed_html = wp_oembed_get( |
| 1320: | $property_video_url, |
| 1321: | array( 'width' => apply_filters( 'epl_property_video_width', $width ) ) |
| 1322: | ); |
| 1323: | |
| 1324: | if ( $video_embed_html ) { |
| 1325: | $video_html .= $video_embed_html; |
| 1326: | } else { |
| 1327: | $video_html .= '<video class="epl-local-video" controls width="' . $width . '"> |
| 1328: | <source src="' . $property_video_url . '"> |
| 1329: | </video>'; |
| 1330: | } |
| 1331: | |
| 1332: | $video_html .= '</div>'; |
| 1333: | |
| 1334: | return $video_html; |
| 1335: | } |
| 1336: | } |
| 1337: | |
| 1338: | |
| 1339: | |
| 1340: | |
| 1341: | |
| 1342: | |
| 1343: | |
| 1344: | |
| 1345: | |
| 1346: | |
| 1347: | function epl_convert_youtube_embed_url( $url ) { |
| 1348: | |
| 1349: | if ( strpos( $url, 'embed' ) > 0 || strpos( $url, 'shorts' ) > 0 ) { |
| 1350: | |
| 1351: | $video_id = epl_get_youtube_id_from_url( $url ); |
| 1352: | |
| 1353: | if ( ! empty( $video_id ) ) { |
| 1354: | $url = 'https://www.youtube.com/watch?v=' . $video_id; |
| 1355: | } |
| 1356: | } |
| 1357: | |
| 1358: | return apply_filters( 'epl_youtube_embed_url', $url ); |
| 1359: | } |
| 1360: | |
| 1361: | |
| 1362: | |
| 1363: | |
| 1364: | |
| 1365: | |
| 1366: | |
| 1367: | |
| 1368: | |
| 1369: | |
| 1370: | |
| 1371: | function epl_property_video_callback( $width = 600 ) { |
| 1372: | |
| 1373: | global $property; |
| 1374: | $video_width = ! empty( $width ) ? $width : 600; |
| 1375: | $property_video_url = $property->get_property_meta( 'property_video_url' ); |
| 1376: | |
| 1377: | if ( '' !== $property_video_url ) { |
| 1378: | echo epl_get_video_html( $property_video_url, $video_width ); |
| 1379: | } |
| 1380: | } |
| 1381: | add_action( 'epl_property_video', 'epl_property_video_callback', 10, 1 ); |
| 1382: | |
| 1383: | |
| 1384: | |
| 1385: | |
| 1386: | |
| 1387: | |
| 1388: | |
| 1389: | add_action( 'epl_property_content_after', 'epl_property_video_callback', 10, 1 ); |
| 1390: | |
| 1391: | |
| 1392: | |
| 1393: | |
| 1394: | |
| 1395: | |
| 1396: | |
| 1397: | |
| 1398: | |
| 1399: | |
| 1400: | |
| 1401: | |
| 1402: | |
| 1403: | function epl_property_tab_section() { |
| 1404: | global $property; |
| 1405: | $post_type = $property->post_type; |
| 1406: | $the_property_feature_list = apply_filters( 'epl_the_property_feature_list_before', '' ); |
| 1407: | |
| 1408: | $general_features_array = array( |
| 1409: | 'category', |
| 1410: | 'rural_category', |
| 1411: | 'commercial_category', |
| 1412: | 'bed', |
| 1413: | 'bath', |
| 1414: | 'rooms', |
| 1415: | 'year_built', |
| 1416: | 'parking', |
| 1417: | 'ac', |
| 1418: | 'pool', |
| 1419: | 'security', |
| 1420: | 'land_value', |
| 1421: | 'building_value', |
| 1422: | 'energy_rating', |
| 1423: | 'new_construction', |
| 1424: | ); |
| 1425: | |
| 1426: | $general_features_array = apply_filters( 'epl_property_general_features_list', $general_features_array ); |
| 1427: | |
| 1428: | foreach ( $general_features_array as $general_feature ) { |
| 1429: | |
| 1430: | switch ( $general_feature ) { |
| 1431: | |
| 1432: | case 'category': |
| 1433: | if ( 'property' === $post_type || 'rental' === $post_type ) { |
| 1434: | $the_property_feature_list .= $property->get_property_category( 'li' ); |
| 1435: | } |
| 1436: | |
| 1437: | break; |
| 1438: | |
| 1439: | case 'rural_category': |
| 1440: | if ( 'rural' === $post_type ) { |
| 1441: | $the_property_feature_list .= $property->get_property_rural_category( 'li' ); |
| 1442: | } |
| 1443: | |
| 1444: | break; |
| 1445: | |
| 1446: | case 'commercial_category': |
| 1447: | if ( 'commercial' === $post_type || 'commercial_land' === $post_type || 'business' === $post_type ) { |
| 1448: | $the_property_feature_list .= $property->get_property_commercial_category( 'li' ); |
| 1449: | } |
| 1450: | |
| 1451: | break; |
| 1452: | |
| 1453: | case 'bed': |
| 1454: | $the_property_feature_list .= $property->get_property_bed( 'l' ) . ' '; |
| 1455: | |
| 1456: | break; |
| 1457: | |
| 1458: | case 'bath': |
| 1459: | $the_property_feature_list .= $property->get_property_bath( 'l' ) . ' '; |
| 1460: | |
| 1461: | break; |
| 1462: | |
| 1463: | case 'rooms': |
| 1464: | $the_property_feature_list .= $property->get_property_rooms( 'l' ) . ' '; |
| 1465: | |
| 1466: | break; |
| 1467: | |
| 1468: | case 'year_built': |
| 1469: | $the_property_feature_list .= $property->get_property_year_built( 'l' ) . ' '; |
| 1470: | |
| 1471: | break; |
| 1472: | |
| 1473: | case 'parking': |
| 1474: | $the_property_feature_list .= $property->get_property_parking( 'l' ) . ' '; |
| 1475: | |
| 1476: | break; |
| 1477: | |
| 1478: | case 'ac': |
| 1479: | $the_property_feature_list .= $property->get_property_air_conditioning( 'l' ) . ' '; |
| 1480: | |
| 1481: | break; |
| 1482: | |
| 1483: | case 'pool': |
| 1484: | $the_property_feature_list .= $property->get_property_pool( 'l' ); |
| 1485: | |
| 1486: | break; |
| 1487: | |
| 1488: | case 'security': |
| 1489: | $the_property_feature_list .= $property->get_property_security_system( 'l' ) . ' '; |
| 1490: | |
| 1491: | break; |
| 1492: | |
| 1493: | case 'land_value': |
| 1494: | $the_property_feature_list .= $property->get_property_land_value( 'l' ); |
| 1495: | |
| 1496: | break; |
| 1497: | |
| 1498: | case 'building_value': |
| 1499: | $the_property_feature_list .= $property->get_property_building_area_value( 'l' ) . ' '; |
| 1500: | |
| 1501: | break; |
| 1502: | |
| 1503: | case 'energy_rating': |
| 1504: | $the_property_feature_list .= $property->get_property_energy_rating( 'l' ); |
| 1505: | |
| 1506: | break; |
| 1507: | |
| 1508: | case 'new_construction': |
| 1509: | $the_property_feature_list .= $property->get_property_new_construction( 'l' ); |
| 1510: | |
| 1511: | break; |
| 1512: | |
| 1513: | default: |
| 1514: | ob_start(); |
| 1515: | do_action( 'epl_property_general_feature_' . $general_feature ); |
| 1516: | $the_property_feature_list .= ob_get_clean(); |
| 1517: | |
| 1518: | break; |
| 1519: | |
| 1520: | } |
| 1521: | } |
| 1522: | |
| 1523: | $the_property_feature_list .= apply_filters( 'epl_the_property_feature_list_before_common_features', '' ); |
| 1524: | |
| 1525: | $common_features = array( |
| 1526: | 'property_toilet', |
| 1527: | 'property_ensuite', |
| 1528: | 'property_pet_friendly', |
| 1529: | 'property_garage', |
| 1530: | 'property_carport', |
| 1531: | 'property_open_spaces', |
| 1532: | 'property_com_parking_comments', |
| 1533: | 'property_com_car_spaces', |
| 1534: | 'property_holiday_rental', |
| 1535: | 'property_furnished', |
| 1536: | ); |
| 1537: | $common_features = apply_filters( 'epl_property_common_features_list', $common_features ); |
| 1538: | |
| 1539: | foreach ( $common_features as $common_feature ) { |
| 1540: | $the_property_feature_list .= $property->get_additional_features_html( $common_feature ); |
| 1541: | } |
| 1542: | |
| 1543: | $the_property_feature_list .= apply_filters( 'epl_the_property_feature_list_before_additional_features', '' ); |
| 1544: | |
| 1545: | $additional_features = array( |
| 1546: | 'property_remote_garage', |
| 1547: | 'property_secure_parking', |
| 1548: | 'property_study', |
| 1549: | 'property_dishwasher', |
| 1550: | 'property_built_in_robes', |
| 1551: | 'property_gym', |
| 1552: | 'property_workshop', |
| 1553: | 'property_rumpus_room', |
| 1554: | 'property_floor_boards', |
| 1555: | 'property_broadband', |
| 1556: | 'property_pay_tv', |
| 1557: | 'property_vacuum_system', |
| 1558: | 'property_intercom', |
| 1559: | 'property_spa', |
| 1560: | 'property_tennis_court', |
| 1561: | 'property_balcony', |
| 1562: | 'property_deck', |
| 1563: | 'property_courtyard', |
| 1564: | 'property_outdoor_entertaining', |
| 1565: | 'property_shed', |
| 1566: | 'property_open_fire_place', |
| 1567: | 'property_ducted_heating', |
| 1568: | 'property_ducted_cooling', |
| 1569: | 'property_split_system_heating', |
| 1570: | 'property_hydronic_heating', |
| 1571: | 'property_split_system_aircon', |
| 1572: | 'property_gas_heating', |
| 1573: | 'property_reverse_cycle_aircon', |
| 1574: | 'property_evaporative_cooling', |
| 1575: | 'property_land_fully_fenced', |
| 1576: | ); |
| 1577: | $additional_features = apply_filters( 'epl_property_additional_features_list', $additional_features ); |
| 1578: | |
| 1579: | if ( 'property' === $property->post_type || 'rental' === $property->post_type || 'rural' === $property->post_type ) { |
| 1580: | foreach ( $additional_features as $additional_feature ) { |
| 1581: | $the_property_feature_list .= $property->get_additional_features_html( $additional_feature ); |
| 1582: | } |
| 1583: | } |
| 1584: | |
| 1585: | $the_property_feature_list .= apply_filters( 'epl_the_property_feature_list_after', '' ); |
| 1586: | |
| 1587: | if ( 'land' !== $property->post_type || 'business' !== $property->post_type ) { |
| 1588: | ?> |
| 1589: | <?php $property_features_title = apply_filters( 'epl_property_sub_title_property_features', __( 'Property Features', 'easy-property-listings' ) ); ?> |
| 1590: | <h5 class="epl-tab-title epl-tab-title-property-features tab-title"><?php echo wp_kses_post( $property_features_title ); ?></h5> |
| 1591: | <div class="epl-tab-content tab-content"> |
| 1592: | <ul class="epl-property-features listing-info epl-tab-<?php echo esc_attr( $property->get_epl_settings( 'display_feature_columns' ) ); ?>-columns"> |
| 1593: | <?php echo wp_kses_post( $the_property_feature_list . ' ' . $property->get_features_from_taxonomy() ); ?> |
| 1594: | </ul> |
| 1595: | </div> |
| 1596: | <?php } ?> |
| 1597: | |
| 1598: | <div class="epl-tab-content epl-tab-content-additional tab-content"> |
| 1599: | <?php |
| 1600: | |
| 1601: | if ( 'land' === $property->post_type || 'commercial_land' === $property->post_type ) { |
| 1602: | echo '<div class="epl-land-category">' . wp_kses_post( $property->get_property_land_category( 'value' ) ) . '</div>'; |
| 1603: | } |
| 1604: | |
| 1605: | |
| 1606: | if ( 'commercial' === $property->post_type ) { |
| 1607: | if ( 1 === (int) $property->get_property_meta( 'property_com_plus_outgoings' ) ) { |
| 1608: | echo '<div class="epl-commercial-outgoings price-type">' . wp_kses_post( apply_filters( 'epl_property_sub_title_plus_outgoings', __( 'Plus Outgoings', 'easy-property-listings' ) ) ) . '</div>'; |
| 1609: | } |
| 1610: | } |
| 1611: | ?> |
| 1612: | </div> |
| 1613: | <?php |
| 1614: | } |
| 1615: | add_action( 'epl_property_tab_section', 'epl_property_tab_section' ); |
| 1616: | add_action( 'epl_property_features', 'epl_property_tab_section' ); |
| 1617: | |
| 1618: | |
| 1619: | |
| 1620: | |
| 1621: | |
| 1622: | |
| 1623: | |
| 1624: | |
| 1625: | |
| 1626: | |
| 1627: | |
| 1628: | |
| 1629: | function epl_property_tab_section_after() { |
| 1630: | global $property; |
| 1631: | $post_type = $property->post_type; |
| 1632: | if ( 'commercial' === $post_type || 'business' === $post_type || 'commercial_land' === $post_type ) { |
| 1633: | |
| 1634: | $the_property_commercial_feature_list = ''; |
| 1635: | $features_lists = array( |
| 1636: | 'property_com_further_options', |
| 1637: | 'property_com_highlight_1', |
| 1638: | 'property_com_highlight_2', |
| 1639: | 'property_com_highlight_3', |
| 1640: | 'property_com_zone', |
| 1641: | ); |
| 1642: | |
| 1643: | $features_lists = apply_filters( 'epl_property_commercial_features_list', $features_lists ); |
| 1644: | |
| 1645: | |
| 1646: | $commercial_value = ''; |
| 1647: | |
| 1648: | $result = array(); |
| 1649: | |
| 1650: | foreach ( $features_lists as $feature ) { |
| 1651: | |
| 1652: | $commercial_value = $property->get_property_meta( $feature ); |
| 1653: | |
| 1654: | if ( ! empty( $commercial_value ) ) { |
| 1655: | $result[] = $commercial_value; |
| 1656: | } |
| 1657: | } |
| 1658: | |
| 1659: | |
| 1660: | if ( ! empty( $result ) ) { |
| 1661: | |
| 1662: | foreach ( $features_lists as $features_list ) { |
| 1663: | $the_property_commercial_feature_list .= $property->get_additional_commercial_features_html( $features_list ); |
| 1664: | } |
| 1665: | |
| 1666: | ?> |
| 1667: | <div class="epl-tab-section epl-tab-section-commercial-features"> |
| 1668: | <h5 class="epl-tab-title epl-tab-title-commercial-features tab-title"><?php echo wp_kses_post( apply_filters( 'epl_property_sub_title_commercial_features', __( 'Commercial Features', 'easy-property-listings' ) ) ); ?></h5> |
| 1669: | <div class="epl-tab-content tab-content"> |
| 1670: | <div class="epl-commercial-features listing-info"> |
| 1671: | <?php echo wp_kses_post( $the_property_commercial_feature_list ); ?> |
| 1672: | </div> |
| 1673: | </div> |
| 1674: | </div> |
| 1675: | <?php |
| 1676: | } |
| 1677: | } |
| 1678: | |
| 1679: | if ( 'rural' === $property->post_type ) { |
| 1680: | $the_property_rural_feature_list = ''; |
| 1681: | $features_lists = array( |
| 1682: | 'property_rural_fencing', |
| 1683: | 'property_rural_annual_rainfall', |
| 1684: | 'property_rural_soil_types', |
| 1685: | 'property_rural_improvements', |
| 1686: | 'property_rural_council_rates', |
| 1687: | 'property_rural_irrigation', |
| 1688: | 'property_rural_carrying_capacity', |
| 1689: | ); |
| 1690: | |
| 1691: | $features_lists = apply_filters( 'epl_property_rural_features_list', $features_lists ); |
| 1692: | |
| 1693: | |
| 1694: | $rural_value = ''; |
| 1695: | |
| 1696: | $result = array(); |
| 1697: | |
| 1698: | foreach ( $features_lists as $feature ) { |
| 1699: | |
| 1700: | $rural_value = $property->get_property_meta( $feature ); |
| 1701: | |
| 1702: | if ( ! empty( $rural_value ) ) { |
| 1703: | $result[] = $rural_value; |
| 1704: | } |
| 1705: | } |
| 1706: | |
| 1707: | |
| 1708: | if ( ! empty( $result ) ) { |
| 1709: | |
| 1710: | foreach ( $features_lists as $features_list ) { |
| 1711: | $the_property_rural_feature_list .= $property->get_additional_rural_features_html( $features_list ); |
| 1712: | } |
| 1713: | |
| 1714: | ?> |
| 1715: | <div class="epl-tab-section epl-tab-section-rural-features"> |
| 1716: | <h5 class="epl-tab-title epl-tab-title-rural-features tab-title"><?php echo wp_kses_post( apply_filters( 'epl_property_sub_title_rural_features', __( 'Rural Features', 'easy-property-listings' ) ) ); ?></h5> |
| 1717: | <div class="epl-tab-content tab-content"> |
| 1718: | <div class="epl-rural-features listing-info"> |
| 1719: | <?php echo wp_kses_post( $the_property_rural_feature_list ); ?> |
| 1720: | </div> |
| 1721: | </div> |
| 1722: | </div> |
| 1723: | <?php |
| 1724: | } |
| 1725: | } |
| 1726: | } |
| 1727: | add_action( 'epl_property_tab_section_after', 'epl_property_tab_section_after' ); |
| 1728: | |
| 1729: | |
| 1730: | |
| 1731: | |
| 1732: | |
| 1733: | |
| 1734: | |
| 1735: | function epl_get_price_sticker() { |
| 1736: | global $property; |
| 1737: | return $property->get_price_sticker(); |
| 1738: | } |
| 1739: | |
| 1740: | |
| 1741: | |
| 1742: | |
| 1743: | |
| 1744: | |
| 1745: | |
| 1746: | function epl_get_property_price() { |
| 1747: | global $property; |
| 1748: | return $property->get_price(); |
| 1749: | } |
| 1750: | |
| 1751: | |
| 1752: | |
| 1753: | |
| 1754: | |
| 1755: | |
| 1756: | |
| 1757: | |
| 1758: | |
| 1759: | |
| 1760: | |
| 1761: | function epl_widget_listing_address( $d_suburb = '', $d_street = '' ) { |
| 1762: | global $property; |
| 1763: | |
| 1764: | |
| 1765: | if ( 'on' === $d_suburb && $property->show_suburb() ) { |
| 1766: | $suburb = $property->get_property_meta( 'property_address_suburb' ); |
| 1767: | if ( null === $suburb ) { |
| 1768: | $suburb = ''; |
| 1769: | } |
| 1770: | ?> |
| 1771: | <div class="property-meta suburb-name"><?php echo esc_html( $suburb ); ?></div> |
| 1772: | <?php |
| 1773: | } |
| 1774: | |
| 1775: | |
| 1776: | if ( 'on' === $d_street && $property->show_street_address() ) { |
| 1777: | ?> |
| 1778: | <div class="property-meta street-name"><?php echo wp_kses_post( $property->get_formatted_property_address() ); ?></div> |
| 1779: | <?php |
| 1780: | } |
| 1781: | } |
| 1782: | |
| 1783: | |
| 1784: | |
| 1785: | |
| 1786: | |
| 1787: | |
| 1788: | |
| 1789: | |
| 1790: | |
| 1791: | |
| 1792: | |
| 1793: | |
| 1794: | function epl_sorting_options( $post_type = null ) { |
| 1795: | |
| 1796: | if ( is_null( $post_type ) ) { |
| 1797: | $post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : 'property'; |
| 1798: | } |
| 1799: | |
| 1800: | return apply_filters( |
| 1801: | 'epl_sorting_options', |
| 1802: | array( |
| 1803: | array( |
| 1804: | 'id' => 'high', |
| 1805: | 'label' => __( 'Price: High to Low', 'easy-property-listings' ), |
| 1806: | 'type' => 'meta', |
| 1807: | 'key' => 'property_price_global', |
| 1808: | 'order' => 'DESC', |
| 1809: | 'orderby' => 'meta_value_num', |
| 1810: | ), |
| 1811: | array( |
| 1812: | 'id' => 'low', |
| 1813: | 'label' => __( 'Price: Low to High', 'easy-property-listings' ), |
| 1814: | 'type' => 'meta', |
| 1815: | 'key' => 'property_price_global', |
| 1816: | 'order' => 'ASC', |
| 1817: | 'orderby' => 'meta_value_num', |
| 1818: | |
| 1819: | ), |
| 1820: | array( |
| 1821: | 'id' => 'new', |
| 1822: | 'label' => __( 'Date: Newest First', 'easy-property-listings' ), |
| 1823: | 'type' => 'post', |
| 1824: | 'key' => 'post_date', |
| 1825: | 'order' => 'DESC', |
| 1826: | |
| 1827: | ), |
| 1828: | array( |
| 1829: | 'id' => 'old', |
| 1830: | 'label' => __( 'Date: Oldest First', 'easy-property-listings' ), |
| 1831: | 'type' => 'post', |
| 1832: | 'key' => 'post_date', |
| 1833: | 'order' => 'ASC', |
| 1834: | ), |
| 1835: | array( |
| 1836: | 'id' => 'status_asc', |
| 1837: | 'label' => __( 'Status: Current First', 'easy-property-listings' ), |
| 1838: | 'type' => 'meta', |
| 1839: | 'key' => 'property_status', |
| 1840: | 'order' => 'ASC', |
| 1841: | 'orderby' => 'meta_value', |
| 1842: | |
| 1843: | ), |
| 1844: | array( |
| 1845: | 'id' => 'status_desc', |
| 1846: | 'label' => __( 'Status: Sold/Leased First', 'easy-property-listings' ), |
| 1847: | 'type' => 'meta', |
| 1848: | 'key' => 'property_status', |
| 1849: | 'order' => 'DESC', |
| 1850: | 'orderby' => 'meta_value', |
| 1851: | |
| 1852: | ), |
| 1853: | array( |
| 1854: | 'id' => 'location_asc', |
| 1855: | 'label' => epl_labels( 'label_suburb' ) . __( ': A-Z', 'easy-property-listings' ), |
| 1856: | 'type' => 'meta', |
| 1857: | 'key' => 'property_address_suburb', |
| 1858: | 'order' => 'ASC', |
| 1859: | 'orderby' => 'meta_value', |
| 1860: | |
| 1861: | ), |
| 1862: | array( |
| 1863: | 'id' => 'location_desc', |
| 1864: | 'label' => epl_labels( 'label_suburb' ) . __( ': Z-A', 'easy-property-listings' ), |
| 1865: | 'type' => 'meta', |
| 1866: | 'key' => 'property_address_suburb', |
| 1867: | 'order' => 'DESC', |
| 1868: | 'orderby' => 'meta_value', |
| 1869: | |
| 1870: | ), |
| 1871: | array( |
| 1872: | 'id' => 'title', |
| 1873: | 'label' => __( 'Title', 'easy-property-listings' ), |
| 1874: | 'type' => 'post', |
| 1875: | 'key' => 'post_title', |
| 1876: | 'order' => 'ASC', |
| 1877: | |
| 1878: | ), |
| 1879: | ) |
| 1880: | ); |
| 1881: | } |
| 1882: | |
| 1883: | |
| 1884: | |
| 1885: | |
| 1886: | |
| 1887: | |
| 1888: | |
| 1889: | |
| 1890: | |
| 1891: | function epl_tools_utility_wrapper( $attributes = array() ) { |
| 1892: | |
| 1893: | |
| 1894: | do_action( 'epl_archive_utility_wrap_start', $attributes ); |
| 1895: | |
| 1896: | do_action( 'epl_add_custom_menus', $attributes ); |
| 1897: | |
| 1898: | |
| 1899: | do_action( 'epl_archive_utility_wrap_end', $attributes ); |
| 1900: | } |
| 1901: | add_action( 'epl_property_loop_start', 'epl_tools_utility_wrapper', 10 ); |
| 1902: | |
| 1903: | |
| 1904: | |
| 1905: | |
| 1906: | |
| 1907: | |
| 1908: | |
| 1909: | |
| 1910: | |
| 1911: | |
| 1912: | |
| 1913: | |
| 1914: | function epl_listing_toolbar_items( $attributes = array(), $args = array() ) { |
| 1915: | echo get_epl_listing_toolbar_items( $attributes, $args ); |
| 1916: | } |
| 1917: | add_action( 'epl_add_custom_menus', 'epl_listing_toolbar_items', 10, 2 ); |
| 1918: | |
| 1919: | |
| 1920: | |
| 1921: | |
| 1922: | |
| 1923: | |
| 1924: | |
| 1925: | |
| 1926: | |
| 1927: | |
| 1928: | |
| 1929: | |
| 1930: | function get_epl_listing_toolbar_items( $attributes = array(), $args = array() ) { |
| 1931: | |
| 1932: | $defaults = array( |
| 1933: | 'switch_views', |
| 1934: | 'sorting_tool', |
| 1935: | ); |
| 1936: | |
| 1937: | $tools = apply_filters( 'epl_listing_toolbar_items', $defaults ); |
| 1938: | |
| 1939: | ob_start(); |
| 1940: | |
| 1941: | |
| 1942: | if ( ! empty( $defaults ) ) { |
| 1943: | ?> |
| 1944: | <div class="epl-loop-tools epl-loop-tools-switch-sort epl-switching-sorting-wrap"> |
| 1945: | <?php |
| 1946: | |
| 1947: | foreach ( $tools as $tool ) { |
| 1948: | |
| 1949: | if ( ! empty( $args ) && ! in_array( $tool, $args, true ) ) { |
| 1950: | continue; |
| 1951: | } |
| 1952: | |
| 1953: | switch ( $tool ) { |
| 1954: | |
| 1955: | case 'switch_views': |
| 1956: | do_action( 'epl_switch_views', $attributes ); |
| 1957: | break; |
| 1958: | |
| 1959: | case 'sorting_tool': |
| 1960: | do_action( 'epl_sorting_tool', $attributes ); |
| 1961: | break; |
| 1962: | |
| 1963: | default: |
| 1964: | |
| 1965: | do_action( 'epl_listing_toolbar_' . $tool, $attributes ); |
| 1966: | break; |
| 1967: | } |
| 1968: | } |
| 1969: | ?> |
| 1970: | </div> |
| 1971: | <?php |
| 1972: | } |
| 1973: | return ob_get_clean(); |
| 1974: | } |
| 1975: | |
| 1976: | |
| 1977: | |
| 1978: | |
| 1979: | |
| 1980: | |
| 1981: | function epl_switch_views() { |
| 1982: | ?> |
| 1983: | <div class="epl-loop-tool epl-tool-switch epl-switch-view"> |
| 1984: | <ul> |
| 1985: | <li title="<?php echo esc_attr( apply_filters( 'epl_switch_views_sorting_title_list', __( 'List', 'easy-property-listings' ) ) ); ?>" class="epl-current-view view-list" data-view="list"> |
| 1986: | </li> |
| 1987: | <li title="<?php echo esc_attr( apply_filters( 'epl_switch_views_sorting_title_grid', __( 'Grid', 'easy-property-listings' ) ) ); ?>" class="view-grid" data-view="grid"> |
| 1988: | </li> |
| 1989: | </ul> |
| 1990: | </div> |
| 1991: | <?php |
| 1992: | } |
| 1993: | add_action( 'epl_switch_views', 'epl_switch_views' ); |
| 1994: | |
| 1995: | |
| 1996: | |
| 1997: | |
| 1998: | |
| 1999: | |
| 2000: | |
| 2001: | |
| 2002: | |
| 2003: | |
| 2004: | |
| 2005: | |
| 2006: | |
| 2007: | |
| 2008: | function epl_sorting_tool( $attributes = array() ) { |
| 2009: | |
| 2010: | $instance_id = ! empty( $attributes['instance_id'] ) ? sanitize_text_field( $attributes['instance_id'] ) : '1'; |
| 2011: | $sortby = ''; |
| 2012: | $set_instance_id = ''; |
| 2013: | if ( ! empty( $_GET['sortby'] ) ) { |
| 2014: | $sortby = sanitize_text_field( wp_unslash( $_GET['sortby'] ) ); |
| 2015: | } |
| 2016: | if ( ! empty( $_GET['instance_id'] ) ) { |
| 2017: | $set_instance_id = sanitize_text_field( wp_unslash( $_GET['instance_id'] ) ); |
| 2018: | } |
| 2019: | $sorters = epl_sorting_options(); |
| 2020: | $id = ! empty( $instance_id ) ? $instance_id : '1'; |
| 2021: | ?> |
| 2022: | |
| 2023: | <div class="epl-loop-tool epl-tool-sorting epl-properties-sorting epl-clearfix"> |
| 2024: | <select aria-label="<?php esc_attr_e( 'Sort Listings', 'easy-property-listings' ); ?>" class="epl-sort-listings" id="epl-sort-listings-<?php echo esc_attr( $instance_id ); ?>" data-instance-id="<?php echo esc_attr( $instance_id ); ?>"> |
| 2025: | <option <?php selected( $sortby, '' ); ?> value=""> |
| 2026: | <?php echo esc_html( apply_filters( 'epl_switch_views_sorting_title_sort', __( 'Sort', 'easy-property-listings' ) ) ); ?> |
| 2027: | </option> |
| 2028: | <?php |
| 2029: | foreach ( $sorters as $sorter ) { |
| 2030: | |
| 2031: | if ( ! empty( $instance_id ) ) { |
| 2032: | $sortbyinstance = $set_instance_id . '_' . $sortby; |
| 2033: | $sorter_id = $instance_id . '_' . $sorter['id']; |
| 2034: | } else { |
| 2035: | $sortbyinstance = $sortby; |
| 2036: | $sorter_id = $sorter['id']; |
| 2037: | } |
| 2038: | ?> |
| 2039: | <option <?php selected( $sortbyinstance, $sorter_id ); ?> value="<?php echo esc_attr( $sorter['id'] ); ?>"> |
| 2040: | <?php echo esc_html( $sorter['label'] ); ?> |
| 2041: | </option> |
| 2042: | <?php |
| 2043: | } |
| 2044: | ?> |
| 2045: | </select> |
| 2046: | </div> |
| 2047: | <?php |
| 2048: | } |
| 2049: | add_action( 'epl_sorting_tool', 'epl_sorting_tool' ); |
| 2050: | |
| 2051: | |
| 2052: | |
| 2053: | |
| 2054: | |
| 2055: | |
| 2056: | |
| 2057: | function epl_sorting_tabs() { |
| 2058: | $sortby = ''; |
| 2059: | if ( ! empty( $_GET['sortby'] ) ) { |
| 2060: | $sortby = sanitize_text_field( wp_unslash( $_GET['sortby'] ) ); |
| 2061: | } |
| 2062: | $sorters = epl_sorting_options(); |
| 2063: | |
| 2064: | global $wp; |
| 2065: | $get_data = $_GET; |
| 2066: | $get_data = array_map( 'sanitize_text_field', $get_data ); |
| 2067: | $current_url = home_url( add_query_arg( array( $get_data ), $wp->request ) ); |
| 2068: | ?> |
| 2069: | |
| 2070: | <div class="epl-loop-tool epl-tool-sorting-tabs epl-properties-sorting epl-clearfix"> |
| 2071: | <ul id="epl-sort-tabs-listings"> |
| 2072: | <?php |
| 2073: | foreach ( $sorters as $sorter ) { |
| 2074: | $href = epl_add_or_update_params( $current_url, 'sortby', $sorter['id'] ); |
| 2075: | $class = $sortby === $sorter['id'] ? 'epl-sortby-selected' : ''; |
| 2076: | ?> |
| 2077: | <li class="epl-sortby-list <?php echo esc_attr( $class ); ?>"> |
| 2078: | <a href="<?php echo esc_url( $href ); ?>"> |
| 2079: | <?php echo esc_html( $sorter['label'] ); ?> |
| 2080: | </a> |
| 2081: | </li> |
| 2082: | <?php |
| 2083: | } |
| 2084: | ?> |
| 2085: | </ul> |
| 2086: | </div> |
| 2087: | <?php |
| 2088: | } |
| 2089: | |
| 2090: | |
| 2091: | |
| 2092: | |
| 2093: | |
| 2094: | |
| 2095: | |
| 2096: | |
| 2097: | |
| 2098: | |
| 2099: | |
| 2100: | |
| 2101: | function epl_add_or_update_params( $url, $key, $value ) { |
| 2102: | |
| 2103: | if ( empty( $url ) ) { |
| 2104: | return $url; |
| 2105: | } |
| 2106: | |
| 2107: | $a = wp_parse_url( $url ); |
| 2108: | $query = isset( $a['query'] ) ? $a['query'] : ''; |
| 2109: | parse_str( $query, $params ); |
| 2110: | $params[ $key ] = $value; |
| 2111: | $query = http_build_query( $params ); |
| 2112: | $result = ''; |
| 2113: | if ( $a['scheme'] ) { |
| 2114: | $result .= $a['scheme'] . ':'; |
| 2115: | } |
| 2116: | if ( $a['host'] ) { |
| 2117: | $result .= '//' . $a['host']; |
| 2118: | } |
| 2119: | if ( ! empty( $a['port'] ) ) { |
| 2120: | $result .= ':' . $a['port']; |
| 2121: | } |
| 2122: | if ( $a['path'] ) { |
| 2123: | $result .= $a['path']; |
| 2124: | } |
| 2125: | if ( $query ) { |
| 2126: | $result .= '?' . $query; |
| 2127: | } |
| 2128: | return $result; |
| 2129: | } |
| 2130: | |
| 2131: | |
| 2132: | |
| 2133: | |
| 2134: | |
| 2135: | |
| 2136: | |
| 2137: | |
| 2138: | |
| 2139: | |
| 2140: | |
| 2141: | |
| 2142: | |
| 2143: | |
| 2144: | |
| 2145: | |
| 2146: | |
| 2147: | function epl_get_sorter_query_args( $sorter ) { |
| 2148: | $order = isset( $sorter['order'] ) && 'ASC' === strtoupper( $sorter['order'] ) ? 'ASC' : 'DESC'; |
| 2149: | $is_meta = isset( $sorter['type'] ) && 'meta' === $sorter['type']; |
| 2150: | $key = isset( $sorter['key'] ) ? $sorter['key'] : ''; |
| 2151: | $primary = $is_meta ? ( isset( $sorter['orderby'] ) ? $sorter['orderby'] : 'meta_value' ) : $key; |
| 2152: | |
| 2153: | $args = array( 'order' => $order ); |
| 2154: | |
| 2155: | if ( $is_meta ) { |
| 2156: | $args['meta_key'] = $key; |
| 2157: | } |
| 2158: | |
| 2159: | if ( ! is_string( $primary ) || '' === $primary || false !== strpos( trim( $primary ), ' ' ) || in_array( $primary, array( 'rand', 'none' ), true ) || 0 === strpos( $primary, 'RAND(' ) ) { |
| 2160: | $args['orderby'] = $primary; |
| 2161: | return $args; |
| 2162: | } |
| 2163: | |
| 2164: | $orderby = array( $primary => $order ); |
| 2165: | |
| 2166: | if ( in_array( $primary, array( 'date', 'post_date' ), true ) ) { |
| 2167: | $orderby['ID'] = $order; |
| 2168: | } elseif ( 'ID' !== $primary ) { |
| 2169: | $orderby['date'] = 'DESC'; |
| 2170: | $orderby['ID'] = 'DESC'; |
| 2171: | } |
| 2172: | |
| 2173: | |
| 2174: | |
| 2175: | |
| 2176: | |
| 2177: | |
| 2178: | |
| 2179: | |
| 2180: | |
| 2181: | $args['orderby'] = apply_filters( 'epl_sorter_orderby', $orderby, $sorter ); |
| 2182: | |
| 2183: | return $args; |
| 2184: | } |
| 2185: | |
| 2186: | |
| 2187: | |
| 2188: | |
| 2189: | |
| 2190: | |
| 2191: | |
| 2192: | |
| 2193: | |
| 2194: | function epl_archive_sorting( $query ) { |
| 2195: | $post_types_sold = array( 'property', 'land', 'commercial', 'business', 'commercial_land', 'location_profile', 'rural' ); |
| 2196: | $post_types_rental = array( 'rental' ); |
| 2197: | |
| 2198: | if ( ! $query->is_main_query() ) { |
| 2199: | return; |
| 2200: | } |
| 2201: | |
| 2202: | if ( is_post_type_archive( $post_types_sold ) || is_post_type_archive( $post_types_rental ) || is_tax( 'location' ) || is_tax( 'tax_feature' ) || is_tax( 'tax_business_listing' ) || epl_is_search() ) { |
| 2203: | |
| 2204: | if ( ! empty( $_GET['sortby'] ) ) { |
| 2205: | |
| 2206: | $orderby = sanitize_text_field( wp_unslash( $_GET['sortby'] ) ); |
| 2207: | $sorters = epl_sorting_options( $query->get( 'post_type' ) ); |
| 2208: | |
| 2209: | foreach ( $sorters as $sorter ) { |
| 2210: | |
| 2211: | if ( $orderby === $sorter['id'] ) { |
| 2212: | |
| 2213: | foreach ( epl_get_sorter_query_args( $sorter ) as $arg => $value ) { |
| 2214: | $query->set( $arg, $value ); |
| 2215: | } |
| 2216: | break; |
| 2217: | } |
| 2218: | } |
| 2219: | } |
| 2220: | } |
| 2221: | } |
| 2222: | add_action( 'pre_get_posts', 'epl_archive_sorting' ); |
| 2223: | |
| 2224: | |
| 2225: | |
| 2226: | |
| 2227: | |
| 2228: | |
| 2229: | |
| 2230: | |
| 2231: | |
| 2232: | |
| 2233: | |
| 2234: | function epl_author_tabs( $epl_author = null ) { |
| 2235: | |
| 2236: | if ( is_null( $epl_author ) ) { |
| 2237: | global $epl_author; |
| 2238: | } |
| 2239: | $author_tabs = array( |
| 2240: | 'author_id' => __( 'About', 'easy-property-listings' ), |
| 2241: | 'description' => __( 'Bio', 'easy-property-listings' ), |
| 2242: | 'video' => __( 'Video', 'easy-property-listings' ), |
| 2243: | 'contact_form' => __( 'Contact', 'easy-property-listings' ), |
| 2244: | ); |
| 2245: | $author_tabs = apply_filters( 'epl_author_tabs', $author_tabs, $epl_author ); |
| 2246: | return $author_tabs; |
| 2247: | } |
| 2248: | |
| 2249: | |
| 2250: | |
| 2251: | |
| 2252: | |
| 2253: | |
| 2254: | |
| 2255: | |
| 2256: | function epl_author_class( $classes ) { |
| 2257: | $classes = explode( ' ', $classes . ' epl-author-box author-box' ); |
| 2258: | $classes = array_filter( array_unique( $classes ) ); |
| 2259: | $classes = apply_filters( 'epl_author_class', $classes ); |
| 2260: | if ( ! empty( $classes ) ) { |
| 2261: | $classes = implode( ' ', $classes ); |
| 2262: | echo esc_attr( $classes ); |
| 2263: | } |
| 2264: | } |
| 2265: | |
| 2266: | |
| 2267: | |
| 2268: | |
| 2269: | |
| 2270: | |
| 2271: | |
| 2272: | |
| 2273: | |
| 2274: | |
| 2275: | function epl_author_tab_author_id( $epl_author = array() ) { |
| 2276: | |
| 2277: | if ( empty( $epl_author ) ) { |
| 2278: | global $epl_author; |
| 2279: | } |
| 2280: | |
| 2281: | $permalink = apply_filters( 'epl_author_profile_link', get_author_posts_url( $epl_author->author_id ), $epl_author ); |
| 2282: | $author_title = apply_filters( 'epl_author_profile_title', get_the_author_meta( 'display_name', $epl_author->author_id ), $epl_author ); |
| 2283: | |
| 2284: | $arg_list = get_defined_vars(); |
| 2285: | |
| 2286: | ob_start(); |
| 2287: | |
| 2288: | epl_get_template_part( 'content-author-box-tab-details.php', $arg_list ); |
| 2289: | |
| 2290: | return ob_get_clean(); |
| 2291: | } |
| 2292: | |
| 2293: | |
| 2294: | |
| 2295: | |
| 2296: | |
| 2297: | |
| 2298: | |
| 2299: | |
| 2300: | function epl_author_tab_image( $epl_author = array() ) { |
| 2301: | |
| 2302: | if ( empty( $epl_author ) ) { |
| 2303: | global $epl_author; |
| 2304: | } |
| 2305: | |
| 2306: | if ( function_exists( 'get_avatar' ) ) { |
| 2307: | echo wp_kses_post( apply_filters( 'epl_author_tab_image', get_avatar( $epl_author->email, '150' ), $epl_author ) ); |
| 2308: | } |
| 2309: | } |
| 2310: | add_action( 'epl_author_thumbnail', 'epl_author_tab_image', 10, 2 ); |
| 2311: | |
| 2312: | |
| 2313: | |
| 2314: | |
| 2315: | |
| 2316: | |
| 2317: | |
| 2318: | |
| 2319: | function epl_author_tab_description( $epl_author = array() ) { |
| 2320: | if ( empty( $epl_author ) ) { |
| 2321: | global $epl_author; |
| 2322: | } |
| 2323: | echo wp_kses_post( $epl_author->get_description_html() ); |
| 2324: | } |
| 2325: | |
| 2326: | |
| 2327: | |
| 2328: | |
| 2329: | |
| 2330: | |
| 2331: | |
| 2332: | |
| 2333: | function epl_author_tab_video( $epl_author = array() ) { |
| 2334: | if ( empty( $epl_author ) ) { |
| 2335: | global $epl_author; |
| 2336: | } |
| 2337: | $video_html = $epl_author->get_video_html(); |
| 2338: | if ( ! empty( $video_html ) ) { |
| 2339: | echo '<div class="epl-author-video author-video epl-video-container">' . $video_html . '</div>'; |
| 2340: | } |
| 2341: | } |
| 2342: | |
| 2343: | |
| 2344: | |
| 2345: | |
| 2346: | |
| 2347: | |
| 2348: | |
| 2349: | |
| 2350: | function epl_author_tab_contact_form( $epl_author = array() ) { |
| 2351: | if ( empty( $epl_author ) ) { |
| 2352: | global $epl_author; |
| 2353: | } |
| 2354: | echo $epl_author->get_author_contact_form(); |
| 2355: | } |
| 2356: | |
| 2357: | |
| 2358: | |
| 2359: | |
| 2360: | |
| 2361: | |
| 2362: | function epl_archive_utility_wrap_before() { |
| 2363: | echo '<div class="epl-loop-tools-wrap epl-archive-utility-wrapper epl-clearfix">'; |
| 2364: | } |
| 2365: | add_action( 'epl_archive_utility_wrap_start', 'epl_archive_utility_wrap_before' ); |
| 2366: | |
| 2367: | |
| 2368: | |
| 2369: | |
| 2370: | |
| 2371: | |
| 2372: | function epl_archive_utility_wrap_after() { |
| 2373: | echo '</div>'; |
| 2374: | } |
| 2375: | add_action( 'epl_archive_utility_wrap_end', 'epl_archive_utility_wrap_after' ); |
| 2376: | |
| 2377: | |
| 2378: | |
| 2379: | |
| 2380: | |
| 2381: | |
| 2382: | |
| 2383: | |
| 2384: | function epl_property_gallery() { |
| 2385: | |
| 2386: | $d_gallery = (int) epl_get_option( 'display_single_gallery' ); |
| 2387: | |
| 2388: | $d_gallery_n = epl_get_option( 'display_gallery_n' ); |
| 2389: | |
| 2390: | if ( 1 !== $d_gallery ) { |
| 2391: | return; |
| 2392: | } |
| 2393: | |
| 2394: | |
| 2395: | |
| 2396: | |
| 2397: | |
| 2398: | |
| 2399: | |
| 2400: | |
| 2401: | |
| 2402: | |
| 2403: | |
| 2404: | $custom = apply_filters( 'epl_property_gallery_html', null, get_the_ID() ); |
| 2405: | if ( null !== $custom ) { |
| 2406: | echo $custom; |
| 2407: | return; |
| 2408: | } |
| 2409: | |
| 2410: | $attachments = get_children( |
| 2411: | array( |
| 2412: | 'post_parent' => get_the_ID(), |
| 2413: | 'post_type' => 'attachment', |
| 2414: | 'post_mime_type' => 'image', |
| 2415: | ) |
| 2416: | ); |
| 2417: | |
| 2418: | if ( $attachments ) { |
| 2419: | ?> |
| 2420: | |
| 2421: | <div class="epl-gallery property-gallery"> |
| 2422: | <!-- Gallery --> |
| 2423: | <div class="epl-gallery-entry entry-gallery epl-clearfix"> |
| 2424: | <?php |
| 2425: | $gallery_shortcode = '[gallery columns="' . $d_gallery_n . '" link="file"]'; |
| 2426: | $gallery = apply_filters( 'epl_property_gallery_shortcode', $gallery_shortcode, $d_gallery_n ); |
| 2427: | echo do_shortcode( $gallery ); |
| 2428: | ?> |
| 2429: | </div> |
| 2430: | </div> |
| 2431: | <?php |
| 2432: | } |
| 2433: | } |
| 2434: | add_action( 'epl_property_gallery', 'epl_property_gallery' ); |
| 2435: | |
| 2436: | |
| 2437: | |
| 2438: | |
| 2439: | |
| 2440: | |
| 2441: | |
| 2442: | function epl_template_path() { |
| 2443: | return apply_filters( 'epl_template_path', 'easypropertylistings/' ); |
| 2444: | } |
| 2445: | |
| 2446: | |
| 2447: | |
| 2448: | |
| 2449: | |
| 2450: | |
| 2451: | function epl_buttons_wrapper_before() { |
| 2452: | echo '<div class="epl-button-wrapper epl-clearfix">'; |
| 2453: | } |
| 2454: | |
| 2455: | |
| 2456: | |
| 2457: | |
| 2458: | |
| 2459: | |
| 2460: | function epl_buttons_wrapper_after() { |
| 2461: | echo '</div>'; |
| 2462: | } |
| 2463: | add_action( 'epl_buttons_single_property', 'epl_buttons_wrapper_before', 1 ); |
| 2464: | add_action( 'epl_buttons_single_property', 'epl_buttons_wrapper_after', 99 ); |
| 2465: | |
| 2466: | |
| 2467: | |
| 2468: | |
| 2469: | |
| 2470: | |
| 2471: | |
| 2472: | |
| 2473: | |
| 2474: | |
| 2475: | |
| 2476: | |
| 2477: | |
| 2478: | |
| 2479: | |
| 2480: | |
| 2481: | function epl_create_ical_file( $start = '', $end = '', $name = '', $description = '', $location = '', $post_id = null ) { |
| 2482: | |
| 2483: | if ( is_null( $post_id ) ) { |
| 2484: | $post_id = get_the_ID(); |
| 2485: | } |
| 2486: | |
| 2487: | $description = str_replace( "\n", "\\n", str_replace( ';', '\;', str_replace( ',', '\,', $description ) ) ); |
| 2488: | $uid = $post_id . time(); |
| 2489: | $url = get_permalink( $post_id ); |
| 2490: | $prodid = '-//' . get_bloginfo( 'name' ) . '/EPL//NONSGML v1.0//EN'; |
| 2491: | $file_name = sanitize_file_name( $name ); |
| 2492: | if ( '' === $file_name ) { |
| 2493: | $file_name = 'event'; |
| 2494: | } |
| 2495: | $args = get_defined_vars(); |
| 2496: | $args = apply_filters( 'epl_ical_args', $args ); |
| 2497: | $data = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:" . $args['prodid'] . "\nMETHOD:PUBLISH\nBEGIN:VEVENT\nDTSTART:" . gmdate( 'Ymd\THis', strtotime( $args['start'] ) ) . "\nDTEND:" . gmdate( 'Ymd\THis', strtotime( $args['end'] ) ) . "\nLOCATION:" . $args['location'] . "\nURL:" . $args['url'] . "\nTRANSP:OPAQUE\nSEQUENCE:0\nUID:" . $args['uid'] . "\nDTSTAMP:" . gmdate( 'Ymd\THis\Z' ) . "\nSUMMARY:" . $args['name'] . "\nDESCRIPTION:" . $args['description'] . "\nPRIORITY:1\nCLASS:PUBLIC\nBEGIN:VALARM\nTRIGGER:-PT10080M\nACTION:DISPLAY\nDESCRIPTION:Reminder\nEND:VALARM\nEND:VEVENT\nEND:VCALENDAR\n"; |
| 2498: | |
| 2499: | header( 'Content-type:text/calendar' ); |
| 2500: | header( 'Content-Disposition: attachment; filename="' . $file_name . '.ics"' ); |
| 2501: | Header( 'Content-Length: ' . strlen( $data ) ); |
| 2502: | Header( 'Connection: close' ); |
| 2503: | echo $data; |
| 2504: | die; |
| 2505: | } |
| 2506: | |
| 2507: | |
| 2508: | |
| 2509: | |
| 2510: | |
| 2511: | |
| 2512: | |
| 2513: | |
| 2514: | |
| 2515: | |
| 2516: | function epl_process_event_cal_request() { |
| 2517: | global $epl_settings; |
| 2518: | if ( ! isset( $_GET['propid'], $_GET['epl_cal_dl'], $_GET['cal'], $_GET['dt'] ) || 1 !== (int) $_GET['epl_cal_dl'] ) { |
| 2519: | return; |
| 2520: | } |
| 2521: | |
| 2522: | $post_id = absint( wp_unslash( $_GET['propid'] ) ); |
| 2523: | if ( $post_id <= 0 || 'ical' !== sanitize_text_field( wp_unslash( $_GET['cal'] ) ) ) { |
| 2524: | return; |
| 2525: | } |
| 2526: | |
| 2527: | $item = base64_decode( sanitize_text_field( wp_unslash( $_GET['dt'] ) ), true ); |
| 2528: | if ( false === $item ) { |
| 2529: | return; |
| 2530: | } |
| 2531: | |
| 2532: | $item = trim( html_entity_decode( $item, ENT_QUOTES, 'UTF-8' ) ); |
| 2533: | if ( '' === $item || ! isset( $item[0] ) || ! is_numeric( $item[0] ) ) { |
| 2534: | return; |
| 2535: | } |
| 2536: | |
| 2537: | $token = isset( $_GET['k'] ) ? sanitize_text_field( wp_unslash( $_GET['k'] ) ) : ''; |
| 2538: | $valid = ! empty( $token ) && hash_equals( epl_get_ical_download_token( $post_id, $item ), $token ); |
| 2539: | |
| 2540: | $allow_legacy_access = apply_filters( 'epl_allow_legacy_ical_access', false, $post_id, $item ); |
| 2541: | if ( ! $valid && ! $allow_legacy_access && ! current_user_can( 'manage_options' ) ) { |
| 2542: | return; |
| 2543: | } |
| 2544: | |
| 2545: | $post = get_post( $post_id ); |
| 2546: | if ( is_null( $post ) || 'publish' !== $post->post_status || ! in_array( $post->post_type, epl_get_core_post_types(), true ) || post_password_required( $post_id ) ) { |
| 2547: | return; |
| 2548: | } |
| 2549: | |
| 2550: | $inspection_time = get_post_meta( $post_id, 'property_inspection_times', true ); |
| 2551: | if ( ! is_string( $inspection_time ) || '' === trim( $inspection_time ) ) { |
| 2552: | return; |
| 2553: | } |
| 2554: | |
| 2555: | $is_valid_inspection = false; |
| 2556: | $list = array_filter( explode( "\n", trim( $inspection_time ) ) ); |
| 2557: | foreach ( $list as $inspection_item ) { |
| 2558: | $inspection_item = trim( $inspection_item ); |
| 2559: | if ( '' === $inspection_item || ! isset( $inspection_item[0] ) || ! is_numeric( $inspection_item[0] ) ) { |
| 2560: | continue; |
| 2561: | } |
| 2562: | |
| 2563: | $timearr = explode( ' ', $inspection_item ); |
| 2564: | $endtime = current( $timearr ) . ' ' . end( $timearr ); |
| 2565: | $expired = strtotime( $endtime ) < epl_get_local_timestamp(); |
| 2566: | $expired = apply_filters( 'epl_maybe_delete_inspection', $expired, $endtime, $inspection_item ); |
| 2567: | if ( $expired ) { |
| 2568: | continue; |
| 2569: | } |
| 2570: | |
| 2571: | if ( $inspection_item === $item ) { |
| 2572: | $is_valid_inspection = true; |
| 2573: | break; |
| 2574: | } |
| 2575: | } |
| 2576: | |
| 2577: | if ( ! $is_valid_inspection ) { |
| 2578: | return; |
| 2579: | } |
| 2580: | |
| 2581: | $timearr = explode( ' ', $item ); |
| 2582: | $starttime = current( $timearr ); |
| 2583: | if ( isset( $timearr[1] ) ) { |
| 2584: | $starttime .= ' ' . $timearr[1]; |
| 2585: | } |
| 2586: | $endtime = current( $timearr ) . ' ' . end( $timearr ); |
| 2587: | |
| 2588: | $subject = $epl_settings['label_home_open'] . ' - ' . get_post_meta( $post_id, 'property_heading', true ); |
| 2589: | if ( isset( $_GET['event_type'] ) && 'auction' === sanitize_text_field( wp_unslash( $_GET['event_type'] ) ) ) { |
| 2590: | $subject = __( 'Auction', 'easy-property-listings' ) . ' - ' . get_post_meta( $post_id, 'property_heading', true ); |
| 2591: | } |
| 2592: | |
| 2593: | $address = ''; |
| 2594: | $prop_sub_num = get_post_meta( $post_id, 'property_address_sub_number', true ); |
| 2595: | if ( ! empty( $prop_sub_num ) ) { |
| 2596: | $address .= get_post_meta( $post_id, 'property_address_sub_number', true ) . '/'; |
| 2597: | } |
| 2598: | $address .= get_post_meta( $post_id, 'property_address_street_number', true ) . ' '; |
| 2599: | $address .= get_post_meta( $post_id, 'property_address_street', true ) . ' '; |
| 2600: | $address .= get_post_meta( $post_id, 'property_address_suburb', true ) . ', '; |
| 2601: | $address .= get_post_meta( $post_id, 'property_address_state', true ) . ' '; |
| 2602: | $address .= get_post_meta( $post_id, 'property_address_postal_code', true ); |
| 2603: | |
| 2604: | $description = wp_strip_all_tags( get_the_excerpt( $post ) ); |
| 2605: | $description = apply_filters( 'epl_ical_description', $description, $post_id, $post, $item ); |
| 2606: | |
| 2607: | epl_create_ical_file( $starttime, $endtime, $subject, $description, $address, $post_id ); |
| 2608: | } |
| 2609: | add_action( 'init', 'epl_process_event_cal_request' ); |
| 2610: | |
| 2611: | |
| 2612: | |
| 2613: | |
| 2614: | |
| 2615: | |
| 2616: | |
| 2617: | |
| 2618: | function epl_update_listing_coordinates() { |
| 2619: | |
| 2620: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 2621: | |
| 2622: | if ( ! current_user_can( 'manage_options' ) ) { |
| 2623: | wp_die( 'fail' ); |
| 2624: | } |
| 2625: | |
| 2626: | if ( ( ! isset( $_POST['listid'] ) || 0 === intval( $_POST['listid'] ) ) || empty( $_POST['coordinates'] ) ) { |
| 2627: | return; |
| 2628: | } |
| 2629: | $coordinates = rtrim( ltrim( sanitize_text_field( wp_unslash( $_POST['coordinates'] ) ), '(' ), ')' ); |
| 2630: | if ( update_post_meta( intval( wp_unslash( $_POST['listid'] ) ), 'property_address_coordinates', $coordinates ) ) { |
| 2631: | wp_die( 'success' ); |
| 2632: | } else { |
| 2633: | wp_die( 'fail' ); |
| 2634: | } |
| 2635: | } |
| 2636: | add_action( 'wp_ajax_epl_update_listing_coordinates', 'epl_update_listing_coordinates' ); |
| 2637: | |
| 2638: | |
| 2639: | |
| 2640: | |
| 2641: | |
| 2642: | |
| 2643: | |
| 2644: | |
| 2645: | |
| 2646: | |
| 2647: | |
| 2648: | |
| 2649: | |
| 2650: | |
| 2651: | |
| 2652: | |
| 2653: | function epl_get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) { |
| 2654: | $terms = get_the_terms( $id, $taxonomy ); |
| 2655: | |
| 2656: | if ( is_wp_error( $terms ) ) { |
| 2657: | return $terms; |
| 2658: | } |
| 2659: | |
| 2660: | if ( empty( $terms ) ) { |
| 2661: | return false; |
| 2662: | } |
| 2663: | |
| 2664: | foreach ( $terms as $term ) { |
| 2665: | |
| 2666: | $link = get_term_link( $term, $taxonomy ); |
| 2667: | if ( is_wp_error( $link ) ) { |
| 2668: | return $link; |
| 2669: | } |
| 2670: | |
| 2671: | if ( true === apply_filters( 'epl_features_taxonomy_link_filter', true ) ) { |
| 2672: | $term_links[] = '<li class="epl-tax-' . $taxonomy . ' ' . $term->slug . ' ">' . |
| 2673: | '<a href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>' |
| 2674: | . '</li>' . $sep; |
| 2675: | } else { |
| 2676: | $term_links[] = '<li class="epl-tax-' . $taxonomy . ' ' . $term->slug . ' ">' . $term->name . '</li>' . $sep; |
| 2677: | } |
| 2678: | } |
| 2679: | |
| 2680: | $term_links = apply_filters( "term_links-$taxonomy", $term_links ); |
| 2681: | |
| 2682: | $html = $before; |
| 2683: | foreach ( $term_links as $term_link ) { |
| 2684: | $html .= $term_link; |
| 2685: | } |
| 2686: | $html .= $after; |
| 2687: | |
| 2688: | return $html; |
| 2689: | } |
| 2690: | |
| 2691: | |
| 2692: | |
| 2693: | |
| 2694: | |
| 2695: | |
| 2696: | |
| 2697: | |
| 2698: | |
| 2699: | function get_property_meta( $key ) { |
| 2700: | global $property; |
| 2701: | return $property->get_property_meta( $key ); |
| 2702: | } |
| 2703: | |
| 2704: | |
| 2705: | |
| 2706: | |
| 2707: | |
| 2708: | |
| 2709: | |
| 2710: | |
| 2711: | |
| 2712: | function the_property_meta( $key ) { |
| 2713: | global $property; |
| 2714: | |
| 2715: | $value = $property->get_property_meta( $key ); |
| 2716: | if ( null === $value ) { |
| 2717: | $value = ''; |
| 2718: | } |
| 2719: | |
| 2720: | echo wp_kses_post( $value ); |
| 2721: | } |
| 2722: | |
| 2723: | |
| 2724: | |
| 2725: | |
| 2726: | |
| 2727: | |
| 2728: | |
| 2729: | |
| 2730: | |
| 2731: | |
| 2732: | |
| 2733: | function epl_template_class( $classname = false, $context = 'single' ) { |
| 2734: | |
| 2735: | if ( $classname ) { |
| 2736: | $classname = 'epl-template-' . $classname; |
| 2737: | } else { |
| 2738: | $classname = 'epl-template-blog'; |
| 2739: | } |
| 2740: | |
| 2741: | return apply_filters( 'epl_template_class', $classname, $context ); |
| 2742: | } |
| 2743: | |
| 2744: | |
| 2745: | |
| 2746: | |
| 2747: | |
| 2748: | |
| 2749: | |
| 2750: | |
| 2751: | function epl_pagination( $query = array() ) { |
| 2752: | global $epl_settings; |
| 2753: | $fancy_on = 1 === (int) epl_get_option( 'use_fancy_navigation', 0 ) ? 1 : 0; |
| 2754: | if ( $fancy_on ) { |
| 2755: | epl_fancy_pagination( $query ); |
| 2756: | } else { |
| 2757: | epl_wp_default_pagination( $query ); |
| 2758: | } |
| 2759: | } |
| 2760: | add_action( 'epl_pagination', 'epl_pagination' ); |
| 2761: | |
| 2762: | |
| 2763: | |
| 2764: | |
| 2765: | |
| 2766: | |
| 2767: | |
| 2768: | |
| 2769: | function epl_get_active_theme() { |
| 2770: | if ( function_exists( 'wp_get_theme' ) ) { |
| 2771: | $active_theme = wp_get_theme(); |
| 2772: | $active_theme = $active_theme->get( 'Name' ); |
| 2773: | |
| 2774: | } else { |
| 2775: | |
| 2776: | $active_theme = wp_get_theme(); |
| 2777: | } |
| 2778: | $active_theme = str_replace( ' ', '', strtolower( $active_theme ) ); |
| 2779: | return apply_filters( 'epl_active_theme', $active_theme ); |
| 2780: | } |
| 2781: | |
| 2782: | |
| 2783: | |
| 2784: | |
| 2785: | |
| 2786: | |
| 2787: | |
| 2788: | |
| 2789: | function epl_get_active_theme_name() { |
| 2790: | $epl_class_prefix = apply_filters( 'epl_active_theme_prefix', 'epl-active-theme-' ); |
| 2791: | $active_theme = epl_get_active_theme(); |
| 2792: | return apply_filters( 'epl_active_theme_name', $epl_class_prefix . $active_theme ); |
| 2793: | } |
| 2794: | |
| 2795: | |
| 2796: | |
| 2797: | |
| 2798: | |
| 2799: | |
| 2800: | |
| 2801: | |
| 2802: | function epl_get_shortcode_list() { |
| 2803: | return apply_filters( |
| 2804: | 'epl_get_shortcode_list', |
| 2805: | array( |
| 2806: | 'listing', |
| 2807: | 'listing_category', |
| 2808: | 'listing_open', |
| 2809: | 'listing_feature', |
| 2810: | 'listing_location', |
| 2811: | 'listing_auction', |
| 2812: | 'listing_advanced', |
| 2813: | ) |
| 2814: | ); |
| 2815: | } |
| 2816: | |
| 2817: | |
| 2818: | |
| 2819: | |
| 2820: | |
| 2821: | |
| 2822: | |
| 2823: | function epl_wp_doing_ajax() { |
| 2824: | |
| 2825: | if ( function_exists( 'wp_doing_ajax' ) ) { |
| 2826: | return wp_doing_ajax(); |
| 2827: | } else { |
| 2828: | return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); |
| 2829: | } |
| 2830: | } |
| 2831: | |
| 2832: | |
| 2833: | |
| 2834: | |
| 2835: | |
| 2836: | |
| 2837: | |
| 2838: | |
| 2839: | |
| 2840: | function epl_home_pagination_fix( $query ) { |
| 2841: | |
| 2842: | global $wp_query; |
| 2843: | $queried_post_type = isset( $query->query_vars['post_type'] ) ? (array) $query->query_vars['post_type'] : array(); |
| 2844: | $diff = array_diff( $queried_post_type, epl_get_core_post_types() ); |
| 2845: | |
| 2846: | if ( isset( $wp_query->query['paged'] ) && 0 === count( $diff ) ) { |
| 2847: | $query->set( 'paged', $wp_query->query['paged'] ); |
| 2848: | } |
| 2849: | |
| 2850: | $shortcodes = epl_get_shortcode_list(); |
| 2851: | |
| 2852: | if ( $query->get( 'is_epl_shortcode' ) && |
| 2853: | in_array( $query->get( 'epl_shortcode_name' ), $shortcodes, true ) && ! epl_wp_doing_ajax() ) { |
| 2854: | |
| 2855: | if ( isset( $_GET['pagination_id'] ) && $_GET['pagination_id'] === $query->get( 'instance_id' ) ) { |
| 2856: | $query->set( 'paged', $query->get( 'paged' ) ); |
| 2857: | } else { |
| 2858: | $query->set( 'paged', 1 ); |
| 2859: | } |
| 2860: | } |
| 2861: | } |
| 2862: | add_action( 'pre_get_posts', 'epl_home_pagination_fix', 99 ); |
| 2863: | |
| 2864: | |
| 2865: | |
| 2866: | |
| 2867: | |
| 2868: | |
| 2869: | function epl_property_widget_status_class() { |
| 2870: | global $property; |
| 2871: | echo 'epl-widget-status-' . esc_attr( $property->get_property_meta( 'property_status' ) ); |
| 2872: | } |
| 2873: | add_action( 'epl_property_widget_status_class', 'epl_property_widget_status_class' ); |
| 2874: | |
| 2875: | |
| 2876: | |
| 2877: | |
| 2878: | |
| 2879: | |
| 2880: | function epl_hide_map_from_front() { |
| 2881: | $epl_posts = epl_get_active_post_types(); |
| 2882: | $epl_posts = array_keys( $epl_posts ); |
| 2883: | |
| 2884: | global $post, $property; |
| 2885: | |
| 2886: | if ( is_single() && in_array( $post->post_type, $epl_posts, true ) ) { |
| 2887: | |
| 2888: | $hide_map = get_post_meta( $post->ID, 'property_address_hide_map', true ); |
| 2889: | if ( 'yes' === $hide_map ) { |
| 2890: | remove_all_actions( 'epl_property_map' ); |
| 2891: | } |
| 2892: | } |
| 2893: | } |
| 2894: | add_action( 'wp', 'epl_hide_map_from_front', 10 ); |
| 2895: | |
| 2896: | |
| 2897: | |
| 2898: | |
| 2899: | |
| 2900: | |
| 2901: | |
| 2902: | |
| 2903: | function epl_nopaging( $query ) { |
| 2904: | $restrict_paging = $query->get( 'epl_nopaging' ); |
| 2905: | if ( true === $restrict_paging ) { |
| 2906: | $query->set( 'paged', 1 ); |
| 2907: | } |
| 2908: | } |
| 2909: | add_action( 'pre_get_posts', 'epl_nopaging' ); |
| 2910: | |
| 2911: | |
| 2912: | |
| 2913: | |
| 2914: | |
| 2915: | |
| 2916: | function epl_hide_author_box_from_front() { |
| 2917: | $epl_posts = epl_get_active_post_types(); |
| 2918: | $epl_posts = array_keys( $epl_posts ); |
| 2919: | |
| 2920: | global $post, $property; |
| 2921: | |
| 2922: | if ( is_single() && in_array( $post->post_type, $epl_posts, true ) ) { |
| 2923: | |
| 2924: | $hide_author_box = get_post_meta( $post->ID, 'property_agent_hide_author_box', true ); |
| 2925: | if ( 'yes' === $hide_author_box ) { |
| 2926: | remove_all_actions( 'epl_single_author' ); |
| 2927: | } |
| 2928: | } |
| 2929: | } |
| 2930: | add_action( 'wp', 'epl_hide_author_box_from_front', 10 ); |
| 2931: | |
| 2932: | |
| 2933: | |
| 2934: | |
| 2935: | |
| 2936: | |
| 2937: | function epl_update_default_view() { |
| 2938: | |
| 2939: | $view = isset( $_POST['view'] ) ? sanitize_text_field( wp_unslash( $_POST['view'] ) ) : ''; |
| 2940: | |
| 2941: | if ( in_array( $view, array( 'list', 'grid' ), true ) ) { |
| 2942: | |
| 2943: | setcookie( 'preferredView', $view, 0, '/' ); |
| 2944: | } |
| 2945: | wp_die( 'success' ); |
| 2946: | } |
| 2947: | add_action( 'wp_ajax_epl_update_default_view', 'epl_update_default_view' ); |
| 2948: | add_action( 'wp_ajax_nopriv_epl_update_default_view', 'epl_update_default_view' ); |
| 2949: | |
| 2950: | |
| 2951: | |
| 2952: | |
| 2953: | |
| 2954: | |
| 2955: | |
| 2956: | function epl_the_content_filters() { |
| 2957: | |
| 2958: | if ( ! has_filter( 'epl_get_the_content', 'wptexturize' ) ) { |
| 2959: | |
| 2960: | add_filter( 'epl_get_the_content', 'wptexturize' ); |
| 2961: | add_filter( 'epl_get_the_content', 'convert_smilies' ); |
| 2962: | add_filter( 'epl_get_the_content', 'convert_chars' ); |
| 2963: | add_filter( 'epl_get_the_content', 'wpautop' ); |
| 2964: | add_filter( 'epl_get_the_content', 'shortcode_unautop' ); |
| 2965: | add_filter( 'epl_get_the_content', 'prepend_attachment' ); |
| 2966: | $vidembed = new WP_Embed(); |
| 2967: | add_filter( 'epl_get_the_content', array( &$vidembed, 'run_shortcode' ), 8 ); |
| 2968: | add_filter( 'epl_get_the_content', array( &$vidembed, 'autoembed' ), 8 ); |
| 2969: | add_filter( 'epl_get_the_content', 'do_shortcode', 11 ); |
| 2970: | add_filter( 'epl_get_the_content', 'do_blocks', 11 ); |
| 2971: | } |
| 2972: | |
| 2973: | add_filter( 'epl_get_the_excerpt', 'epl_trim_excerpt' ); |
| 2974: | } |
| 2975: | add_action( 'init', 'epl_the_content_filters', 1 ); |
| 2976: | |
| 2977: | |
| 2978: | |
| 2979: | |
| 2980: | |
| 2981: | |
| 2982: | function epl_compatibility_archive_class_callback() { |
| 2983: | $class = '-disable'; |
| 2984: | echo esc_attr( $class ); |
| 2985: | } |
| 2986: | |
| 2987: | |
| 2988: | |
| 2989: | |
| 2990: | |
| 2991: | |
| 2992: | function epl_apply_feeling_lucky_config() { |
| 2993: | |
| 2994: | global $epl_settings; |
| 2995: | |
| 2996: | $epl_posts = epl_get_active_post_types(); |
| 2997: | $epl_posts = array_keys( $epl_posts ); |
| 2998: | |
| 2999: | |
| 3000: | if ( 'on' === epl_get_option( 'epl_lucky_disable_single_thumb' ) ) { |
| 3001: | |
| 3002: | if ( is_single() && in_array( get_post_type(), $epl_posts, true ) ) { |
| 3003: | remove_all_actions( 'epl_property_featured_image' ); |
| 3004: | } |
| 3005: | } |
| 3006: | |
| 3007: | |
| 3008: | if ( 'on' === epl_get_option( 'epl_lucky_disable_theme_single_thumb' ) ) { |
| 3009: | |
| 3010: | if ( is_single() && in_array( get_post_type(), $epl_posts, true ) ) { |
| 3011: | add_filter( 'post_thumbnail_html', 'epl_remove_single_thumbnail', 20, 5 ); |
| 3012: | } |
| 3013: | } |
| 3014: | |
| 3015: | |
| 3016: | if ( 'on' === epl_get_option( 'epl_lucky_disable_archive_thumb' ) ) { |
| 3017: | |
| 3018: | if ( is_post_type_archive( $epl_posts ) ) { |
| 3019: | add_filter( 'post_thumbnail_html', 'epl_remove_archive_thumbnail', 20, 5 ); |
| 3020: | } |
| 3021: | } |
| 3022: | |
| 3023: | |
| 3024: | if ( 'on' === epl_get_option( 'epl_lucky_disable_epl_archive_thumb' ) ) { |
| 3025: | |
| 3026: | if ( is_post_type_archive( $epl_posts ) ) { |
| 3027: | remove_all_actions( 'epl_property_archive_featured_image' ); |
| 3028: | |
| 3029: | |
| 3030: | add_action( 'epl_compatibility_archive_class', 'epl_compatibility_archive_class_callback' ); |
| 3031: | } |
| 3032: | } |
| 3033: | } |
| 3034: | add_action( 'wp', 'epl_apply_feeling_lucky_config', 1 ); |
| 3035: | |
| 3036: | |
| 3037: | |
| 3038: | |
| 3039: | |
| 3040: | |
| 3041: | |
| 3042: | |
| 3043: | |
| 3044: | |
| 3045: | |
| 3046: | |
| 3047: | |
| 3048: | |
| 3049: | |
| 3050: | function epl_remove_archive_thumbnail( $html, $post_id, $post_thumbnail_id, $size, $attr ) { |
| 3051: | |
| 3052: | if ( is_admin() ) { |
| 3053: | return $html; |
| 3054: | } |
| 3055: | |
| 3056: | if ( is_epl_post_archive() ) { |
| 3057: | |
| 3058: | if ( |
| 3059: | doing_action( 'epl_property_archive_featured_image' ) || |
| 3060: | doing_action( 'epl_property_widgets_featured_image' ) || |
| 3061: | doing_action( 'epl_author_thumbnail' ) || |
| 3062: | doing_action( 'epl_author_widget_thumbnail' ) |
| 3063: | ) { |
| 3064: | |
| 3065: | } else { |
| 3066: | $html = ''; |
| 3067: | } |
| 3068: | } |
| 3069: | |
| 3070: | return $html; |
| 3071: | } |
| 3072: | |
| 3073: | |
| 3074: | |
| 3075: | |
| 3076: | |
| 3077: | |
| 3078: | |
| 3079: | |
| 3080: | |
| 3081: | |
| 3082: | |
| 3083: | |
| 3084: | |
| 3085: | |
| 3086: | function epl_remove_single_thumbnail( $html, $post_id, $post_thumbnail_id, $size, $attr ) { |
| 3087: | |
| 3088: | if ( is_admin() ) { |
| 3089: | return $html; |
| 3090: | } |
| 3091: | |
| 3092: | if ( is_epl_post() ) { |
| 3093: | |
| 3094: | if ( doing_action( 'epl_property_featured_image' ) || doing_action( 'epl_property_widgets_featured_image' ) ) { |
| 3095: | |
| 3096: | } else { |
| 3097: | $html = ''; |
| 3098: | } |
| 3099: | } |
| 3100: | return $html; |
| 3101: | } |
| 3102: | |
| 3103: | |
| 3104: | |
| 3105: | |
| 3106: | |
| 3107: | |
| 3108: | function epl_the_content() { |
| 3109: | |
| 3110: | global $property; |
| 3111: | $content = apply_filters( 'epl_get_the_content', get_the_content() ); |
| 3112: | echo str_replace( ']]>', ']]>', $content ); |
| 3113: | } |
| 3114: | add_action( 'epl_property_the_content', 'epl_the_content' ); |
| 3115: | |
| 3116: | |
| 3117: | |
| 3118: | |
| 3119: | |
| 3120: | |
| 3121: | |
| 3122: | |
| 3123: | |
| 3124: | |
| 3125: | |
| 3126: | function epl_feeling_lucky( $content ) { |
| 3127: | |
| 3128: | global $epl_settings; |
| 3129: | |
| 3130: | if ( is_admin() ) { |
| 3131: | return $content; |
| 3132: | } |
| 3133: | |
| 3134: | if ( ! isset( $epl_settings['epl_feeling_lucky'] ) || 'on' !== $epl_settings['epl_feeling_lucky'] ) { |
| 3135: | return $content; |
| 3136: | } |
| 3137: | |
| 3138: | $epl_posts = epl_get_active_post_types(); |
| 3139: | $epl_posts = array_keys( $epl_posts ); |
| 3140: | |
| 3141: | if ( is_single() && in_array( get_post_type(), $epl_posts, true ) ) { |
| 3142: | ob_start(); |
| 3143: | do_action( 'epl_property_single' ); |
| 3144: | return ob_get_clean(); |
| 3145: | } elseif ( is_post_type_archive( $epl_posts ) ) { |
| 3146: | ob_start(); |
| 3147: | do_action( 'epl_property_blog' ); |
| 3148: | |
| 3149: | |
| 3150: | |
| 3151: | echo ob_get_clean(); |
| 3152: | |
| 3153: | } else { |
| 3154: | return $content; |
| 3155: | } |
| 3156: | } |
| 3157: | |
| 3158: | add_filter( 'the_content', 'epl_feeling_lucky' ); |
| 3159: | |
| 3160: | |
| 3161: | |
| 3162: | |
| 3163: | |
| 3164: | |
| 3165: | |
| 3166: | |
| 3167: | |
| 3168: | |
| 3169: | function epl_trim_excerpt( $text = '' ) { |
| 3170: | |
| 3171: | $raw_excerpt = $text; |
| 3172: | if ( empty( $text ) ) { |
| 3173: | $text = get_the_content( '' ); |
| 3174: | |
| 3175: | $text = strip_shortcodes( $text ); |
| 3176: | |
| 3177: | $text = apply_filters( 'epl_get_the_content', $text ); |
| 3178: | $text = str_replace( ']]>', ']]>', $text ); |
| 3179: | |
| 3180: | $excerpt_length = apply_filters( 'excerpt_length', 55 ); |
| 3181: | $excerpt_more = apply_filters( 'excerpt_more', ' […]' ); |
| 3182: | $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); |
| 3183: | |
| 3184: | } |
| 3185: | return apply_filters( 'epl_trim_excerpt', $text, $raw_excerpt ); |
| 3186: | } |
| 3187: | |
| 3188: | |
| 3189: | |
| 3190: | |
| 3191: | |
| 3192: | |
| 3193: | function epl_the_excerpt() { |
| 3194: | echo wp_kses_post( apply_filters( 'epl_the_excerpt', epl_get_the_excerpt() ) ); |
| 3195: | } |
| 3196: | |
| 3197: | |
| 3198: | |
| 3199: | |
| 3200: | |
| 3201: | |
| 3202: | |
| 3203: | |
| 3204: | |
| 3205: | |
| 3206: | |
| 3207: | function epl_get_the_excerpt( $post = null ) { |
| 3208: | |
| 3209: | if ( is_bool( $post ) ) { |
| 3210: | _deprecated_argument( __FUNCTION__, '2.3' ); |
| 3211: | } |
| 3212: | |
| 3213: | if ( $post instanceof WP_Post ) { |
| 3214: | $post = get_post( $post ); |
| 3215: | } else { |
| 3216: | $post = get_post(); |
| 3217: | } |
| 3218: | |
| 3219: | if ( empty( $post ) ) { |
| 3220: | return ''; |
| 3221: | } |
| 3222: | |
| 3223: | if ( post_password_required() ) { |
| 3224: | return esc_html__( 'There is no excerpt because this is a protected post.', 'easy-property-listings' ); |
| 3225: | } |
| 3226: | |
| 3227: | return apply_filters( 'epl_get_the_excerpt', $post->post_excerpt ); |
| 3228: | } |
| 3229: | |
| 3230: | |
| 3231: | |
| 3232: | |
| 3233: | |
| 3234: | |
| 3235: | |
| 3236: | |
| 3237: | |
| 3238: | |
| 3239: | |
| 3240: | function epl_syntax_highlight( $str = '', $classname = '' ) { |
| 3241: | return '<pre><code class="' . $classname . '">' . htmlentities( $str, ENT_QUOTES, 'UTF-8' ) . '</code></pre>'; |
| 3242: | } |
| 3243: | |
| 3244: | |
| 3245: | |
| 3246: | |
| 3247: | |
| 3248: | |
| 3249: | |
| 3250: | |
| 3251: | |
| 3252: | |
| 3253: | |
| 3254: | function epl_strip_tags( $value, $allowed_tags = '' ) { |
| 3255: | |
| 3256: | if ( ! is_array( $value ) ) { |
| 3257: | return strip_tags( $value, $allowed_tags ); |
| 3258: | } |
| 3259: | return $value; |
| 3260: | } |
| 3261: | |
| 3262: | |
| 3263: | |
| 3264: | |
| 3265: | |
| 3266: | |
| 3267: | |
| 3268: | |
| 3269: | |
| 3270: | |
| 3271: | function epl_esc_attr( $value ) { |
| 3272: | |
| 3273: | if ( is_string( $value ) ) { |
| 3274: | return esc_attr( $value ); |
| 3275: | } |
| 3276: | return $value; |
| 3277: | } |
| 3278: | |
| 3279: | |
| 3280: | |
| 3281: | |
| 3282: | |
| 3283: | |
| 3284: | |
| 3285: | |
| 3286: | |
| 3287: | |
| 3288: | |
| 3289: | |
| 3290: | |
| 3291: | |
| 3292: | |
| 3293: | |
| 3294: | function epl_get_post_count( $type, $meta_key, $meta_value, $author_id = '' ) { |
| 3295: | global $wpdb; |
| 3296: | |
| 3297: | $where = array( "p.post_status = 'publish'" ); |
| 3298: | $prepare_args = array(); |
| 3299: | |
| 3300: | if ( empty( $type ) ) { |
| 3301: | $epl_posts = array_keys( epl_get_active_post_types() ); |
| 3302: | |
| 3303: | if ( empty( $epl_posts ) ) { |
| 3304: | $epl_posts = epl_get_core_post_types(); |
| 3305: | } |
| 3306: | |
| 3307: | $placeholders = implode( ', ', array_fill( 0, count( $epl_posts ), '%s' ) ); |
| 3308: | $where[] = "p.post_type IN ( {$placeholders} )"; |
| 3309: | $prepare_args = array_merge( $prepare_args, array_values( $epl_posts ) ); |
| 3310: | } else { |
| 3311: | $where[] = 'p.post_type = %s'; |
| 3312: | $prepare_args[] = $type; |
| 3313: | } |
| 3314: | |
| 3315: | if ( ! empty( $author_id ) ) { |
| 3316: | $author_id = absint( $author_id ); |
| 3317: | $user_info = get_userdata( $author_id ); |
| 3318: | $user_login = $user_info ? $user_info->user_login : ''; |
| 3319: | |
| 3320: | $where[] = '( p.post_author = %d OR pm2.meta_value = %s )'; |
| 3321: | $prepare_args[] = $author_id; |
| 3322: | $prepare_args[] = $user_login; |
| 3323: | } |
| 3324: | |
| 3325: | $where[] = 'p.ID = pm.post_id'; |
| 3326: | $where[] = 'pm.meta_key = %s'; |
| 3327: | $prepare_args[] = $meta_key; |
| 3328: | $where[] = 'pm.meta_value = %s'; |
| 3329: | $prepare_args[] = $meta_value; |
| 3330: | |
| 3331: | |
| 3332: | |
| 3333: | $second_agent_join = empty( $author_id ) ? '' : "LEFT JOIN {$wpdb->postmeta} pm2 ON ( p.ID = pm2.post_id AND pm2.meta_key = 'property_second_agent' )"; |
| 3334: | |
| 3335: | $sql = " |
| 3336: | SELECT count( Distinct p.ID ) AS count |
| 3337: | FROM {$wpdb->posts} AS p |
| 3338: | INNER JOIN {$wpdb->postmeta} pm ON (p.ID = pm.post_id) |
| 3339: | {$second_agent_join} |
| 3340: | WHERE " . implode( ' AND ', $where ); |
| 3341: | |
| 3342: | $count = $wpdb->get_row( $wpdb->prepare( $sql, $prepare_args ) ); |
| 3343: | return $count->count; |
| 3344: | } |
| 3345: | |
| 3346: | |
| 3347: | |
| 3348: | |
| 3349: | |
| 3350: | |
| 3351: | |
| 3352: | |
| 3353: | function epl_get_inspection_date_format() { |
| 3354: | |
| 3355: | $date_format = epl_get_option( 'inspection_date_format' ) === 'custom_inspection_date_format' ? |
| 3356: | epl_get_option( 'custom_inspection_date_format' ) : epl_get_option( 'inspection_date_format' ); |
| 3357: | |
| 3358: | if ( empty( $date_format ) ) { |
| 3359: | $date_format = 'd-M-Y'; |
| 3360: | } |
| 3361: | |
| 3362: | return apply_filters( 'epl_inspection_date_format', $date_format ); |
| 3363: | } |
| 3364: | |
| 3365: | |
| 3366: | |
| 3367: | |
| 3368: | |
| 3369: | |
| 3370: | |
| 3371: | |
| 3372: | function epl_get_inspection_time_format() { |
| 3373: | |
| 3374: | $time_format = 'custom_inspection_time_format' === epl_get_option( 'inspection_time_format' ) ? |
| 3375: | epl_get_option( 'custom_inspection_time_format' ) : epl_get_option( 'inspection_time_format' ); |
| 3376: | |
| 3377: | if ( empty( $time_format ) ) { |
| 3378: | $time_format = 'h:i A'; |
| 3379: | } |
| 3380: | |
| 3381: | return apply_filters( 'epl_inspection_time_format', $time_format ); |
| 3382: | } |
| 3383: | |
| 3384: | |
| 3385: | |
| 3386: | |
| 3387: | |
| 3388: | |
| 3389: | |
| 3390: | |
| 3391: | |
| 3392: | |
| 3393: | function epl_inspection_format( $inspection_date ) { |
| 3394: | |
| 3395: | $formatted_date = ''; |
| 3396: | $inspection_date = explode( ' ', $inspection_date ); |
| 3397: | |
| 3398: | $date_format = epl_get_inspection_date_format(); |
| 3399: | $time_format = epl_get_inspection_time_format(); |
| 3400: | |
| 3401: | $date = isset( $inspection_date[0] ) ? gmdate( $date_format, strtotime( $inspection_date[0] ) ) : ''; |
| 3402: | $time_start = isset( $inspection_date[1] ) ? gmdate( $time_format, strtotime( $inspection_date[1] ) ) : ''; |
| 3403: | $time_end = isset( $inspection_date[3] ) ? gmdate( $time_format, strtotime( $inspection_date[3] ) ) : ''; |
| 3404: | |
| 3405: | return "{$date} {$time_start} to {$time_end}"; |
| 3406: | } |
| 3407: | add_action( 'epl_inspection_format', 'epl_inspection_format' ); |
| 3408: | |
| 3409: | |
| 3410: | |
| 3411: | |
| 3412: | |
| 3413: | |
| 3414: | |
| 3415: | |
| 3416: | |
| 3417: | function epl_count_total_contacts() { |
| 3418: | $counts = wp_count_posts( 'epl_contact' ); |
| 3419: | return $counts->publish; |
| 3420: | } |
| 3421: | |
| 3422: | |
| 3423: | |
| 3424: | |
| 3425: | |
| 3426: | |
| 3427: | |
| 3428: | |
| 3429: | |
| 3430: | |
| 3431: | function epl_contact_note_agents() { |
| 3432: | return array( 'easy-property-listings', 'epl' ); |
| 3433: | } |
| 3434: | |
| 3435: | |
| 3436: | |
| 3437: | |
| 3438: | |
| 3439: | |
| 3440: | |
| 3441: | |
| 3442: | |
| 3443: | function epl_is_contact_note( $comment ) { |
| 3444: | return isset( $comment->comment_agent ) && in_array( $comment->comment_agent, epl_contact_note_agents(), true ); |
| 3445: | } |
| 3446: | |
| 3447: | |
| 3448: | |
| 3449: | |
| 3450: | |
| 3451: | |
| 3452: | |
| 3453: | |
| 3454: | |
| 3455: | |
| 3456: | function epl_can_see_contact_notes() { |
| 3457: | return is_admin() && current_user_can( 'edit_posts' ); |
| 3458: | } |
| 3459: | |
| 3460: | |
| 3461: | |
| 3462: | |
| 3463: | |
| 3464: | |
| 3465: | |
| 3466: | |
| 3467: | |
| 3468: | |
| 3469: | |
| 3470: | function epl_filter_listing_comments_array( $comments, $post_id ) { |
| 3471: | foreach ( $comments as $key => $comment ) { |
| 3472: | if ( epl_is_contact_note( $comment ) ) { |
| 3473: | unset( $comments[ $key ] ); |
| 3474: | } |
| 3475: | } |
| 3476: | return $comments; |
| 3477: | } |
| 3478: | add_filter( 'comments_array', 'epl_filter_listing_comments_array', 10, 2 ); |
| 3479: | |
| 3480: | |
| 3481: | |
| 3482: | |
| 3483: | |
| 3484: | |
| 3485: | |
| 3486: | function epl_exclude_contact_notes_sql() { |
| 3487: | global $wpdb; |
| 3488: | |
| 3489: | $agents = epl_contact_note_agents(); |
| 3490: | $placeholders = implode( ', ', array_fill( 0, count( $agents ), '%s' ) ); |
| 3491: | |
| 3492: | |
| 3493: | return $wpdb->prepare( " AND {$wpdb->comments}.comment_agent NOT IN ( $placeholders )", $agents ); |
| 3494: | } |
| 3495: | |
| 3496: | |
| 3497: | |
| 3498: | |
| 3499: | |
| 3500: | |
| 3501: | |
| 3502: | |
| 3503: | |
| 3504: | |
| 3505: | |
| 3506: | |
| 3507: | |
| 3508: | function epl_hide_contact_notes_from_comment_queries( $clauses, $query ) { |
| 3509: | $asks_for_a_contacts_notes = isset( $query->query_vars['meta_key'] ) && 'epl_contact_id' === $query->query_vars['meta_key']; |
| 3510: | |
| 3511: | if ( epl_can_see_contact_notes() || $asks_for_a_contacts_notes ) { |
| 3512: | return $clauses; |
| 3513: | } |
| 3514: | |
| 3515: | $clauses['where'] .= epl_exclude_contact_notes_sql(); |
| 3516: | return $clauses; |
| 3517: | } |
| 3518: | add_filter( 'comments_clauses', 'epl_hide_contact_notes_from_comment_queries', 10, 2 ); |
| 3519: | |
| 3520: | |
| 3521: | |
| 3522: | |
| 3523: | |
| 3524: | |
| 3525: | |
| 3526: | |
| 3527: | |
| 3528: | function epl_hide_contact_notes_from_comment_feeds( $where ) { |
| 3529: | return $where . epl_exclude_contact_notes_sql(); |
| 3530: | } |
| 3531: | add_filter( 'comment_feed_where', 'epl_hide_contact_notes_from_comment_feeds' ); |
| 3532: | |
| 3533: | |
| 3534: | |
| 3535: | |
| 3536: | |
| 3537: | |
| 3538: | |
| 3539: | |
| 3540: | |
| 3541: | |
| 3542: | function epl_archive_title_callback() { |
| 3543: | the_post(); |
| 3544: | |
| 3545: | if ( is_tax() && function_exists( 'epl_is_search' ) && false === epl_is_search() ) { |
| 3546: | $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
| 3547: | |
| 3548: | $title = sprintf( __( 'Property in %s', 'easy-property-listings' ), $term->name ); |
| 3549: | } elseif ( function_exists( 'epl_is_search' ) && epl_is_search() ) { |
| 3550: | $title = apply_filters( 'epl_archive_title_search_result', __( 'Search Result', 'easy-property-listings' ) ); |
| 3551: | } elseif ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() && function_exists( 'post_type_archive_title' ) ) { |
| 3552: | $title = post_type_archive_title( '', false ); |
| 3553: | $title = apply_filters( 'epl_archive_title_post_type', $title ); |
| 3554: | } else { |
| 3555: | $title = apply_filters( 'epl_archive_title_fallback', __( 'Listing', 'easy-property-listings' ) ); |
| 3556: | } |
| 3557: | |
| 3558: | if ( is_paged() ) { |
| 3559: | |
| 3560: | printf( '%s – Page %d', esc_html( $title ), esc_attr( get_query_var( 'paged' ) ) ); |
| 3561: | } else { |
| 3562: | echo wp_kses_post( apply_filters( 'epl_archive_title_default', $title ) ); |
| 3563: | } |
| 3564: | |
| 3565: | rewind_posts(); |
| 3566: | } |
| 3567: | add_action( 'epl_the_archive_title', 'epl_archive_title_callback' ); |
| 3568: | |
| 3569: | |
| 3570: | |
| 3571: | |
| 3572: | |
| 3573: | |
| 3574: | |
| 3575: | |
| 3576: | |
| 3577: | |
| 3578: | |
| 3579: | |
| 3580: | |
| 3581: | |
| 3582: | function epl_add_orderby_args( $args, $type = '', $name = '' ) { |
| 3583: | |
| 3584: | if ( 'shortcode' === $type ) { |
| 3585: | $args['is_epl_shortcode'] = true; |
| 3586: | $args['epl_shortcode_name'] = $name; |
| 3587: | } |
| 3588: | |
| 3589: | $post_type = isset( $args['post_type'] ) ? current( $args['post_type'] ) : ''; |
| 3590: | $post_type = sanitize_text_field( wp_unslash( $post_type ) ); |
| 3591: | $orderby = isset( $_GET['sortby'] ) ? sanitize_text_field( wp_unslash( $_GET['sortby'] ) ) : ''; |
| 3592: | |
| 3593: | $instance_id = ! empty( $args['instance_id'] ) ? sanitize_text_field( $args['instance_id'] ) : ''; |
| 3594: | $set_instance_id = ''; |
| 3595: | |
| 3596: | if ( ! empty( $_GET['instance_id'] ) ) { |
| 3597: | $set_instance_id = sanitize_text_field( wp_unslash( $_GET['instance_id'] ) ); |
| 3598: | } |
| 3599: | |
| 3600: | if ( ! empty( $orderby ) && ( ! empty( $instance_id ) && $instance_id === $set_instance_id ) ) { |
| 3601: | |
| 3602: | $sorters = epl_sorting_options( $post_type ); |
| 3603: | |
| 3604: | foreach ( $sorters as $sorter ) { |
| 3605: | |
| 3606: | if ( $orderby === $sorter['id'] ) { |
| 3607: | |
| 3608: | $args = array_merge( $args, epl_get_sorter_query_args( $sorter ) ); |
| 3609: | break; |
| 3610: | } |
| 3611: | } |
| 3612: | } |
| 3613: | return $args; |
| 3614: | } |
| 3615: | |
| 3616: | |
| 3617: | |
| 3618: | |
| 3619: | |
| 3620: | |
| 3621: | |
| 3622: | |
| 3623: | |
| 3624: | |
| 3625: | |
| 3626: | function epl_shortcode_results_message_callback( $shortcode = 'default' ) { |
| 3627: | |
| 3628: | $title = apply_filters( 'epl_shortcode_results_message_title', __( 'Nothing found, please check back later.', 'easy-property-listings' ), $shortcode ); |
| 3629: | |
| 3630: | if ( 'open' === $shortcode ) { |
| 3631: | $title = apply_filters( 'epl_shortcode_results_message_title_open', __( 'Nothing currently scheduled for inspection, please check back later.', 'easy-property-listings' ), $shortcode ); |
| 3632: | } |
| 3633: | |
| 3634: | $text = apply_filters( 'epl_shortcode_results_message_text', '', $shortcode ); |
| 3635: | |
| 3636: | $html = '<h3 class="epl-alert epl-shortcode-results-message epl-shortcode-results-message-' . esc_attr( $shortcode ) . '">' . wp_kses_post( $title ) . '</h3>'; |
| 3637: | |
| 3638: | if ( '' !== (string) $text ) { |
| 3639: | $html .= '<p class="epl-shortcode-results-message-text epl-shortcode-results-message-text-' . esc_attr( $shortcode ) . '">' . wp_kses_post( $text ) . '</p>'; |
| 3640: | } |
| 3641: | |
| 3642: | echo wp_kses_post( apply_filters( 'epl_shortcode_results_message_html', $html, $shortcode, $title, $text ) ); |
| 3643: | } |
| 3644: | add_action( 'epl_shortcode_results_message', 'epl_shortcode_results_message_callback' ); |
| 3645: | |
| 3646: | |
| 3647: | |
| 3648: | |
| 3649: | |
| 3650: | |
| 3651: | |
| 3652: | |
| 3653: | function epl_property_search_not_found_callback() { |
| 3654: | |
| 3655: | $title = apply_filters( 'epl_property_search_not_found_title', __( 'Listing not Found', 'easy-property-listings' ) ); |
| 3656: | $message = apply_filters( 'epl_property_search_not_found_message', __( 'Listing not found, expand your search criteria and try again.', 'easy-property-listings' ) ); |
| 3657: | |
| 3658: | ?> |
| 3659: | <div class="epl-search-not-found"> |
| 3660: | <div class="epl-search-not-found-title entry-header clearfix"> |
| 3661: | <h3 class="entry-title"><?php echo wp_kses_post( $title ); ?></h3> |
| 3662: | </div> |
| 3663: | |
| 3664: | <div class="epl-search-not-found-message entry-content clearfix"> |
| 3665: | <p><?php echo wp_kses_post( $message ); ?></p> |
| 3666: | </div> |
| 3667: | </div> |
| 3668: | |
| 3669: | <?php |
| 3670: | } |
| 3671: | add_action( 'epl_property_search_not_found', 'epl_property_search_not_found_callback' ); |
| 3672: | |
| 3673: | |
| 3674: | |
| 3675: | |
| 3676: | |
| 3677: | |
| 3678: | |
| 3679: | |
| 3680: | |
| 3681: | |
| 3682: | |
| 3683: | |
| 3684: | function epl_property_post_class_listing_status_callback( $classes ) { |
| 3685: | |
| 3686: | if ( is_epl_post() ) { |
| 3687: | |
| 3688: | $property_status = get_property_meta( 'property_status' ); |
| 3689: | $property_under_offer = get_property_meta( 'property_under_offer' ); |
| 3690: | $commercial_type = get_property_meta( 'property_com_listing_type' ); |
| 3691: | $authority = 'commercial' === get_post_type() ? get_property_meta( 'property_com_authority' ) : get_property_meta( 'property_authority' ); |
| 3692: | $class_prefix = 'epl-status-'; |
| 3693: | |
| 3694: | if ( ! empty( $property_status ) ) { |
| 3695: | $classes[] = $class_prefix . strtolower( $property_status ); |
| 3696: | } |
| 3697: | if ( 'yes' === $property_under_offer && 'sold' !== $property_status ) { |
| 3698: | $classes[] = $class_prefix . 'under-offer'; |
| 3699: | } |
| 3700: | if ( 'auction' === $authority ) { |
| 3701: | $classes[] = $class_prefix . 'auction'; |
| 3702: | } |
| 3703: | if ( ! empty( $commercial_type ) ) { |
| 3704: | $class_prefix = 'epl-commercial-type-'; |
| 3705: | $classes[] = $class_prefix . strtolower( $commercial_type ); |
| 3706: | } |
| 3707: | } |
| 3708: | |
| 3709: | if ( 'on' === epl_get_option( 'epl_feeling_lucky', 'off' ) && is_epl_post_archive() ) { |
| 3710: | $classes[] = 'epl-property-blog-compatibility'; |
| 3711: | } |
| 3712: | |
| 3713: | return $classes; |
| 3714: | } |
| 3715: | add_filter( 'post_class', 'epl_property_post_class_listing_status_callback' ); |
| 3716: | |
| 3717: | |
| 3718: | |
| 3719: | |
| 3720: | |
| 3721: | |
| 3722: | |
| 3723: | function epl_archive_author_callback() { |
| 3724: | global $epl_author_secondary, $epl_author_third, $epl_author_fourth; |
| 3725: | epl_get_template_part( 'content-author-archive-card.php' ); |
| 3726: | |
| 3727: | if ( is_epl_post() ) { |
| 3728: | if ( epl_listing_has_secondary_author() ) { |
| 3729: | epl_get_template_part( 'content-author-archive-card.php', array( 'epl_author' => $epl_author_secondary ) ); |
| 3730: | } |
| 3731: | if ( epl_listing_has_third_agent() ) { |
| 3732: | epl_get_template_part( 'content-author-archive-card', array( 'epl_author' => $epl_author_third ) ); |
| 3733: | } |
| 3734: | if ( epl_listing_has_fourth_agent() ) { |
| 3735: | epl_get_template_part( 'content-author-archive-card', array( 'epl_author' => $epl_author_fourth ) ); |
| 3736: | } |
| 3737: | epl_reset_post_author(); |
| 3738: | } |
| 3739: | } |
| 3740: | add_action( 'epl_archive_author', 'epl_archive_author_callback' ); |
| 3741: | |
| 3742: | |
| 3743: | |
| 3744: | |
| 3745: | |
| 3746: | |
| 3747: | |
| 3748: | |
| 3749: | |
| 3750: | |
| 3751: | |
| 3752: | |
| 3753: | function epl_contact_capture_user_can_manage() { |
| 3754: | $capability = epl_get_option( 'min_contact_access', 'manage_options' ); |
| 3755: | $capability = is_string( $capability ) && ! empty( $capability ) ? $capability : 'manage_options'; |
| 3756: | $allowed = current_user_can( $capability ); |
| 3757: | |
| 3758: | return apply_filters( 'epl_contact_capture_user_can_manage', $allowed, $capability ); |
| 3759: | } |
| 3760: | |
| 3761: | |
| 3762: | |
| 3763: | |
| 3764: | |
| 3765: | |
| 3766: | |
| 3767: | |
| 3768: | |
| 3769: | |
| 3770: | function epl_contact_capture_get_ip() { |
| 3771: | $ip = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : ''; |
| 3772: | $ip = filter_var( $ip, FILTER_VALIDATE_IP ); |
| 3773: | |
| 3774: | return $ip ? $ip : ''; |
| 3775: | } |
| 3776: | |
| 3777: | |
| 3778: | |
| 3779: | |
| 3780: | |
| 3781: | |
| 3782: | |
| 3783: | |
| 3784: | |
| 3785: | |
| 3786: | |
| 3787: | function epl_contact_capture_rate_limit_exceeded() { |
| 3788: | $max = (int) apply_filters( 'epl_contact_capture_rate_limit_max', 10 ); |
| 3789: | $window = (int) apply_filters( 'epl_contact_capture_rate_limit_window', 10 * MINUTE_IN_SECONDS ); |
| 3790: | |
| 3791: | |
| 3792: | if ( $max <= 0 || $window <= 0 ) { |
| 3793: | return false; |
| 3794: | } |
| 3795: | |
| 3796: | $ip = epl_contact_capture_get_ip(); |
| 3797: | if ( '' === $ip ) { |
| 3798: | return false; |
| 3799: | } |
| 3800: | |
| 3801: | $key = 'epl_ccap_rl_' . md5( $ip ); |
| 3802: | $count = (int) get_transient( $key ); |
| 3803: | |
| 3804: | if ( $count >= $max ) { |
| 3805: | return true; |
| 3806: | } |
| 3807: | |
| 3808: | set_transient( $key, $count + 1, $window ); |
| 3809: | |
| 3810: | return false; |
| 3811: | } |
| 3812: | |
| 3813: | |
| 3814: | |
| 3815: | |
| 3816: | |
| 3817: | |
| 3818: | |
| 3819: | |
| 3820: | |
| 3821: | |
| 3822: | |
| 3823: | |
| 3824: | |
| 3825: | function epl_process_contact_capture_request( $request ) { |
| 3826: | if ( ! is_array( $request ) || ! empty( $request['epl_contact_anti_spam'] ) ) { |
| 3827: | return new WP_Error( 'epl_contact_capture_invalid', __( 'There was a problem with your submission.', 'easy-property-listings' ) ); |
| 3828: | } |
| 3829: | |
| 3830: | |
| 3831: | if ( ! epl_contact_capture_user_can_manage() && epl_contact_capture_rate_limit_exceeded() ) { |
| 3832: | return new WP_Error( 'epl_contact_capture_throttled', __( 'Too many submissions. Please try again later.', 'easy-property-listings' ) ); |
| 3833: | } |
| 3834: | |
| 3835: | $email = isset( $request['epl_contact_email'] ) ? sanitize_email( wp_unslash( $request['epl_contact_email'] ) ) : ''; |
| 3836: | if ( empty( $email ) ) { |
| 3837: | return new WP_Error( 'epl_contact_capture_email_required', __( 'Email is required.', 'easy-property-listings' ) ); |
| 3838: | } |
| 3839: | |
| 3840: | if ( ! is_email( $email ) ) { |
| 3841: | return new WP_Error( 'epl_contact_capture_invalid_email', __( 'Invalid email.', 'easy-property-listings' ) ); |
| 3842: | } |
| 3843: | |
| 3844: | $fname = isset( $request['epl_contact_first_name'] ) |
| 3845: | ? sanitize_text_field( wp_unslash( $request['epl_contact_first_name'] ) ) |
| 3846: | : ''; |
| 3847: | |
| 3848: | $lname = isset( $request['epl_contact_last_name'] ) |
| 3849: | ? sanitize_text_field( wp_unslash( $request['epl_contact_last_name'] ) ) |
| 3850: | : ''; |
| 3851: | |
| 3852: | $phone = isset( $request['epl_contact_phone'] ) |
| 3853: | ? sanitize_text_field( wp_unslash( $request['epl_contact_phone'] ) ) |
| 3854: | : ''; |
| 3855: | |
| 3856: | $title = isset( $request['epl_contact_title'] ) |
| 3857: | ? sanitize_text_field( wp_unslash( $request['epl_contact_title'] ) ) |
| 3858: | : ''; |
| 3859: | |
| 3860: | $title = trim( $title ); |
| 3861: | if ( empty( $title ) && ( $fname || $lname ) ) { |
| 3862: | $title = trim( $fname . ' ' . $lname ); |
| 3863: | } |
| 3864: | if ( empty( $title ) ) { |
| 3865: | $title = $email; |
| 3866: | } |
| 3867: | |
| 3868: | $contact_listing_id = isset( $request['epl_contact_listing_id'] ) ? absint( $request['epl_contact_listing_id'] ) : 0; |
| 3869: | if ( $contact_listing_id ) { |
| 3870: | $listing = get_post( $contact_listing_id ); |
| 3871: | $listing_type = $listing instanceof WP_Post ? $listing->post_type : ''; |
| 3872: | $valid_types = array_unique( array_merge( array_keys( epl_get_post_types() ), epl_all_post_types() ) ); |
| 3873: | |
| 3874: | if ( |
| 3875: | ! $listing instanceof WP_Post || |
| 3876: | ! in_array( $listing_type, $valid_types, true ) |
| 3877: | ) { |
| 3878: | return new WP_Error( 'epl_contact_capture_invalid_listing', __( 'Invalid listing.', 'easy-property-listings' ) ); |
| 3879: | } |
| 3880: | } |
| 3881: | |
| 3882: | $contact_listing_note = isset( $request['epl_contact_note'] ) |
| 3883: | ? sanitize_textarea_field( wp_unslash( $request['epl_contact_note'] ) ) |
| 3884: | : ''; |
| 3885: | |
| 3886: | |
| 3887: | |
| 3888: | $activity_note = '' !== $contact_listing_note |
| 3889: | ? $contact_listing_note |
| 3890: | : __( 'Enquiry submitted via contact form.', 'easy-property-listings' ); |
| 3891: | |
| 3892: | $contact = new EPL_Contact( $email ); |
| 3893: | if ( ! empty( $contact->ID ) ) { |
| 3894: | if ( $contact_listing_id ) { |
| 3895: | $contact->attach_listing( $contact_listing_id ); |
| 3896: | } |
| 3897: | |
| 3898: | $contact->add_note( $activity_note, 'note', $contact_listing_id ); |
| 3899: | |
| 3900: | return true; |
| 3901: | } |
| 3902: | |
| 3903: | $contact_data = array( |
| 3904: | 'name' => $title, |
| 3905: | 'email' => $email, |
| 3906: | ); |
| 3907: | |
| 3908: | if ( ! $contact->create( $contact_data ) ) { |
| 3909: | return new WP_Error( 'epl_contact_capture_create_failed', __( 'There was a problem with your submission.', 'easy-property-listings' ) ); |
| 3910: | } |
| 3911: | |
| 3912: | $contact->update_meta( 'contact_first_name', $fname ); |
| 3913: | $contact->update_meta( 'contact_last_name', $lname ); |
| 3914: | $contact->update_meta( 'contact_phones', array( 'phone' => $phone ) ); |
| 3915: | $contact->update_meta( 'contact_category', 'widget' ); |
| 3916: | |
| 3917: | if ( $contact_listing_id ) { |
| 3918: | $contact->attach_listing( $contact_listing_id ); |
| 3919: | } |
| 3920: | |
| 3921: | $contact->add_note( $activity_note, 'note', $contact_listing_id ); |
| 3922: | |
| 3923: | return true; |
| 3924: | } |
| 3925: | |
| 3926: | |
| 3927: | |
| 3928: | |
| 3929: | |
| 3930: | |
| 3931: | |
| 3932: | |
| 3933: | |
| 3934: | function epl_contact_capture_action() { |
| 3935: | |
| 3936: | $success = array( |
| 3937: | 'status' => 'success', |
| 3938: | 'msg' => apply_filters( |
| 3939: | 'epl_contact_capture_success_msg', |
| 3940: | __( 'Your enquiry has been submitted.', 'easy-property-listings' ) |
| 3941: | ), |
| 3942: | ); |
| 3943: | |
| 3944: | $fail = array( |
| 3945: | 'status' => 'fail', |
| 3946: | 'msg' => apply_filters( |
| 3947: | 'epl_contact_capture_fail_msg', |
| 3948: | __( 'There was a problem with your submission.', 'easy-property-listings' ) |
| 3949: | ), |
| 3950: | ); |
| 3951: | |
| 3952: | if ( false === check_ajax_referer( 'epl_contact_widget', 'epl_contact_widget', false ) ) { |
| 3953: | wp_send_json( $fail, 403 ); |
| 3954: | } |
| 3955: | |
| 3956: | $result = epl_process_contact_capture_request( $_POST ); |
| 3957: | if ( is_wp_error( $result ) ) { |
| 3958: | $fail['msg'] = $result->get_error_message(); |
| 3959: | wp_send_json( $fail, 400 ); |
| 3960: | } |
| 3961: | |
| 3962: | wp_send_json( $success ); |
| 3963: | } |
| 3964: | add_action( 'wp_ajax_epl_contact_capture_action', 'epl_contact_capture_action' ); |
| 3965: | add_action( 'wp_ajax_nopriv_epl_contact_capture_action', 'epl_contact_capture_action' ); |
| 3966: | |
| 3967: | |
| 3968: | |
| 3969: | |
| 3970: | |
| 3971: | |
| 3972: | |
| 3973: | |
| 3974: | function epl_get_post_id_from_unique_id( $unique_id = '' ) { |
| 3975: | |
| 3976: | if ( '' === $unique_id ) { |
| 3977: | return false; |
| 3978: | } |
| 3979: | |
| 3980: | $args = array( |
| 3981: | 'meta_key' => 'property_unique_id', |
| 3982: | 'meta_value' => $unique_id, |
| 3983: | 'post_type' => epl_get_core_post_types(), |
| 3984: | 'post_status' => 'publish', |
| 3985: | 'posts_per_page' => -1, |
| 3986: | ); |
| 3987: | |
| 3988: | $posts = get_posts( $args ); |
| 3989: | |
| 3990: | if ( ! empty( $posts ) ) { |
| 3991: | $post = current( $posts ); |
| 3992: | return $post->ID; |
| 3993: | } |
| 3994: | |
| 3995: | return false; |
| 3996: | } |
| 3997: | |
| 3998: | |
| 3999: | |
| 4000: | |
| 4001: | |
| 4002: | |
| 4003: | |
| 4004: | |
| 4005: | |
| 4006: | |
| 4007: | function epl_stickers( $options = array(), $stickers = array() ) { |
| 4008: | |
| 4009: | global $post; |
| 4010: | |
| 4011: | if ( ! is_epl_post() ) { |
| 4012: | return; |
| 4013: | } |
| 4014: | |
| 4015: | $default_options = array( |
| 4016: | 'wrap' => false, |
| 4017: | 'wrap_class' => 'epl-stickers-wrapper', |
| 4018: | 'wrapper_tag' => 'div', |
| 4019: | 'sticker_tag' => 'span', |
| 4020: | 'sticker_class' => 'status-sticker', |
| 4021: | 'max_stickers' => 2, |
| 4022: | ); |
| 4023: | |
| 4024: | $sticker_counts = 0; |
| 4025: | |
| 4026: | $options = array_merge( $default_options, $options ); |
| 4027: | |
| 4028: | if ( empty( $stickers ) ) { |
| 4029: | $stickers = epl_get_stickers_array(); |
| 4030: | } |
| 4031: | |
| 4032: | $options = apply_filters( 'epl_stickers_options', $options ); |
| 4033: | |
| 4034: | if ( $options['wrap'] ) { |
| 4035: | echo '<' . esc_attr( $options['wrapper_tag'] ) . ' class="' . esc_attr( $options['wrap_class'] ) . '">'; |
| 4036: | } |
| 4037: | |
| 4038: | foreach ( $stickers as $key => $sticker ) { |
| 4039: | |
| 4040: | if ( $sticker_counts === $default_options['max_stickers'] ) { |
| 4041: | break; |
| 4042: | } |
| 4043: | ?> |
| 4044: | |
| 4045: | <<?php echo esc_attr( $options['sticker_tag'] ); ?> class="<?php echo esc_attr( $options['sticker_class'] . ' ' . $sticker['class'] ); ?>"> |
| 4046: | <?php |
| 4047: | echo isset( $sticker['before'] ) ? |
| 4048: | wp_kses_post( $sticker['before'] ) : ''; |
| 4049: | echo wp_kses_post( $sticker['label'] ); |
| 4050: | echo isset( $sticker['after'] ) ? |
| 4051: | wp_kses_post( $sticker['after'] ) : ''; |
| 4052: | ?> |
| 4053: | </<?php echo esc_attr( $options['sticker_tag'] ); ?>> |
| 4054: | <?php |
| 4055: | ++$sticker_counts; |
| 4056: | } |
| 4057: | |
| 4058: | if ( $options['wrap'] ) { |
| 4059: | echo '</' . esc_attr( $options['wrapper_tag'] ) . '>'; |
| 4060: | } |
| 4061: | } |
| 4062: | |
| 4063: | |
| 4064: | |
| 4065: | |
| 4066: | |
| 4067: | |
| 4068: | |
| 4069: | |
| 4070: | |
| 4071: | |
| 4072: | |
| 4073: | |
| 4074: | function epl_get_stickers_array( $sticker_keys = array() ) { |
| 4075: | |
| 4076: | global $post; |
| 4077: | |
| 4078: | $stickers = array( |
| 4079: | |
| 4080: | 'under_offer' => array( |
| 4081: | 'conditions' => array( |
| 4082: | 'property_status' => 'current', |
| 4083: | 'property_under_offer' => array( 'yes' ), |
| 4084: | ), |
| 4085: | 'type' => epl_get_core_post_types(), |
| 4086: | 'label' => epl_get_option( 'label_under_offer' ), |
| 4087: | 'before' => '', |
| 4088: | 'after' => '', |
| 4089: | 'class' => 'under-offer', |
| 4090: | ), |
| 4091: | 'home_open' => array( |
| 4092: | 'conditions' => array( |
| 4093: | 'property_inspection_times' => array( null, '' ), |
| 4094: | ), |
| 4095: | 'compare' => '!=', |
| 4096: | 'type' => epl_get_core_post_types(), |
| 4097: | 'label' => epl_get_option( 'label_home_open' ), |
| 4098: | 'before' => '', |
| 4099: | 'after' => '', |
| 4100: | 'class' => 'open', |
| 4101: | ), |
| 4102: | |
| 4103: | 'new' => array( |
| 4104: | 'type' => epl_get_core_post_types(), |
| 4105: | 'label' => epl_get_option( 'label_new' ), |
| 4106: | 'before' => '', |
| 4107: | 'after' => '', |
| 4108: | 'class' => 'new', |
| 4109: | |
| 4110: | ), |
| 4111: | 'rental_lease' => array( |
| 4112: | 'conditions' => array( |
| 4113: | 'property_status' => 'current', |
| 4114: | ), |
| 4115: | 'type' => array( 'rental' ), |
| 4116: | 'label' => __( 'For Lease', 'easy-property-listings' ), |
| 4117: | 'before' => '', |
| 4118: | 'after' => '', |
| 4119: | 'class' => 'for-lease', |
| 4120: | ), |
| 4121: | 'leased' => array( |
| 4122: | 'conditions' => array( |
| 4123: | 'property_status' => 'leased', |
| 4124: | ), |
| 4125: | 'type' => array( 'rental', 'commercial_land', 'commercial' ), |
| 4126: | 'label' => epl_get_option( 'label_leased' ), |
| 4127: | 'before' => '', |
| 4128: | 'after' => '', |
| 4129: | 'class' => 'leased', |
| 4130: | ), |
| 4131: | 'current_sales' => array( |
| 4132: | 'conditions' => array( |
| 4133: | 'property_status' => 'current', |
| 4134: | ), |
| 4135: | 'type' => array( 'property', 'rural', 'land', 'business' ), |
| 4136: | 'label' => __( 'For Sale', 'easy-property-listings' ), |
| 4137: | 'before' => '', |
| 4138: | 'after' => '', |
| 4139: | 'class' => 'for-sale', |
| 4140: | ), |
| 4141: | 'sold' => array( |
| 4142: | 'conditions' => array( |
| 4143: | 'property_status' => 'sold', |
| 4144: | ), |
| 4145: | 'type' => epl_get_core_post_types(), |
| 4146: | 'label' => epl_get_option( 'label_sold' ), |
| 4147: | 'before' => '', |
| 4148: | 'after' => '', |
| 4149: | 'class' => 'sold', |
| 4150: | ), |
| 4151: | 'commercial_sale_lease' => array( |
| 4152: | 'conditions' => array( |
| 4153: | 'property_status' => 'current', |
| 4154: | 'property_com_listing_type' => array( 'both' ), |
| 4155: | ), |
| 4156: | 'type' => array( 'commercial', 'commercial_land' ), |
| 4157: | 'label' => __( 'For Sale & Lease', 'easy-property-listings' ), |
| 4158: | 'before' => '', |
| 4159: | 'after' => '', |
| 4160: | 'class' => 'for-sale', |
| 4161: | ), |
| 4162: | 'commercial_sale' => array( |
| 4163: | 'conditions' => array( |
| 4164: | 'property_status' => 'current', |
| 4165: | 'property_com_listing_type' => array( 'sale' ), |
| 4166: | ), |
| 4167: | 'type' => array( 'commercial', 'commercial_land' ), |
| 4168: | 'label' => __( 'For Sale', 'easy-property-listings' ), |
| 4169: | 'before' => '', |
| 4170: | 'after' => '', |
| 4171: | 'class' => 'for-sale', |
| 4172: | ), |
| 4173: | 'commercial_lease' => array( |
| 4174: | 'conditions' => array( |
| 4175: | 'property_status' => 'current', |
| 4176: | 'property_com_listing_type' => array( 'lease' ), |
| 4177: | ), |
| 4178: | 'type' => array( 'commercial', 'commercial_land' ), |
| 4179: | 'label' => __( 'For Lease', 'easy-property-listings' ), |
| 4180: | 'before' => '', |
| 4181: | 'after' => '', |
| 4182: | 'class' => 'for-lease', |
| 4183: | ), |
| 4184: | |
| 4185: | ); |
| 4186: | |
| 4187: | |
| 4188: | |
| 4189: | |
| 4190: | |
| 4191: | |
| 4192: | $stickers = apply_filters( 'epl_available_stickers', $stickers ); |
| 4193: | |
| 4194: | $return = array(); |
| 4195: | |
| 4196: | foreach ( $stickers as $key => $sticker ) { |
| 4197: | |
| 4198: | $add_sticker = false; |
| 4199: | |
| 4200: | if ( ! empty( $sticker_keys ) && ! in_array( $key, $sticker_keys, true ) ) { |
| 4201: | continue; |
| 4202: | } |
| 4203: | |
| 4204: | if ( ! empty( $sticker ) && is_array( $sticker ) ) { |
| 4205: | |
| 4206: | if ( ! in_array( get_post_type(), $sticker['type'], true ) ) { |
| 4207: | continue; |
| 4208: | } |
| 4209: | |
| 4210: | if ( 'new' === $key ) { |
| 4211: | |
| 4212: | $date = new DateTime( $post->post_date ); |
| 4213: | $now = new DateTime(); |
| 4214: | |
| 4215: | |
| 4216: | if ( method_exists( $now, 'diff' ) ) { |
| 4217: | |
| 4218: | $diff = $now->diff( $date ); |
| 4219: | $diff = $diff->days; |
| 4220: | } else { |
| 4221: | $diff = strtotime( $now->format( 'M d Y ' ) ) - strtotime( $date->format( 'M d Y ' ) ); |
| 4222: | $diff = floor( $diff / 3600 / 24 ); |
| 4223: | |
| 4224: | } |
| 4225: | |
| 4226: | if ( epl_get_option( 'sticker_new_range' ) >= $diff ) { |
| 4227: | |
| 4228: | $return[ $key ] = array( |
| 4229: | 'label' => $sticker['label'], |
| 4230: | 'class' => $sticker['class'], |
| 4231: | 'before' => $sticker['before'], |
| 4232: | 'after' => $sticker['after'], |
| 4233: | ); |
| 4234: | } |
| 4235: | } else { |
| 4236: | |
| 4237: | $conditions = $sticker['conditions']; |
| 4238: | $compare = isset( $sticker['compare'] ) ? $sticker['compare'] : '='; |
| 4239: | |
| 4240: | $add_sticker = epl_sticker_is_condition_valid( $conditions, $compare ); |
| 4241: | |
| 4242: | } |
| 4243: | |
| 4244: | if ( $add_sticker ) { |
| 4245: | $return[ $key ] = array( |
| 4246: | 'label' => $sticker['label'], |
| 4247: | 'class' => $sticker['class'], |
| 4248: | 'before' => $sticker['before'], |
| 4249: | 'after' => $sticker['after'], |
| 4250: | ); |
| 4251: | } |
| 4252: | } |
| 4253: | } |
| 4254: | |
| 4255: | |
| 4256: | |
| 4257: | |
| 4258: | |
| 4259: | return apply_filters( 'epl_stickers_array', $return ); |
| 4260: | } |
| 4261: | |
| 4262: | |
| 4263: | |
| 4264: | |
| 4265: | |
| 4266: | |
| 4267: | |
| 4268: | |
| 4269: | |
| 4270: | |
| 4271: | function epl_sticker_is_condition_valid( $condition, $compare = '=' ) { |
| 4272: | |
| 4273: | $condition_met = 0; |
| 4274: | $total_condition = count( $condition ); |
| 4275: | $match = false; |
| 4276: | |
| 4277: | foreach ( $condition as $key => $value ) { |
| 4278: | |
| 4279: | if ( is_array( $value ) ) { |
| 4280: | |
| 4281: | if ( in_array( get_property_meta( $key ), $value, true ) ) { |
| 4282: | ++$condition_met; |
| 4283: | } |
| 4284: | } else { |
| 4285: | if ( get_property_meta( $key ) === $value ) { |
| 4286: | ++$condition_met; |
| 4287: | } |
| 4288: | } |
| 4289: | } |
| 4290: | $match = $total_condition === $condition_met ? true : false; |
| 4291: | |
| 4292: | return '=' === $compare ? $match : ! $match; |
| 4293: | } |
| 4294: | |
| 4295: | |
| 4296: | |
| 4297: | |
| 4298: | |
| 4299: | |
| 4300: | |
| 4301: | |
| 4302: | |
| 4303: | |
| 4304: | function epl_property_status( $statues = array(), $options = array() ) { |
| 4305: | |
| 4306: | $statues_defaults = array( |
| 4307: | 'commercial_lease', |
| 4308: | 'commercial_sale', |
| 4309: | 'rental_lease', |
| 4310: | 'leased', |
| 4311: | 'sold', |
| 4312: | 'current_sales', |
| 4313: | 'commercial_sale_lease', |
| 4314: | ); |
| 4315: | |
| 4316: | $statues = array_merge( $statues_defaults, (array) $statues ); |
| 4317: | |
| 4318: | $statues = apply_filters( 'epl_property_status_keys', $statues ); |
| 4319: | |
| 4320: | $stickers = epl_get_stickers_array( $statues ); |
| 4321: | |
| 4322: | $default_options = array( |
| 4323: | 'wrap' => true, |
| 4324: | 'wrap_class' => 'epl-listing-status', |
| 4325: | 'wrapper_tag' => 'div', |
| 4326: | 'sticker_tag' => 'span', |
| 4327: | 'sticker_class' => 'epl-widget-status-label', |
| 4328: | ); |
| 4329: | |
| 4330: | $options = array_merge( $default_options, (array) $options ); |
| 4331: | epl_stickers( $options, $stickers ); |
| 4332: | } |
| 4333: | add_action( 'epl_property_status', 'epl_property_status', 10, 2 ); |
| 4334: | |
| 4335: | |
| 4336: | |
| 4337: | |
| 4338: | |
| 4339: | |
| 4340: | |
| 4341: | |
| 4342: | |
| 4343: | |
| 4344: | function epl_body_classes( $classes ) { |
| 4345: | |
| 4346: | if ( is_epl_post_single() ) { |
| 4347: | $classes[] = 'epl-single-listing'; |
| 4348: | $classes[] = 'epl-single-' . get_post_type(); |
| 4349: | } |
| 4350: | |
| 4351: | if ( is_epl_post_archive() ) { |
| 4352: | $classes[] = 'epl-post-type-archive'; |
| 4353: | $classes[] = 'epl-post-type-archive-' . get_post_type(); |
| 4354: | } |
| 4355: | |
| 4356: | if ( epl_is_search() ) { |
| 4357: | $classes[] = 'epl-post-type-archive'; |
| 4358: | $classes[] = 'epl-search-results'; |
| 4359: | } |
| 4360: | |
| 4361: | return $classes; |
| 4362: | } |
| 4363: | add_filter( 'body_class', 'epl_body_classes', 10 ); |
| 4364: | |
| 4365: | |
| 4366: | |
| 4367: | |
| 4368: | |
| 4369: | |
| 4370: | function epl_get_total_agent_count() { |
| 4371: | $counter = 1; |
| 4372: | |
| 4373: | $second_agent = get_property_meta( 'property_second_agent' ); |
| 4374: | $third_agent = get_property_meta( 'property_third_agent' ); |
| 4375: | $fourth_agent = get_property_meta( 'property_fourth_agent' ); |
| 4376: | $counter = ! empty( $second_agent ) ? $counter + 1 : $counter; |
| 4377: | $counter = ! empty( $third_agent ) ? $counter + 1 : $counter; |
| 4378: | $counter = ! empty( $fourth_agent ) ? $counter + 1 : $counter; |
| 4379: | |
| 4380: | return $counter; |
| 4381: | } |
| 4382: | |
| 4383: | |
| 4384: | |
| 4385: | |
| 4386: | |
| 4387: | |
| 4388: | |
| 4389: | |
| 4390: | |
| 4391: | function epl_get_agent_id_by_login( $login ) { |
| 4392: | if ( ! empty( $login ) ) { |
| 4393: | $user = get_user_by( 'login', $login ); |
| 4394: | return $user ? $user->ID : false; |
| 4395: | } |
| 4396: | return false; |
| 4397: | } |
| 4398: | |
| 4399: | |
| 4400: | |
| 4401: | |
| 4402: | |
| 4403: | |
| 4404: | |
| 4405: | |
| 4406: | |
| 4407: | function epl_get_active_agent_count() { |
| 4408: | global $epl_author; |
| 4409: | |
| 4410: | $agents = array( $epl_author->author_id ); |
| 4411: | |
| 4412: | $second_agent = get_property_meta( 'property_second_agent' ); |
| 4413: | $third_agent = get_property_meta( 'property_third_agent' ); |
| 4414: | $fourth_agent = get_property_meta( 'property_fourth_agent' ); |
| 4415: | |
| 4416: | $second_author_id = epl_get_agent_id_by_login( $second_agent ); |
| 4417: | $third_author_id = epl_get_agent_id_by_login( $third_agent ); |
| 4418: | $fourth_author_id = epl_get_agent_id_by_login( $fourth_agent ); |
| 4419: | |
| 4420: | if ( false !== $second_author_id ) { |
| 4421: | $agents[] = $second_author_id; |
| 4422: | } |
| 4423: | if ( false !== $third_author_id ) { |
| 4424: | $agents[] = $third_author_id; |
| 4425: | } |
| 4426: | if ( false !== $fourth_author_id ) { |
| 4427: | $agents[] = $fourth_author_id; |
| 4428: | } |
| 4429: | |
| 4430: | $agents = array_unique( $agents ); |
| 4431: | $count = count( $agents ); |
| 4432: | |
| 4433: | return apply_filters( 'epl_get_active_agent_count', $count ); |
| 4434: | } |
| 4435: | |
| 4436: | |
| 4437: | |
| 4438: | |
| 4439: | |
| 4440: | |
| 4441: | |
| 4442: | function epl_single_author_wrapper_start() { |
| 4443: | |
| 4444: | $counter = epl_get_total_agent_count(); |
| 4445: | $active = epl_get_active_agent_count(); |
| 4446: | ?> |
| 4447: | <div class="epl-author-box-wrapper epl-author-box-wrapper--count-<?php echo esc_attr( $active ); ?> epl-author-box-wrapper--total-<?php echo esc_attr( $counter ); ?> "> |
| 4448: | <?php |
| 4449: | } |
| 4450: | add_action( 'epl_single_author', 'epl_single_author_wrapper_start', 1 ); |
| 4451: | |
| 4452: | |
| 4453: | |
| 4454: | |
| 4455: | |
| 4456: | |
| 4457: | function epl_single_author_wrapper_end() { |
| 4458: | ?> |
| 4459: | </div> |
| 4460: | <?php |
| 4461: | } |
| 4462: | add_action( 'epl_single_author', 'epl_single_author_wrapper_end', 99 ); |
| 4463: | |
| 4464: | |
| 4465: | |
| 4466: | |
| 4467: | |
| 4468: | |
| 4469: | |
| 4470: | |
| 4471: | |
| 4472: | |
| 4473: | function epl_value_bool_checker( $value ) { |
| 4474: | |
| 4475: | $truthy_values = array( 1, 'yes', 'true' ); |
| 4476: | $truthy_values = apply_filters( 'epl_truthy_values', $truthy_values ); |
| 4477: | |
| 4478: | if ( in_array( $value, $truthy_values, true ) ) { |
| 4479: | return true; |
| 4480: | } else { |
| 4481: | return false; |
| 4482: | } |
| 4483: | } |
| 4484: | |