| 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: | function epl_property_address_suburb_column_orderby( $vars ) { |
| 26: | if ( isset( $vars['orderby'] ) && 'property_address_suburb' === $vars['orderby'] ) { |
| 27: | $vars = array_merge( |
| 28: | $vars, |
| 29: | array( |
| 30: | 'meta_key' => 'property_address_suburb', |
| 31: | 'orderby' => 'meta_value', |
| 32: | ) |
| 33: | ); |
| 34: | } |
| 35: | return $vars; |
| 36: | } |
| 37: | add_filter( 'request', 'epl_property_address_suburb_column_orderby' ); |
| 38: | |
| 39: | |
| 40: | add_action( 'restrict_manage_posts', 'epl_custom_restrict_manage_posts' ); |
| 41: | add_filter( 'parse_query', 'epl_admin_posts_filter' ); |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | function epl_custom_restrict_manage_posts() { |
| 51: | global $post_type; |
| 52: | if ( 'property' === $post_type || 'rental' === $post_type || 'land' === $post_type || 'commercial' === $post_type || 'rural' === $post_type || 'business' === $post_type || 'holiday_rental' === $post_type || 'commercial_land' === $post_type ) { |
| 53: | |
| 54: | |
| 55: | $fields = array(); |
| 56: | $fields['current'] = epl_get_the_status_label( 'current' ); |
| 57: | |
| 58: | if ( 'rental' !== $post_type && 'holiday_rental' !== $post_type ) { |
| 59: | $fields['sold'] = apply_filters( 'epl_sold_label_status_filter', epl_get_the_status_label( 'sold' ) ); |
| 60: | } |
| 61: | |
| 62: | if ( 'rental' === $post_type || 'holiday_rental' === $post_type || 'commercial' === $post_type || 'business' === $post_type || 'commercial_land' === $post_type ) { |
| 63: | $fields['leased'] = apply_filters( 'epl_leased_label_status_filter', epl_get_the_status_label( 'leased' ) ); |
| 64: | } |
| 65: | |
| 66: | $fields['withdrawn'] = epl_get_the_status_label( 'withdrawn' ); |
| 67: | $fields['offmarket'] = epl_get_the_status_label( 'offmarket' ); |
| 68: | $fields['deleted'] = epl_get_the_status_label( 'deleted' ); |
| 69: | |
| 70: | if ( ! empty( $fields ) ) { |
| 71: | $_GET['property_status'] = isset( $_GET['property_status'] ) ? sanitize_text_field( wp_unslash( $_GET['property_status'] ) ) : ''; |
| 72: | echo '<select aria-label="' . esc_attr__( 'Filter By Type', 'easy-property-listings' ) . '" name="property_status">'; |
| 73: | echo '<option value="">' . esc_html__( 'Filter By Type', 'easy-property-listings' ) . '</option>'; |
| 74: | foreach ( $fields as $k => $v ) { |
| 75: | $selected = ( sanitize_text_field( wp_unslash( $_GET['property_status'] ) ) === $k ? 'selected="selected"' : '' ); |
| 76: | echo '<option value="' . esc_attr( $k ) . '" ' . esc_attr( $selected ) . '>' . esc_attr( $v ) . '</option>'; |
| 77: | } |
| 78: | echo '</select>'; |
| 79: | } |
| 80: | |
| 81: | $property_author = isset( $_GET['property_author'] ) ? intval( $_GET['property_author'] ) : ''; |
| 82: | |
| 83: | wp_dropdown_users( |
| 84: | array( |
| 85: | 'name' => 'property_author', |
| 86: | 'selected' => $property_author, |
| 87: | 'show_option_all' => __( 'All Users', 'easy-property-listings' ), |
| 88: | 'role__not_in' => array( 'subscriber' ), |
| 89: | ) |
| 90: | ); |
| 91: | |
| 92: | $custom_search_fields = array( |
| 93: | 'property_address_suburb' => epl_labels( 'label_suburb' ), |
| 94: | 'property_office_id' => __( 'Office ID', 'easy-property-listings' ), |
| 95: | 'property_agent' => __( 'Listing Agent', 'easy-property-listings' ), |
| 96: | 'property_second_agent' => __( 'Second Listing Agent', 'easy-property-listings' ), |
| 97: | 'property_unique_id' => __( 'Property ID', 'easy-property-listings' ), |
| 98: | ); |
| 99: | $custom_search_fields = apply_filters( 'epl_admin_search_fields', $custom_search_fields ); |
| 100: | |
| 101: | if ( ! empty( $custom_search_fields ) ) { |
| 102: | $sel = isset( $_GET['property_custom_fields'] ) ? sanitize_text_field( wp_unslash( $_GET['property_custom_fields'] ) ) : ''; |
| 103: | echo '<select aria-label="' . esc_attr__( 'Search For', 'easy-property-listings' ) . '" name="property_custom_fields">'; |
| 104: | echo '<option value="">' . esc_html__( 'Search For', 'easy-property-listings' ) . '</option>'; |
| 105: | foreach ( $custom_search_fields as $k => $v ) { |
| 106: | echo '<option value="' . esc_attr( $k ) . '" ' . selected( $sel, $k, false ) . '>' . esc_attr( $v ) . '</option>'; |
| 107: | } |
| 108: | echo '</select>'; |
| 109: | } |
| 110: | |
| 111: | |
| 112: | if ( isset( $_GET['property_custom_value'] ) ) { |
| 113: | $val = sanitize_text_field( wp_unslash( $_GET['property_custom_value'] ) ); |
| 114: | } else { |
| 115: | $val = ''; |
| 116: | } |
| 117: | echo '<input type="text" name="property_custom_value" placeholder="' . esc_html__( 'Search Value.', 'easy-property-listings' ) . '" value="' . esc_attr( $val ) . '" />'; |
| 118: | } |
| 119: | } |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: | |
| 125: | |
| 126: | |
| 127: | |
| 128: | |
| 129: | function epl_admin_posts_filter( $query ) { |
| 130: | |
| 131: | global $pagenow; |
| 132: | if ( is_admin() && 'edit.php' === $pagenow && in_array( $query->get( 'post_type' ), epl_get_core_post_types(), true ) ) { |
| 133: | $meta_query = (array) $query->get( 'meta_query' ); |
| 134: | |
| 135: | if ( isset( $_GET['property_status'] ) && ! empty( $_GET['property_status'] ) ) { |
| 136: | $meta_query[] = array( |
| 137: | 'key' => 'property_status', |
| 138: | 'value' => sanitize_text_field( wp_unslash( $_GET['property_status'] ) ), |
| 139: | ); |
| 140: | } |
| 141: | |
| 142: | if ( isset( $_GET['property_author'] ) && ! empty( $_GET['property_author'] ) ) { |
| 143: | $author = intval( $_GET['property_author'] ); |
| 144: | $author_object = get_user_by( 'id', $author ); |
| 145: | $meta_query[] = array( |
| 146: | 'relation' => 'OR', |
| 147: | array( |
| 148: | 'key' => 'property_agent', |
| 149: | 'value' => $author_object->user_login, |
| 150: | ), |
| 151: | array( |
| 152: | 'key' => 'property_second_agent', |
| 153: | 'value' => $author_object->user_login, |
| 154: | ), |
| 155: | ); |
| 156: | } |
| 157: | |
| 158: | if ( ! empty( $_GET['property_custom_value'] ) && ! empty( $_GET['property_custom_fields'] ) ) { |
| 159: | |
| 160: | $meta_query[] = array( |
| 161: | 'key' => sanitize_text_field( wp_unslash( $_GET['property_custom_fields'] ) ), |
| 162: | 'value' => sanitize_text_field( wp_unslash( $_GET['property_custom_value'] ) ), |
| 163: | 'compare' => 'LIKE', |
| 164: | ); |
| 165: | |
| 166: | } |
| 167: | |
| 168: | if ( ! empty( $meta_query ) ) { |
| 169: | $query->set( 'meta_query', $meta_query ); |
| 170: | } |
| 171: | } |
| 172: | } |
| 173: | |
| 174: | |
| 175: | |
| 176: | |
| 177: | |
| 178: | |
| 179: | |
| 180: | |
| 181: | |
| 182: | function epl_manage_listings_sortable_columns( $columns ) { |
| 183: | $columns['property_featured'] = 'property_featured'; |
| 184: | $columns['property_rent'] = 'property_rent'; |
| 185: | $columns['property_price'] = 'property_price'; |
| 186: | $columns['property_status'] = 'property_status'; |
| 187: | $columns['listing_id'] = 'listing_id'; |
| 188: | $columns['agent'] = 'agent'; |
| 189: | $columns['property_thumb'] = 'property_thumb'; |
| 190: | return $columns; |
| 191: | } |
| 192: | |
| 193: | $epl_posts = array( 'property', 'land', 'commercial', 'business', 'commercial_land', 'location_profile', 'rental', 'rural' ); |
| 194: | |
| 195: | foreach ( $epl_posts as $epl_post ) { |
| 196: | add_filter( 'manage_edit-' . $epl_post . '_sortable_columns', 'epl_manage_listings_sortable_columns' ); |
| 197: | } |
| 198: | |
| 199: | |
| 200: | |
| 201: | |
| 202: | |
| 203: | |
| 204: | |
| 205: | function epl_custom_orderby( $query ) { |
| 206: | if ( ! is_admin() ) { |
| 207: | return; |
| 208: | } |
| 209: | |
| 210: | $orderby = $query->get( 'orderby' ); |
| 211: | |
| 212: | if ( 'property_price' === $orderby ) { |
| 213: | $query->set( 'meta_key', 'property_price' ); |
| 214: | $query->set( 'orderby', 'meta_value_num' ); |
| 215: | } |
| 216: | |
| 217: | if ( 'property_rent' === $orderby ) { |
| 218: | $query->set( 'meta_key', 'property_rent' ); |
| 219: | $query->set( 'orderby', 'meta_value_num' ); |
| 220: | } |
| 221: | |
| 222: | if ( 'listing_id' === $orderby ) { |
| 223: | $query->set( 'meta_key', 'property_unique_id' ); |
| 224: | $query->set( 'orderby', 'meta_value' ); |
| 225: | } |
| 226: | |
| 227: | if ( 'property_thumb' === $orderby ) { |
| 228: | $query->set( 'meta_key', '_thumbnail_id' ); |
| 229: | $query->set( 'orderby', 'meta_value' ); |
| 230: | } |
| 231: | |
| 232: | if ( 'property_featured' === $orderby ) { |
| 233: | $query->set( 'meta_key', 'property_featured' ); |
| 234: | $query->set( 'orderby', 'meta_value' ); |
| 235: | } |
| 236: | } |
| 237: | |
| 238: | add_filter( 'pre_get_posts', 'epl_custom_orderby' ); |
| 239: | |
| 240: | |
| 241: | |
| 242: | |
| 243: | |
| 244: | |
| 245: | |
| 246: | function epl_manage_listing_column_property_thumb_callback() { |
| 247: | |
| 248: | if ( function_exists( 'the_post_thumbnail' ) ) { |
| 249: | $thumb_size = epl_get_option( 'epl_admin_thumb_size', 'admin-list-thumb' ); |
| 250: | |
| 251: | the_post_thumbnail( $thumb_size ); |
| 252: | } |
| 253: | } |
| 254: | add_action( 'epl_manage_listing_column_property_thumb', 'epl_manage_listing_column_property_thumb_callback' ); |
| 255: | |
| 256: | |
| 257: | |
| 258: | |
| 259: | |
| 260: | |
| 261: | |
| 262: | |
| 263: | |
| 264: | |
| 265: | |
| 266: | |
| 267: | function epl_manage_listing_column_listing_callback() { |
| 268: | global $post, $property; |
| 269: | |
| 270: | $property_address_suburb = get_the_term_list( $post->ID, 'location', '', ', ', '' ); |
| 271: | $heading = $property->get_property_meta( 'property_heading' ); |
| 272: | $home_open = $property->get_property_meta( 'property_inspection_times' ); |
| 273: | $home_open = is_string( $home_open ) ? trim( $home_open ) : ''; |
| 274: | $beds = $property->get_property_meta( 'property_bedrooms' ); |
| 275: | $baths = $property->get_property_meta( 'property_bathrooms' ); |
| 276: | $rooms = $property->get_property_meta( 'property_rooms', false ); |
| 277: | $land = $property->get_property_meta( 'property_land_area', false ); |
| 278: | $land_unit = $property->get_property_meta( 'property_land_area_unit' ); |
| 279: | $category = $property->get_property_meta( 'property_category' ); |
| 280: | |
| 281: | |
| 282: | $commercial_category = $property->get_property_meta( 'property_commercial_category' ); |
| 283: | $outgoings = $property->get_property_meta( 'property_com_outgoings' ); |
| 284: | $return = $property->get_property_meta( 'property_com_return' ); |
| 285: | |
| 286: | |
| 287: | $taking = $property->get_property_meta( 'property_bus_takings' ); |
| 288: | $franchise = $property->get_property_meta( 'property_bus_franchise' ); |
| 289: | $taking = $property->get_property_meta( 'property_bus_terms' ); |
| 290: | |
| 291: | if ( is_array( $commercial_category ) ) { |
| 292: | $commercial_category = implode( ', ', $commercial_category ); |
| 293: | } |
| 294: | |
| 295: | |
| 296: | if ( empty( $heading ) ) { |
| 297: | echo '<strong>' . esc_html__( 'Important! Set a Heading', 'easy-property-listings' ) . '</strong>'; |
| 298: | } else { |
| 299: | echo '<div class="type_heading"><strong>', wp_kses( |
| 300: | $heading, |
| 301: | array( |
| 302: | 'strong' => array(), |
| 303: | 'b' => array(), |
| 304: | ) |
| 305: | ), '</strong></div>'; |
| 306: | } |
| 307: | |
| 308: | |
| 309: | if ( ! empty( $commercial_category ) ) { |
| 310: | echo '<div class="epl_meta_category">', esc_html( $commercial_category ), '</div>'; |
| 311: | } |
| 312: | |
| 313: | |
| 314: | |
| 315: | |
| 316: | |
| 317: | |
| 318: | |
| 319: | |
| 320: | |
| 321: | |
| 322: | |
| 323: | |
| 324: | |
| 325: | |
| 326: | |
| 327: | |
| 328: | echo '<div class="type_suburb">', wp_kses( |
| 329: | $property_address_suburb, |
| 330: | array( |
| 331: | 'strong' => array(), |
| 332: | 'b' => array(), |
| 333: | 'a' => array( |
| 334: | 'href' => array(), |
| 335: | ), |
| 336: | ) |
| 337: | ), '</div>'; |
| 338: | |
| 339: | |
| 340: | if ( ! empty( $category ) ) { |
| 341: | $property_category = $property->get_property_category( 'span', 'epl_meta_property_category' ); |
| 342: | echo '<div class="epl_meta_category">', wp_kses_post( $property_category ), '</div>'; |
| 343: | } |
| 344: | |
| 345: | |
| 346: | if ( ! empty( $outgoings ) ) { |
| 347: | echo '<div class="epl_meta_outgoings">' . esc_html( epl_get_meta_field_label( 'property_com_outgoings' ) ) . ': ', esc_html( epl_currency_formatted_amount( $outgoings ) ), '</div>'; |
| 348: | } |
| 349: | |
| 350: | |
| 351: | if ( ! empty( $return ) ) { |
| 352: | echo '<div class="epl_meta_return">' . esc_html( epl_get_meta_field_label( 'property_com_return' ) ) . ': ', esc_html( $return ), '%</div>'; |
| 353: | } |
| 354: | |
| 355: | |
| 356: | if ( ! empty( $beds ) || ! empty( $baths ) ) { |
| 357: | echo '<div class="epl_meta_beds_baths">'; |
| 358: | echo '<span class="epl_meta_beds">', esc_attr( $beds ), ' ', esc_html__( 'Beds', 'easy-property-listings' ), ' | </span>'; |
| 359: | echo '<span class="epl_meta_baths">', esc_attr( $baths ), ' ', esc_html__( 'Baths', 'easy-property-listings' ), '</span>'; |
| 360: | echo '</div>'; |
| 361: | } |
| 362: | |
| 363: | |
| 364: | if ( ! empty( $rooms ) ) { |
| 365: | if ( 1 === absint( $rooms ) ) { |
| 366: | echo '<div class="epl_meta_rooms">', esc_attr( $rooms ), ' ', esc_html__( 'Room', 'easy-property-listings' ), '</div>'; |
| 367: | } else { |
| 368: | echo '<div class="epl_meta_rooms">', esc_attr( $rooms ), ' ', esc_html( epl_get_meta_field_label( 'property_rooms' ) ), '</div>'; |
| 369: | } |
| 370: | } |
| 371: | |
| 372: | |
| 373: | if ( ! empty( $land ) ) { |
| 374: | |
| 375: | $decimal_formatted = apply_filters( 'epl_land_value_decimal_format', true ); |
| 376: | |
| 377: | if ( $decimal_formatted ) { |
| 378: | $land = epl_format_amount( $land, true, true ); |
| 379: | } |
| 380: | echo '<div class="epl_meta_land_details">'; |
| 381: | echo '<span class="epl_meta_land">', wp_kses_post( $land ), '</span>'; |
| 382: | |
| 383: | if ( 'squareMeter' === $land_unit ) { |
| 384: | $land_unit = esc_html__( 'm²', 'easy-property-listings' ); |
| 385: | } |
| 386: | $land_unit = apply_filters( 'epl_property_land_area_unit_label', $land_unit ); |
| 387: | |
| 388: | echo '<span class="epl_meta_land_unit"> ', wp_kses_post( $land_unit ), '</span>'; |
| 389: | echo '</div>'; |
| 390: | } |
| 391: | |
| 392: | |
| 393: | if ( ! empty( $home_open ) ) { |
| 394: | $home_open = array_filter( explode( "\n", $home_open ) ); |
| 395: | $home_open_list = '<ul class="epl_meta_home_open">'; |
| 396: | foreach ( $home_open as $num => $item ) { |
| 397: | $home_open_list .= '<li>' . htmlspecialchars( $item, ENT_QUOTES, 'UTF-8' ) . '</li>'; |
| 398: | } |
| 399: | $home_open_list .= '</ul>'; |
| 400: | echo '<div class="epl_meta_home_open_label"><span class="home-open"><strong>' . esc_html( epl_labels( 'label_home_open' ) ) . '</strong></span>', wp_kses_post( $home_open_list ), '</div>'; |
| 401: | } |
| 402: | } |
| 403: | add_action( 'epl_manage_listing_column_listing', 'epl_manage_listing_column_listing_callback' ); |
| 404: | |
| 405: | |
| 406: | |
| 407: | |
| 408: | |
| 409: | |
| 410: | |
| 411: | |
| 412: | |
| 413: | |
| 414: | function epl_get_manage_listing_column_labels( $args = array(), $returntype = 'l' ) { |
| 415: | |
| 416: | global $property; |
| 417: | |
| 418: | $defaults = array( 'featured' ); |
| 419: | $labels = apply_filters( 'epl_manage_listing_column_labels', $defaults ); |
| 420: | $returntype = apply_filters( 'epl_manage_listing_column_labels_return_type', $returntype ); |
| 421: | |
| 422: | ob_start(); |
| 423: | |
| 424: | foreach ( $labels as $label ) { |
| 425: | if ( ! empty( $args ) && ! in_array( $label, $args, true ) ) { |
| 426: | continue; |
| 427: | } |
| 428: | |
| 429: | switch ( $label ) { |
| 430: | case 'featured': |
| 431: | echo $property->get_property_featured( $returntype ); |
| 432: | break; |
| 433: | |
| 434: | default: |
| 435: | |
| 436: | do_action( 'epl_get_manage_listing_column_label_' . $label ); |
| 437: | break; |
| 438: | } |
| 439: | } |
| 440: | |
| 441: | return ob_get_clean(); |
| 442: | } |
| 443: | |
| 444: | |
| 445: | |
| 446: | |
| 447: | |
| 448: | |
| 449: | |
| 450: | function epl_manage_listing_column_labels_callback( $returntype = 'l' ) { |
| 451: | |
| 452: | $returntype = empty( $returntype ) ? 'l' : $returntype; |
| 453: | |
| 454: | echo '<ul class="epl-listing-labels">' . epl_get_manage_listing_column_labels( array(), $returntype ) . '</ul>'; |
| 455: | } |
| 456: | add_action( 'epl_manage_listing_column_listing', 'epl_manage_listing_column_labels_callback', 20 ); |
| 457: | |
| 458: | |
| 459: | |
| 460: | |
| 461: | |
| 462: | |
| 463: | function epl_manage_listing_column_listing_id_callback() { |
| 464: | global $post; |
| 465: | |
| 466: | $unique_id = get_post_meta( $post->ID, 'property_unique_id', true ); |
| 467: | |
| 468: | if ( ! empty( $unique_id ) ) { |
| 469: | echo esc_attr( $unique_id ); |
| 470: | } |
| 471: | } |
| 472: | add_action( 'epl_manage_listing_column_listing_id', 'epl_manage_listing_column_listing_id_callback' ); |
| 473: | |
| 474: | |
| 475: | |
| 476: | |
| 477: | |
| 478: | |
| 479: | function epl_manage_listing_column_geo_callback() { |
| 480: | global $post; |
| 481: | |
| 482: | $property_address_coordinates = get_post_meta( $post->ID, 'property_address_coordinates', true ); |
| 483: | |
| 484: | if ( ',' === $property_address_coordinates || empty( $property_address_coordinates ) ) { |
| 485: | esc_html_e( 'No', 'easy-property-listings' ); |
| 486: | } else { |
| 487: | echo esc_html( $property_address_coordinates ); |
| 488: | } |
| 489: | } |
| 490: | add_action( 'epl_manage_listing_column_geo', 'epl_manage_listing_column_geo_callback' ); |
| 491: | |
| 492: | |
| 493: | |
| 494: | |
| 495: | |
| 496: | |
| 497: | |
| 498: | |
| 499: | |
| 500: | |
| 501: | function epl_manage_listing_column_price_callback() { |
| 502: | global $post, $property; |
| 503: | |
| 504: | $price = $property->get_property_meta( 'property_price' ); |
| 505: | $view = $property->get_property_meta( 'property_price_view' ); |
| 506: | $property_status = $property->get_property_meta( 'property_status' ); |
| 507: | $property_authority = $property->get_property_meta( 'property_authority' ); |
| 508: | $sold_price = $property->get_property_meta( 'property_sold_price' ); |
| 509: | $property_under_offer = $property->get_property_meta( 'property_under_offer' ); |
| 510: | $lease = $property->get_property_meta( 'property_com_rent' ); |
| 511: | $lease_period = $property->get_property_meta( 'property_com_rent_period' ); |
| 512: | $lease_date = $property->get_property_meta( 'property_com_lease_end_date' ); |
| 513: | $d_bond = ''; |
| 514: | $bond = ''; |
| 515: | $max_price = (int) epl_get_option( 'epl_max_graph_sales_price', '2000000' ); |
| 516: | |
| 517: | |
| 518: | if ( 'rental' === $post->post_type ) { |
| 519: | |
| 520: | $price = $property->get_property_meta( 'property_rent' ); |
| 521: | $view = $property->get_property_meta( 'property_rent_view' ); |
| 522: | |
| 523: | $d_bond = epl_get_option( 'display_bond' ); |
| 524: | $bond = $property->get_property_meta( 'property_bond', false ); |
| 525: | |
| 526: | $max_price = (int) epl_get_option( 'epl_max_graph_rent_price', '2000' ); |
| 527: | } |
| 528: | |
| 529: | |
| 530: | if ( 'commercial' === $post->post_type && 'lease' === $property->get_property_meta( 'property_com_listing_type' ) ) { |
| 531: | |
| 532: | |
| 533: | |
| 534: | |
| 535: | |
| 536: | |
| 537: | |
| 538: | |
| 539: | |
| 540: | |
| 541: | $price = $property->get_property_meta( 'property_com_rent' ); |
| 542: | $max_price = (int) epl_get_option( 'epl_max_graph_rent_price', '2000' ); |
| 543: | } |
| 544: | |
| 545: | if ( 'sold' === $property_status ) { |
| 546: | $class = 'bar-home-sold'; |
| 547: | } elseif ( 'leased' === $property_status ) { |
| 548: | $class = 'bar-home-sold'; |
| 549: | } elseif ( ! empty( $property_under_offer ) && 'yes' === $property_under_offer ) { |
| 550: | $class = 'bar-under-offer'; |
| 551: | } elseif ( 'current' === $property_status ) { |
| 552: | $class = 'bar-home-open'; |
| 553: | } else { |
| 554: | $class = ''; |
| 555: | } |
| 556: | |
| 557: | |
| 558: | if ( ! empty( $sold_price ) ) { |
| 559: | $bar_price = $sold_price; |
| 560: | |
| 561: | } elseif ( ! empty( $price ) ) { |
| 562: | $bar_price = $price; |
| 563: | } |
| 564: | |
| 565: | |
| 566: | if ( ! empty( $bar_price ) ) { |
| 567: | $bar_width = 0 === $max_price ? 0 : intval( $bar_price ) / $max_price * 100; |
| 568: | echo '<div class="epl-price-bar ' . esc_attr( $class ) . '"> |
| 569: | <span style="width:' . esc_attr( $bar_width ) . '%"></span> |
| 570: | </div>'; |
| 571: | |
| 572: | } else { |
| 573: | echo esc_html__( 'No price set', 'easy-property-listings' ); |
| 574: | } |
| 575: | |
| 576: | |
| 577: | if ( ! empty( $sold_price ) ) { |
| 578: | echo '<div class="epl_meta_search_price">' . wp_kses_post( $property->get_price_plain_value() ) . ' '; |
| 579: | echo 'sold' === $property_status ? esc_html( epl_currency_formatted_amount( $sold_price ) ) : ''; |
| 580: | echo '</div>'; |
| 581: | } else { |
| 582: | echo '<div class="epl_meta_price">' . wp_kses_post( $property->get_price_plain_value() ) . '</div>'; |
| 583: | } |
| 584: | |
| 585: | |
| 586: | if ( ! empty( $bond ) && 1 === $d_bond ) { |
| 587: | echo '<div class="epl_meta_bond">', esc_html( epl_labels( 'label_bond' ) ), ' ', esc_html( epl_currency_formatted_amount( $bond ) ), '</div>'; |
| 588: | } |
| 589: | |
| 590: | |
| 591: | if ( ! empty( $lease_date ) ) { |
| 592: | echo '<div class="epl_meta_lease_date">' . esc_html__( 'Lease End:', 'easy-property-listings' ) . ' ', esc_html( $lease_date ), '</div>'; |
| 593: | } |
| 594: | |
| 595: | |
| 596: | if ( ! empty( $lease ) ) { |
| 597: | if ( empty( $lease_period ) ) { |
| 598: | $lease_period = esc_html( 'annual' ); |
| 599: | } |
| 600: | echo '<div class="epl_meta_lease_price">Lease: ', esc_html( epl_currency_formatted_amount( $lease ) ), ' ', esc_html( epl_listing_load_meta_commercial_rent_period_value( $lease_period ) ), '</div>'; |
| 601: | } |
| 602: | } |
| 603: | add_action( 'epl_manage_listing_column_price', 'epl_manage_listing_column_price_callback' ); |
| 604: | |
| 605: | |
| 606: | |
| 607: | |
| 608: | |
| 609: | |
| 610: | |
| 611: | |
| 612: | |
| 613: | function epl_manage_listing_column_property_status_callback() { |
| 614: | global $post, $property; |
| 615: | |
| 616: | $property_status = get_post_meta( $post->ID, 'property_status', true ); |
| 617: | $labels_property_status = apply_filters( |
| 618: | 'epl_labels_property_status_filter', |
| 619: | array( |
| 620: | 'current' => epl_get_the_status_label( 'current' ), |
| 621: | 'sold' => $property->label_sold, |
| 622: | 'leased' => $property->label_leased, |
| 623: | 'withdrawn' => epl_get_the_status_label( 'withdrawn' ), |
| 624: | 'offmarket' => epl_get_the_status_label( 'offmarket' ), |
| 625: | 'deleted' => epl_get_the_status_label( 'deleted' ), |
| 626: | ) |
| 627: | ); |
| 628: | if ( ! empty( $property_status ) ) { |
| 629: | echo '<span class="type_' . esc_attr( strtolower( $property_status ) ) . '">' . esc_html( $labels_property_status[ $property_status ] ) . '</span>'; |
| 630: | } |
| 631: | } |
| 632: | add_action( 'epl_manage_listing_column_property_status', 'epl_manage_listing_column_property_status_callback' ); |
| 633: | |
| 634: | |
| 635: | |
| 636: | |
| 637: | |
| 638: | |
| 639: | function epl_manage_listing_column_listing_type_callback() { |
| 640: | global $post; |
| 641: | |
| 642: | |
| 643: | $listing_type = get_post_meta( $post->ID, 'property_com_listing_type', true ); |
| 644: | |
| 645: | if ( ! empty( $listing_type ) ) { |
| 646: | echo esc_html( $listing_type ); |
| 647: | } |
| 648: | } |
| 649: | add_action( 'epl_manage_listing_column_listing_type', 'epl_manage_listing_column_listing_type_callback' ); |
| 650: | |
| 651: | |
| 652: | |
| 653: | |
| 654: | |
| 655: | |
| 656: | function epl_show_agent_name_in_column() { |
| 657: | |
| 658: | global $property, $post; |
| 659: | |
| 660: | $agent_keys = array( |
| 661: | 'property_second_agent', |
| 662: | 'property_third_agent', |
| 663: | 'property_fourth_agent', |
| 664: | ); |
| 665: | |
| 666: | foreach ( $agent_keys as $agent_key ) { |
| 667: | |
| 668: | $agent = $property->get_property_meta( $agent_key ); |
| 669: | |
| 670: | if ( ! empty( $agent ) ) { |
| 671: | |
| 672: | $current_author = get_user_by( 'login', $agent ); |
| 673: | |
| 674: | if ( false !== $current_author ) { |
| 675: | $url = add_query_arg( |
| 676: | array( |
| 677: | 'post_type' => $post->post_type, |
| 678: | 'author' => $current_author->ID, |
| 679: | ), |
| 680: | 'edit.php' |
| 681: | ); |
| 682: | ?> |
| 683: | <div class="epl-meta epl-meta--agent epl-meta--<?php echo esc_attr( $agent_key ); ?>"> |
| 684: | <span class="epl-agent epl-agent--name"> |
| 685: | <a href="<?php echo esc_url( $url ); ?>"> |
| 686: | <?php echo esc_html( get_the_author_meta( 'display_name', $current_author->ID ) ); ?> |
| 687: | </a> |
| 688: | </span> |
| 689: | </div> |
| 690: | <?php |
| 691: | } else { |
| 692: | ?> |
| 693: | <div class="epl-meta epl-meta--agent epl-meta--<?php echo esc_attr( $agent_key ); ?>"> |
| 694: | <span class="epl-agent epl-agent--name"><?php echo esc_html( $agent ); ?></span> |
| 695: | </div> |
| 696: | <?php |
| 697: | } |
| 698: | epl_reset_post_author(); |
| 699: | } |
| 700: | } |
| 701: | } |
| 702: | |
| 703: | |
| 704: | |
| 705: | |
| 706: | |
| 707: | |
| 708: | function epl_manage_listing_column_agent_callback() { |
| 709: | global $post, $property; |
| 710: | |
| 711: | printf( |
| 712: | '<a href="%s">%s</a>', |
| 713: | esc_url( |
| 714: | add_query_arg( |
| 715: | array( |
| 716: | 'post_type' => $post->post_type, |
| 717: | 'author' => get_the_author_meta( 'ID' ), |
| 718: | ), |
| 719: | 'edit.php' |
| 720: | ) |
| 721: | ), |
| 722: | get_the_author() |
| 723: | ); |
| 724: | |
| 725: | epl_show_agent_name_in_column(); |
| 726: | } |
| 727: | add_action( 'epl_manage_listing_column_agent', 'epl_manage_listing_column_agent_callback' ); |
| 728: | |
| 729: | |
| 730: | |
| 731: | |
| 732: | |
| 733: | |
| 734: | function epl_manage_listing_column_featured_callback() { |
| 735: | |
| 736: | global $property; |
| 737: | |
| 738: | if ( 'yes' === $property->get_property_meta( 'property_featured' ) ) { |
| 739: | echo '<span class="dashicons dashicons-star-filled"></span>'; |
| 740: | } else { |
| 741: | echo '<span class="dashicons dashicons-star-empty"></span>'; |
| 742: | } |
| 743: | } |
| 744: | add_action( 'epl_manage_listing_column_featured', 'epl_manage_listing_column_featured_callback' ); |
| 745: | |