| 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: | |
| 29: | |
| 30: | |
| 31: | function epl_get_option( $key = '', $default_val = false ) { |
| 32: | |
| 33: | global $epl_settings; |
| 34: | |
| 35: | |
| 36: | if ( isset( $epl_settings[ $key ] ) && is_numeric( $epl_settings[ $key ] ) && 0.0 === (float) $epl_settings[ $key ] ) { |
| 37: | $value = 0; |
| 38: | } else { |
| 39: | |
| 40: | $value = ! empty( $epl_settings[ $key ] ) ? $epl_settings[ $key ] : $default_val; |
| 41: | } |
| 42: | |
| 43: | $value = apply_filters( 'epl_get_option', $value, $key, $default_val ); |
| 44: | return apply_filters( 'epl_get_option_' . $key, $value, $key, $default_val ); |
| 45: | } |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | |
| 60: | |
| 61: | |
| 62: | function epl_get_saved_option( $key = '', $default_val = false ) { |
| 63: | |
| 64: | $epl_settings = epl_get_settings(); |
| 65: | |
| 66: | if ( is_array( $epl_settings ) && isset( $epl_settings[ $key ] ) ) { |
| 67: | $value = $epl_settings[ $key ]; |
| 68: | } else { |
| 69: | $value = $default_val; |
| 70: | } |
| 71: | |
| 72: | $value = apply_filters( 'epl_get_option', $value, $key, $default_val ); |
| 73: | return apply_filters( 'epl_get_option_' . $key, $value, $key, $default_val ); |
| 74: | } |
| 75: | |
| 76: | |
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | function epl_refresh_settings_global( $old_value, $value ) { |
| 89: | global $epl_settings; |
| 90: | $epl_settings = $value; |
| 91: | } |
| 92: | add_action( 'update_option_epl_settings', 'epl_refresh_settings_global', 10, 2 ); |
| 93: | |
| 94: | |
| 95: | |
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | function epl_refresh_settings_global_on_add( $option, $value ) { |
| 103: | epl_refresh_settings_global( null, $value ); |
| 104: | } |
| 105: | add_action( 'add_option_epl_settings', 'epl_refresh_settings_global_on_add', 10, 2 ); |
| 106: | |
| 107: | |
| 108: | |
| 109: | |
| 110: | |
| 111: | |
| 112: | function epl_is_divi_framework_theme() { |
| 113: | if ( function_exists( 'et_divi_fonts_url' ) ) { |
| 114: | return true; |
| 115: | } |
| 116: | return false; |
| 117: | } |
| 118: | |
| 119: | |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: | function epl_is_builder_framework_theme() { |
| 125: | if ( function_exists( 'it_classes_load' ) ) { |
| 126: | return true; |
| 127: | } |
| 128: | return false; |
| 129: | } |
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | |
| 135: | |
| 136: | function epl_is_genesis_framework_theme() { |
| 137: | if ( function_exists( 'genesis_constants' ) ) { |
| 138: | return true; |
| 139: | } |
| 140: | return false; |
| 141: | } |
| 142: | |
| 143: | |
| 144: | |
| 145: | |
| 146: | |
| 147: | |
| 148: | function epl_is_twenty_twenty_theme() { |
| 149: | if ( function_exists( 'twentytwenty_theme_support' ) ) { |
| 150: | return true; |
| 151: | } |
| 152: | return false; |
| 153: | } |
| 154: | |
| 155: | |
| 156: | |
| 157: | |
| 158: | |
| 159: | |
| 160: | function epl_is_avada_theme() { |
| 161: | if ( function_exists( 'Avada' ) ) { |
| 162: | return true; |
| 163: | } |
| 164: | return false; |
| 165: | } |
| 166: | |
| 167: | |
| 168: | |
| 169: | |
| 170: | |
| 171: | |
| 172: | |
| 173: | function epl_get_thumbnail_sizes() { |
| 174: | global $_wp_additional_image_sizes; |
| 175: | $sizes = array( |
| 176: | 'full' => array(), |
| 177: | ); |
| 178: | foreach ( get_intermediate_image_sizes() as $s ) { |
| 179: | $sizes[ $s ] = array( 0, 0 ); |
| 180: | if ( in_array( $s, array( 'thumbnail', 'medium', 'large' ), true ) ) { |
| 181: | $sizes[ $s ][0] = get_option( $s . '_size_w' ); |
| 182: | $sizes[ $s ][1] = get_option( $s . '_size_h' ); |
| 183: | } elseif ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) ) { |
| 184: | $sizes[ $s ] = array( $_wp_additional_image_sizes[ $s ]['width'], $_wp_additional_image_sizes[ $s ]['height'] ); |
| 185: | } |
| 186: | } |
| 187: | return $sizes; |
| 188: | } |
| 189: | |
| 190: | |
| 191: | |
| 192: | |
| 193: | |
| 194: | |
| 195: | |
| 196: | |
| 197: | |
| 198: | |
| 199: | function epl_remote_url_get( $url ) { |
| 200: | |
| 201: | $response = wp_remote_get( $url ); |
| 202: | return wp_remote_retrieve_body( $response ); |
| 203: | } |
| 204: | |
| 205: | |
| 206: | |
| 207: | |
| 208: | |
| 209: | |
| 210: | |
| 211: | |
| 212: | |
| 213: | |
| 214: | function epl_get_ical_download_token( $post_id, $inspection_time ) { |
| 215: | $post_id = absint( $post_id ); |
| 216: | $inspection_time = trim( (string) $inspection_time ); |
| 217: | $payload = $post_id . '|' . $inspection_time; |
| 218: | $secret = apply_filters( 'epl_ical_token_secret', wp_salt( 'nonce' ) ); |
| 219: | |
| 220: | return hash_hmac( 'sha256', $payload, $secret ); |
| 221: | } |
| 222: | |
| 223: | |
| 224: | |
| 225: | |
| 226: | |
| 227: | |
| 228: | |
| 229: | |
| 230: | |
| 231: | |
| 232: | |
| 233: | |
| 234: | function epl_register_post_type( $post_type = '', $post_type_label = '', $args = array() ) { |
| 235: | if ( empty( $post_type ) ) { |
| 236: | return; |
| 237: | } |
| 238: | |
| 239: | global $epl_settings; |
| 240: | if ( ! empty( $epl_settings ) && isset( $epl_settings['activate_post_types'] ) ) { |
| 241: | $epl_activate_post_types = $epl_settings['activate_post_types']; |
| 242: | if ( ! empty( $epl_activate_post_types ) ) { |
| 243: | if ( in_array( $post_type, $epl_activate_post_types, true ) ) { |
| 244: | global $epl_active_post_types; |
| 245: | if ( ! isset( $epl_active_post_types ) ) { |
| 246: | $epl_active_post_types = array(); |
| 247: | } |
| 248: | $epl_active_post_types[ $post_type ] = $post_type_label; |
| 249: | register_post_type( $post_type, $args ); |
| 250: | } |
| 251: | } |
| 252: | } |
| 253: | |
| 254: | if ( isset( $_REQUEST['action'] ) && 'epl_settings' === $_REQUEST['action'] ) { |
| 255: | update_option( 'epl_rewrite_rules', false ); |
| 256: | } |
| 257: | } |
| 258: | |
| 259: | |
| 260: | |
| 261: | |
| 262: | |
| 263: | |
| 264: | function epl_get_active_post_types() { |
| 265: | global $epl_active_post_types; |
| 266: | if ( is_null( $epl_active_post_types ) ) { |
| 267: | $epl_active_post_types = array(); |
| 268: | } |
| 269: | return $epl_active_post_types; |
| 270: | } |
| 271: | |
| 272: | |
| 273: | |
| 274: | |
| 275: | |
| 276: | |
| 277: | function epl_get_post_types() { |
| 278: | $epl_post_types = array( |
| 279: | 'property' => __( 'Property (Residential)', 'easy-property-listings' ), |
| 280: | 'land' => __( 'Land', 'easy-property-listings' ), |
| 281: | 'rental' => __( 'Rental', 'easy-property-listings' ), |
| 282: | 'rural' => __( 'Rural', 'easy-property-listings' ), |
| 283: | 'commercial' => __( 'Commercial', 'easy-property-listings' ), |
| 284: | 'commercial_land' => __( 'Commercial Land', 'easy-property-listings' ), |
| 285: | 'business' => __( 'Business', 'easy-property-listings' ), |
| 286: | ); |
| 287: | |
| 288: | return apply_filters( 'epl_post_types', $epl_post_types ); |
| 289: | } |
| 290: | |
| 291: | |
| 292: | |
| 293: | |
| 294: | |
| 295: | |
| 296: | |
| 297: | |
| 298: | function epl_get_currencies() { |
| 299: | $currencies = array( |
| 300: | 'AUD' => __( 'Australian Dollars ($)', 'easy-property-listings' ), |
| 301: | 'USD' => __( 'US Dollars ($)', 'easy-property-listings' ), |
| 302: | 'EUR' => __( 'Euros (€)', 'easy-property-listings' ), |
| 303: | 'GBP' => __( 'Pounds Sterling (£)', 'easy-property-listings' ), |
| 304: | 'BRL' => __( 'Brazilian Real (R$)', 'easy-property-listings' ), |
| 305: | 'CAD' => __( 'Canadian Dollars ($)', 'easy-property-listings' ), |
| 306: | 'CZK' => __( 'Czech Koruna', 'easy-property-listings' ), |
| 307: | 'DKK' => __( 'Danish Krone', 'easy-property-listings' ), |
| 308: | 'HKD' => __( 'Hong Kong Dollar ($)', 'easy-property-listings' ), |
| 309: | 'HUF' => __( 'Hungarian Forint', 'easy-property-listings' ), |
| 310: | 'INR' => __( 'Indian Rupee (₹)', 'easy-property-listings' ), |
| 311: | 'RIAL' => __( 'Iranian Rial (﷼)', 'easy-property-listings' ), |
| 312: | 'ILS' => __( 'Israeli Shekel (₪)', 'easy-property-listings' ), |
| 313: | 'JPY' => __( 'Japanese Yen (¥)', 'easy-property-listings' ), |
| 314: | 'MYR' => __( 'Malaysian Ringgits', 'easy-property-listings' ), |
| 315: | 'MXN' => __( 'Mexican Peso ($)', 'easy-property-listings' ), |
| 316: | 'NAD' => __( 'Namibian Dollar ($)', 'easy-property-listings' ), |
| 317: | 'NZD' => __( 'New Zealand Dollar ($)', 'easy-property-listings' ), |
| 318: | 'NOK' => __( 'Norwegian Krone', 'easy-property-listings' ), |
| 319: | 'PHP' => __( 'Philippine Pesos', 'easy-property-listings' ), |
| 320: | 'PLN' => __( 'Polish Zloty', 'easy-property-listings' ), |
| 321: | 'PKR' => __( 'Pakistani Rupee', 'easy-property-listings' ), |
| 322: | 'QAR' => __( 'Qatar Riyal (QAR)', 'easy-property-listings' ), |
| 323: | 'SGD' => __( 'Singapore Dollar ($)', 'easy-property-listings' ), |
| 324: | 'ZAR' => __( 'South African Rand (R)', 'easy-property-listings' ), |
| 325: | 'SEK' => __( 'Swedish Krona', 'easy-property-listings' ), |
| 326: | 'CHF' => __( 'Swiss Franc', 'easy-property-listings' ), |
| 327: | 'TWD' => __( 'Taiwan New Dollars', 'easy-property-listings' ), |
| 328: | 'THB' => __( 'Thai Baht (฿)', 'easy-property-listings' ), |
| 329: | 'TRY' => __( 'Turkish Lira (₺)', 'easy-property-listings' ), |
| 330: | 'RUB' => __( 'Russian Rubles', 'easy-property-listings' ), |
| 331: | 'AED' => __( 'United Arab Emirates, Dirham (AED)', 'easy-property-listings' ), |
| 332: | 'UAH' => __( 'Ukrainian Hryvnia (₴)', 'easy-property-listings' ), |
| 333: | 'VND' => __( 'Vietnamese đồng (₫)', 'easy-property-listings' ), |
| 334: | ); |
| 335: | return apply_filters( 'epl_get_currencies', $currencies ); |
| 336: | } |
| 337: | |
| 338: | |
| 339: | |
| 340: | |
| 341: | |
| 342: | |
| 343: | |
| 344: | function epl_get_currency() { |
| 345: | $epl_currency = ''; |
| 346: | |
| 347: | global $epl_settings; |
| 348: | if ( ! empty( $epl_settings ) && isset( $epl_settings['currency'] ) ) { |
| 349: | $epl_currency = $epl_settings['currency']; |
| 350: | } |
| 351: | return apply_filters( 'epl_currency', $epl_currency ); |
| 352: | } |
| 353: | |
| 354: | |
| 355: | |
| 356: | |
| 357: | |
| 358: | |
| 359: | |
| 360: | function epl_get_currency_position() { |
| 361: | $epl_currency_position = ''; |
| 362: | |
| 363: | global $epl_settings; |
| 364: | if ( ! empty( $epl_settings ) && isset( $epl_settings['currency_position'] ) ) { |
| 365: | $epl_currency_position = $epl_settings['currency_position']; |
| 366: | } |
| 367: | return apply_filters( 'epl_currency_position', $epl_currency_position ); |
| 368: | } |
| 369: | |
| 370: | |
| 371: | |
| 372: | |
| 373: | |
| 374: | |
| 375: | |
| 376: | function epl_get_thousands_separator() { |
| 377: | $epl_thousands_separator = ''; |
| 378: | |
| 379: | global $epl_settings; |
| 380: | if ( ! empty( $epl_settings ) && isset( $epl_settings['currency_thousands_separator'] ) ) { |
| 381: | $epl_thousands_separator = $epl_settings['currency_thousands_separator']; |
| 382: | } |
| 383: | return apply_filters( 'epl_thousands_separator', $epl_thousands_separator ); |
| 384: | } |
| 385: | |
| 386: | |
| 387: | |
| 388: | |
| 389: | |
| 390: | |
| 391: | |
| 392: | function epl_get_decimal_separator() { |
| 393: | $epl_decimal_separator = ''; |
| 394: | |
| 395: | global $epl_settings; |
| 396: | if ( ! empty( $epl_settings ) && isset( $epl_settings['currency_decimal_separator'] ) ) { |
| 397: | $epl_decimal_separator = $epl_settings['currency_decimal_separator']; |
| 398: | } |
| 399: | return apply_filters( 'epl_decimal_separator', $epl_decimal_separator ); |
| 400: | } |
| 401: | |
| 402: | |
| 403: | |
| 404: | |
| 405: | |
| 406: | |
| 407: | |
| 408: | |
| 409: | |
| 410: | function epl_currency_formatted_amount( $price ) { |
| 411: | $price_format = apply_filters( 'epl_price_number_format', 'number' ); |
| 412: | $price_format_com_lease = apply_filters( 'epl_price_number_format_commercial_lease', 'number' ); |
| 413: | |
| 414: | if ( 'decimal' === $price_format || 'decimal' === $price_format_com_lease ) { |
| 415: | return epl_currency_filter( epl_format_amount( $price, true ) ); |
| 416: | } else { |
| 417: | return epl_currency_filter( epl_format_amount( $price, false ) ); |
| 418: | } |
| 419: | } |
| 420: | |
| 421: | |
| 422: | |
| 423: | |
| 424: | |
| 425: | |
| 426: | |
| 427: | |
| 428: | |
| 429: | |
| 430: | function epl_labels( $key ) { |
| 431: | global $epl_settings; |
| 432: | $field_groups = epl_get_admin_option_fields(); |
| 433: | $epl_labels = array(); |
| 434: | foreach ( $field_groups as $field_group ) { |
| 435: | if ( 'labels' === $field_group['id'] || 'address' === $field_group['id'] ) { |
| 436: | $epl_labels = array_merge( $epl_labels, array_filter( $field_group['fields'] ) ); |
| 437: | } |
| 438: | } |
| 439: | foreach ( $epl_labels as $label_key => $label ) { |
| 440: | |
| 441: | if ( isset( $label['default'] ) && $key === $label['name'] ) { |
| 442: | |
| 443: | $label = isset( $epl_settings[ $key ] ) ? $epl_settings[ $key ] : $label['default']; |
| 444: | |
| 445: | return apply_filters( 'epl_display_' . $key, $label ); |
| 446: | } |
| 447: | } |
| 448: | } |
| 449: | |
| 450: | |
| 451: | |
| 452: | |
| 453: | |
| 454: | |
| 455: | |
| 456: | |
| 457: | |
| 458: | |
| 459: | |
| 460: | |
| 461: | function epl_the_address( $before = '', $after = '', $country = false, $echo_output = true ) { |
| 462: | $address = epl_get_the_address(); |
| 463: | |
| 464: | if ( strlen( $address ) === 0 ) { |
| 465: | return; |
| 466: | } |
| 467: | |
| 468: | $address = $before . $address . $after; |
| 469: | |
| 470: | if ( $echo_output ) { |
| 471: | echo wp_kses_post( $address ); |
| 472: | } else { |
| 473: | return $address; |
| 474: | } |
| 475: | } |
| 476: | |
| 477: | |
| 478: | |
| 479: | |
| 480: | |
| 481: | |
| 482: | |
| 483: | |
| 484: | |
| 485: | |
| 486: | |
| 487: | |
| 488: | |
| 489: | |
| 490: | function epl_get_the_address( $address_args = array(), $sep = array(), $country = false, $prefix = array() ) { |
| 491: | |
| 492: | $address = ''; |
| 493: | |
| 494: | $address_defaults = array( |
| 495: | 'sub_number' => '/', |
| 496: | 'lot_number' => ' ', |
| 497: | 'street_number' => ' ', |
| 498: | 'street' => ', ', |
| 499: | 'suburb' => ' ', |
| 500: | 'city' => ' ', |
| 501: | 'state' => ' ', |
| 502: | 'postal_code' => ' ', |
| 503: | 'country' => ' ', |
| 504: | ); |
| 505: | |
| 506: | $prefix_defaults = array( |
| 507: | 'sub_number' => '', |
| 508: | 'lot_number' => '', |
| 509: | 'street_number' => '', |
| 510: | 'street' => '', |
| 511: | 'suburb' => '', |
| 512: | 'city' => '', |
| 513: | 'state' => '', |
| 514: | 'postal_code' => '', |
| 515: | 'country' => '', |
| 516: | ); |
| 517: | |
| 518: | |
| 519: | $seps = array_merge( $address_defaults, $sep ); |
| 520: | |
| 521: | $prefix = array_merge( $prefix_defaults, $prefix ); |
| 522: | |
| 523: | |
| 524: | if ( empty( $address_args ) ) { |
| 525: | $address_args = array_keys( $address_defaults ); |
| 526: | } |
| 527: | |
| 528: | global $property; |
| 529: | |
| 530: | foreach ( $address_args as $arg ) { |
| 531: | |
| 532: | if ( isset( $address_defaults[ $arg ] ) ) { |
| 533: | |
| 534: | if ( ! $property->show_street_address() && in_array( $arg, array( 'sub_number', 'lot_number', 'street_number', 'street' ), true ) ) { |
| 535: | continue; |
| 536: | } |
| 537: | |
| 538: | if ( 'suburb' === $arg && ! $property->show_suburb() ) { |
| 539: | continue; |
| 540: | } |
| 541: | |
| 542: | |
| 543: | if ( true !== $country && in_array( $arg, array( 'country' ), true ) ) { |
| 544: | continue; |
| 545: | } |
| 546: | |
| 547: | $value = get_property_meta( 'property_address_' . $arg ); |
| 548: | |
| 549: | if ( ! empty( $value ) ) { |
| 550: | $address .= $prefix[ $arg ] . get_property_meta( 'property_address_' . $arg ) . $seps[ $arg ]; |
| 551: | } |
| 552: | } |
| 553: | } |
| 554: | |
| 555: | |
| 556: | |
| 557: | |
| 558: | |
| 559: | |
| 560: | |
| 561: | |
| 562: | |
| 563: | return apply_filters( 'epl_the_address', $address ); |
| 564: | } |
| 565: | |
| 566: | |
| 567: | |
| 568: | |
| 569: | |
| 570: | |
| 571: | |
| 572: | |
| 573: | |
| 574: | |
| 575: | |
| 576: | function epl_the_status( $before = '', $after = '', $echo_output = true ) { |
| 577: | $status = epl_get_the_status(); |
| 578: | |
| 579: | $status_opts = epl_get_property_status_opts(); |
| 580: | |
| 581: | if ( strlen( $status ) === 0 ) { |
| 582: | return; |
| 583: | } |
| 584: | |
| 585: | $status = $before . $status_opts[ $status ] . $after; |
| 586: | |
| 587: | if ( $echo_output ) { |
| 588: | echo wp_kses_post( $status ); |
| 589: | } else { |
| 590: | return $status; |
| 591: | } |
| 592: | } |
| 593: | |
| 594: | |
| 595: | |
| 596: | |
| 597: | |
| 598: | |
| 599: | |
| 600: | |
| 601: | |
| 602: | function epl_get_the_status( $post = 0 ) { |
| 603: | |
| 604: | $post = get_post( $post ); |
| 605: | |
| 606: | $status = get_property_meta( 'property_status' ); |
| 607: | $status = isset( $status ) ? $status : ''; |
| 608: | $id = isset( $post->ID ) ? $post->ID : 0; |
| 609: | |
| 610: | |
| 611: | |
| 612: | |
| 613: | |
| 614: | |
| 615: | |
| 616: | |
| 617: | |
| 618: | return apply_filters( 'epl_get_the_status', $status, $id ); |
| 619: | } |
| 620: | |
| 621: | |
| 622: | |
| 623: | |
| 624: | |
| 625: | |
| 626: | |
| 627: | |
| 628: | |
| 629: | function epl_get_property_meta( $post_ID = '', $meta_key = '' ) { |
| 630: | |
| 631: | if ( empty( $post_ID ) ) { |
| 632: | $post_ID = get_the_ID(); |
| 633: | } |
| 634: | |
| 635: | if ( ! empty( $meta_key ) ) { |
| 636: | $meta_value = trim( get_post_meta( $post_ID, $meta_key, true ) ); |
| 637: | } else { |
| 638: | $meta_value = get_post_meta( $post_ID, $meta_key, false ); |
| 639: | } |
| 640: | return apply_filters( 'epl_get_property_meta_filter', $meta_value ); |
| 641: | } |
| 642: | |
| 643: | |
| 644: | |
| 645: | |
| 646: | |
| 647: | |
| 648: | |
| 649: | |
| 650: | |
| 651: | |
| 652: | function epl_the_property_meta( $post_ID = '', $meta_key = '' ) { |
| 653: | $meta_value = epl_get_property_meta( $post_ID, $meta_key ); |
| 654: | echo wp_kses_post( apply_filters( 'epl_the_property_meta_filter', $meta_value ) ); |
| 655: | } |
| 656: | |
| 657: | |
| 658: | |
| 659: | |
| 660: | |
| 661: | |
| 662: | |
| 663: | function epl_tax_location_label() { |
| 664: | $label_location = ''; |
| 665: | global $epl_settings; |
| 666: | if ( ! empty( $epl_settings ) && isset( $epl_settings['label_location'] ) ) { |
| 667: | $label_location = trim( $epl_settings['label_location'] ); |
| 668: | } |
| 669: | if ( empty( $label_location ) ) { |
| 670: | $label_location = __( 'City', 'easy-property-listings' ); |
| 671: | } |
| 672: | return $label_location; |
| 673: | } |
| 674: | |
| 675: | |
| 676: | |
| 677: | |
| 678: | |
| 679: | |
| 680: | |
| 681: | function epl_meta_location_label() { |
| 682: | $label_location = ''; |
| 683: | global $epl_settings; |
| 684: | if ( ! empty( $epl_settings ) && isset( $epl_settings['label_suburb'] ) ) { |
| 685: | $label_location = trim( $epl_settings['label_suburb'] ); |
| 686: | } |
| 687: | if ( empty( $label_location ) ) { |
| 688: | $label_location = __( 'City', 'easy-property-listings' ); |
| 689: | } |
| 690: | return $label_location; |
| 691: | } |
| 692: | |
| 693: | |
| 694: | |
| 695: | |
| 696: | |
| 697: | |
| 698: | |
| 699: | |
| 700: | |
| 701: | |
| 702: | |
| 703: | function epl_the_under_offer( $before = '', $after = '', $echo_output = true ) { |
| 704: | $under_offer = epl_get_the_under_offer(); |
| 705: | |
| 706: | $under_offer_label = epl_meta_under_offer_label(); |
| 707: | |
| 708: | if ( strlen( $under_offer ) === 0 ) { |
| 709: | return; |
| 710: | } |
| 711: | |
| 712: | if ( 'yes' !== strtolower( $under_offer ) && 'sold' !== epl_get_the_status() ) { |
| 713: | return; |
| 714: | } |
| 715: | |
| 716: | $under_offer = $before . $under_offer_label . $after; |
| 717: | |
| 718: | if ( $echo_output ) { |
| 719: | echo wp_kses_post( $under_offer ); |
| 720: | } else { |
| 721: | return $under_offer; |
| 722: | } |
| 723: | } |
| 724: | |
| 725: | |
| 726: | |
| 727: | |
| 728: | |
| 729: | |
| 730: | |
| 731: | |
| 732: | |
| 733: | function epl_get_the_under_offer( $post = 0 ) { |
| 734: | |
| 735: | $post = get_post( $post ); |
| 736: | |
| 737: | $under_offer = get_property_meta( 'property_under_offer' ); |
| 738: | $under_offer = 'yes' === get_property_meta( 'property_under_offer' ) && 'sold' !== epl_get_the_status() ? $under_offer : ''; |
| 739: | $id = isset( $post->ID ) ? $post->ID : 0; |
| 740: | |
| 741: | |
| 742: | |
| 743: | |
| 744: | |
| 745: | |
| 746: | |
| 747: | |
| 748: | |
| 749: | return apply_filters( 'epl_get_the_under_offer', $under_offer, $id ); |
| 750: | } |
| 751: | |
| 752: | |
| 753: | |
| 754: | |
| 755: | |
| 756: | |
| 757: | |
| 758: | function epl_meta_under_offer_label() { |
| 759: | $under_offer = ''; |
| 760: | global $epl_settings; |
| 761: | if ( ! empty( $epl_settings ) && isset( $epl_settings['label_under_offer'] ) ) { |
| 762: | $under_offer = trim( $epl_settings['label_under_offer'] ); |
| 763: | } |
| 764: | if ( empty( $under_offer ) ) { |
| 765: | $under_offer = __( 'Under Offer', 'easy-property-listings' ); |
| 766: | } |
| 767: | return $under_offer; |
| 768: | } |
| 769: | |
| 770: | |
| 771: | |
| 772: | |
| 773: | |
| 774: | |
| 775: | |
| 776: | function epl_listing_load_meta_property_category() { |
| 777: | $defaults = array( |
| 778: | 'House' => __( 'House', 'easy-property-listings' ), |
| 779: | 'Unit' => __( 'Unit', 'easy-property-listings' ), |
| 780: | 'Townhouse' => __( 'Townhouse', 'easy-property-listings' ), |
| 781: | 'Villa' => __( 'Villa', 'easy-property-listings' ), |
| 782: | 'Apartment' => __( 'Apartment', 'easy-property-listings' ), |
| 783: | 'Flat' => __( 'Flat', 'easy-property-listings' ), |
| 784: | 'Studio' => __( 'Studio', 'easy-property-listings' ), |
| 785: | 'Warehouse' => __( 'Warehouse', 'easy-property-listings' ), |
| 786: | 'DuplexSemi-detached' => __( 'Duplex Semi-detached', 'easy-property-listings' ), |
| 787: | 'Alpine' => __( 'Alpine', 'easy-property-listings' ), |
| 788: | 'AcreageSemi-rural' => __( 'Acreage Semi-rural', 'easy-property-listings' ), |
| 789: | 'Retirement' => __( 'Retirement', 'easy-property-listings' ), |
| 790: | 'BlockOfUnits' => __( 'Block Of Units', 'easy-property-listings' ), |
| 791: | 'Terrace' => __( 'Terrace', 'easy-property-listings' ), |
| 792: | 'ServicedApartment' => __( 'Serviced Apartment', 'easy-property-listings' ), |
| 793: | 'Other' => __( 'Other', 'easy-property-listings' ), |
| 794: | ); |
| 795: | return apply_filters( 'epl_listing_meta_property_category', $defaults ); |
| 796: | } |
| 797: | |
| 798: | |
| 799: | |
| 800: | |
| 801: | |
| 802: | |
| 803: | |
| 804: | |
| 805: | function epl_listing_meta_property_category_value( $key ) { |
| 806: | $array = epl_listing_load_meta_property_category(); |
| 807: | $key = (array) $key; |
| 808: | $values = array(); |
| 809: | foreach ( $key as $single ) { |
| 810: | $values[] = array_key_exists( $single, $array ) && ! empty( $array[ $single ] ) ? $array[ $single ] : $single; |
| 811: | } |
| 812: | |
| 813: | $value = implode( ', ', $values ); |
| 814: | |
| 815: | return apply_filters( 'epl_property_category_value', $value ); |
| 816: | } |
| 817: | |
| 818: | |
| 819: | |
| 820: | |
| 821: | |
| 822: | |
| 823: | |
| 824: | function epl_listing_load_meta_land_category() { |
| 825: | $defaults = array( |
| 826: | 'Commercial' => __( 'Commercial', 'easy-property-listings' ), |
| 827: | 'Residential' => __( 'Residential', 'easy-property-listings' ), |
| 828: | ); |
| 829: | return apply_filters( 'epl_listing_meta_land_category', $defaults ); |
| 830: | } |
| 831: | |
| 832: | |
| 833: | |
| 834: | |
| 835: | |
| 836: | |
| 837: | |
| 838: | |
| 839: | |
| 840: | function epl_listing_meta_land_category_value( $key ) { |
| 841: | $array = epl_listing_load_meta_land_category(); |
| 842: | $value = array_key_exists( $key, $array ) && ! empty( $array[ $key ] ) ? $array[ $key ] : ''; |
| 843: | |
| 844: | return $value; |
| 845: | } |
| 846: | |
| 847: | |
| 848: | |
| 849: | |
| 850: | |
| 851: | |
| 852: | |
| 853: | function epl_listing_load_meta_commercial_category() { |
| 854: | $defaults = array( |
| 855: | 'Commercial Farming' => __( 'Commercial Farming', 'easy-property-listings' ), |
| 856: | 'Land/Development' => __( 'Land/Development', 'easy-property-listings' ), |
| 857: | 'Hotel/Leisure' => __( 'Hotel/Leisure', 'easy-property-listings' ), |
| 858: | 'Industrial/Warehouse' => __( 'Industrial/Warehouse', 'easy-property-listings' ), |
| 859: | 'Medical/Consulting' => __( 'Medical/Consulting', 'easy-property-listings' ), |
| 860: | 'Offices' => __( 'Offices', 'easy-property-listings' ), |
| 861: | 'Retail' => __( 'Retail', 'easy-property-listings' ), |
| 862: | 'Showrooms/Bulky Goods' => __( 'Showrooms/Bulky Goods', 'easy-property-listings' ), |
| 863: | 'Other' => __( 'Other', 'easy-property-listings' ), |
| 864: | ); |
| 865: | return apply_filters( 'epl_listing_meta_commercial_category', $defaults ); |
| 866: | } |
| 867: | |
| 868: | |
| 869: | |
| 870: | |
| 871: | |
| 872: | |
| 873: | |
| 874: | |
| 875: | function epl_listing_load_meta_commercial_category_value( $key ) { |
| 876: | $array = epl_listing_load_meta_commercial_category(); |
| 877: | |
| 878: | if ( is_array( $key ) ) { |
| 879: | $values = array(); |
| 880: | foreach ( $key as $k ) { |
| 881: | $values[] = array_key_exists( $k, $array ) && ! empty( $array[ $k ] ) ? $array[ $k ] : ucfirst( $k ); |
| 882: | } |
| 883: | $value = implode( ', ', $values ); |
| 884: | } else { |
| 885: | $value = array_key_exists( $key, $array ) && ! empty( $array[ $key ] ) ? $array[ $key ] : ucfirst( $key ); |
| 886: | } |
| 887: | |
| 888: | return apply_filters( 'epl_meta_commercial_category_value', $value, $key, $array ); |
| 889: | } |
| 890: | |
| 891: | |
| 892: | |
| 893: | |
| 894: | |
| 895: | |
| 896: | |
| 897: | function epl_listing_load_meta_commercial_rent_period() { |
| 898: | $defaults = array( |
| 899: | 'annual' => __( 'P.A.', 'easy-property-listings' ), |
| 900: | 'nnn' => __( 'NNN', 'easy-property-listings' ), |
| 901: | 'full-service' => __( 'Full Service', 'easy-property-listings' ), |
| 902: | 'gross-lease-rates' => __( 'Gross Lease Rates', 'easy-property-listings' ), |
| 903: | ); |
| 904: | return apply_filters( 'epl_listing_meta_commercial_rent_period', $defaults ); |
| 905: | } |
| 906: | |
| 907: | |
| 908: | |
| 909: | |
| 910: | |
| 911: | |
| 912: | |
| 913: | |
| 914: | function epl_listing_load_meta_commercial_rent_period_value( $key ) { |
| 915: | $array = epl_listing_load_meta_commercial_rent_period(); |
| 916: | $value = array_key_exists( $key, $array ) && ! empty( $array[ $key ] ) ? $array[ $key ] : ''; |
| 917: | |
| 918: | return $value; |
| 919: | } |
| 920: | |
| 921: | |
| 922: | |
| 923: | |
| 924: | |
| 925: | |
| 926: | |
| 927: | function epl_listing_load_meta_rural_category() { |
| 928: | $defaults = array( |
| 929: | 'Cropping' => __( 'Cropping', 'easy-property-listings' ), |
| 930: | 'Dairy' => __( 'Dairy', 'easy-property-listings' ), |
| 931: | 'Farmlet' => __( 'Farmlet', 'easy-property-listings' ), |
| 932: | 'Horticulture' => __( 'Horticulture', 'easy-property-listings' ), |
| 933: | 'Livestock' => __( 'Livestock', 'easy-property-listings' ), |
| 934: | 'Viticulture' => __( 'Viticulture', 'easy-property-listings' ), |
| 935: | 'MixedFarming' => __( 'Mixed Farming', 'easy-property-listings' ), |
| 936: | 'Lifestyle' => __( 'Lifestyle', 'easy-property-listings' ), |
| 937: | 'Other' => __( 'Other', 'easy-property-listings' ), |
| 938: | ); |
| 939: | return apply_filters( 'epl_listing_meta_rural_category', $defaults ); |
| 940: | } |
| 941: | |
| 942: | |
| 943: | |
| 944: | |
| 945: | |
| 946: | |
| 947: | |
| 948: | |
| 949: | function epl_listing_load_meta_rural_category_value( $key ) { |
| 950: | $array = epl_listing_load_meta_rural_category(); |
| 951: | $value = array_key_exists( $key, $array ) && ! empty( $array[ $key ] ) ? $array[ $key ] : ''; |
| 952: | |
| 953: | return $value; |
| 954: | } |
| 955: | |
| 956: | |
| 957: | |
| 958: | |
| 959: | |
| 960: | |
| 961: | |
| 962: | |
| 963: | |
| 964: | |
| 965: | |
| 966: | |
| 967: | |
| 968: | function epl_feedsync_format_date( $date ) { |
| 969: | $date_example = '2014-07-22-16:45:56'; |
| 970: | |
| 971: | $tempdate = explode( '-', $date ); |
| 972: | $date = $tempdate[0]; |
| 973: | if ( isset( $tempdate[1] ) ) { |
| 974: | $date .= '-' . $tempdate[1]; |
| 975: | } |
| 976: | if ( isset( $tempdate[2] ) ) { |
| 977: | $date .= '-' . $tempdate[2]; |
| 978: | } |
| 979: | if ( isset( $tempdate[3] ) ) { |
| 980: | $date .= ' ' . $tempdate[3]; |
| 981: | } |
| 982: | |
| 983: | return gmdate( 'Y-m-d H:i:s', strtotime( $date ) ); |
| 984: | } |
| 985: | |
| 986: | |
| 987: | |
| 988: | |
| 989: | |
| 990: | |
| 991: | |
| 992: | |
| 993: | |
| 994: | |
| 995: | |
| 996: | |
| 997: | |
| 998: | function epl_feedsync_format_date_auction( $date, $time ) { |
| 999: | |
| 1000: | $date = str_replace( '/', '-', $date ); |
| 1001: | return gmdate( 'Y-M-d H:i:s', strtotime( $date . ' ' . $time ) ); |
| 1002: | } |
| 1003: | |
| 1004: | |
| 1005: | |
| 1006: | |
| 1007: | |
| 1008: | |
| 1009: | |
| 1010: | |
| 1011: | |
| 1012: | |
| 1013: | |
| 1014: | |
| 1015: | |
| 1016: | function epl_feedsync_format_sub_number( $sub_value ) { |
| 1017: | if ( $sub_value ) { |
| 1018: | $sub_value = $sub_value . '/'; |
| 1019: | return $sub_value; |
| 1020: | } |
| 1021: | } |
| 1022: | |
| 1023: | |
| 1024: | |
| 1025: | |
| 1026: | |
| 1027: | |
| 1028: | |
| 1029: | |
| 1030: | |
| 1031: | |
| 1032: | function epl_feedsync_format_strip_currency( $value ) { |
| 1033: | if ( $value ) { |
| 1034: | $value = preg_replace( apply_filters( 'epl_feedsync_format_strip_currency_symbol', '/[\$,]/' ), '', $value ); |
| 1035: | $value = floatval( $value ); |
| 1036: | return $value; |
| 1037: | } |
| 1038: | } |
| 1039: | |
| 1040: | |
| 1041: | |
| 1042: | |
| 1043: | |
| 1044: | |
| 1045: | |
| 1046: | |
| 1047: | |
| 1048: | |
| 1049: | |
| 1050: | |
| 1051: | |
| 1052: | |
| 1053: | |
| 1054: | |
| 1055: | |
| 1056: | function epl_feedsync_switch_date_time( $date_time = false, $old_time_zone = 'Australia/Perth', $new_timezone = 'Australia/Sydney', $format = 'Y-m-d H:i:s' ) { |
| 1057: | |
| 1058: | if ( ! $date_time ) { |
| 1059: | $date_time = gmdate( 'Y-m-d H:i:s', epl_get_local_timestamp() ); |
| 1060: | } |
| 1061: | if ( ! $old_time_zone ) { |
| 1062: | $old_time_zone = 'Australia/Perth'; |
| 1063: | } |
| 1064: | if ( ! $new_timezone ) { |
| 1065: | $new_timezone = 'Australia/Sydney'; |
| 1066: | } |
| 1067: | |
| 1068: | $schedule_date = new DateTime( $date_time, new DateTimeZone( $new_timezone ) ); |
| 1069: | $schedule_date->setTimeZone( new DateTimeZone( $old_time_zone ) ); |
| 1070: | return $schedule_date->format( $format ); |
| 1071: | } |
| 1072: | |
| 1073: | |
| 1074: | |
| 1075: | |
| 1076: | |
| 1077: | |
| 1078: | |
| 1079: | |
| 1080: | |
| 1081: | function epl_render_html_fields( $field = array(), $val = '' ) { |
| 1082: | EPL()->render_fields->render( $field, $val ); |
| 1083: | } |
| 1084: | |
| 1085: | |
| 1086: | |
| 1087: | |
| 1088: | |
| 1089: | |
| 1090: | |
| 1091: | |
| 1092: | |
| 1093: | function epl_get_admin_option_fields() { |
| 1094: | global $epl_settings; |
| 1095: | $opts_epl_gallery_n = array(); |
| 1096: | for ( $i = 1; $i <= 10; $i++ ) { |
| 1097: | $opts_epl_gallery_n[ $i ] = $i; |
| 1098: | } |
| 1099: | |
| 1100: | $opts_epl_property_card_excerpt_length = array(); |
| 1101: | for ( $i = 10; $i <= 55; $i++ ) { |
| 1102: | $opts_epl_property_card_excerpt_length[ $i ] = $i; |
| 1103: | } |
| 1104: | |
| 1105: | $opts_epl_features = array(); |
| 1106: | for ( $i = 1; $i <= 5; $i++ ) { |
| 1107: | $opts_epl_features[ $i ] = $i; |
| 1108: | } |
| 1109: | |
| 1110: | $opts_pages = array( '' => __( 'Select Page', 'easy-property-listings' ) ); |
| 1111: | $pages = get_pages(); |
| 1112: | |
| 1113: | if ( ! empty( $pages ) ) { |
| 1114: | foreach ( $pages as $page ) { |
| 1115: | $opts_pages[ $page->ID ] = $page->post_title; |
| 1116: | } |
| 1117: | } |
| 1118: | |
| 1119: | $get_google_maps_api_key_uri = '<a target="_blank" href="https://developers.google.com/maps/documentation/javascript/get-api-key">' . __( 'Google Maps API Key', 'easy-property-listings' ) . '</a>'; |
| 1120: | |
| 1121: | $epl_currency_positions = array( |
| 1122: | 'before' => __( 'Before - $10', 'easy-property-listings' ), |
| 1123: | 'after' => __( 'After - 10$', 'easy-property-listings' ), |
| 1124: | ); |
| 1125: | $epl_currency_types = epl_get_currencies(); |
| 1126: | $epl_post_types = epl_get_post_types(); |
| 1127: | if ( ! function_exists( 'get_editable_roles' ) ) { |
| 1128: | require_once ABSPATH . '/wp-admin/includes/user.php'; |
| 1129: | } |
| 1130: | $roles = array( |
| 1131: | 'level_10' => __( 'Administrator', 'easy-property-listings' ), |
| 1132: | 'level_7' => __( 'Editor', 'easy-property-listings' ), |
| 1133: | 'level_2' => __( 'Author', 'easy-property-listings' ), |
| 1134: | 'level_1' => __( 'Contributor', 'easy-property-listings' ), |
| 1135: | 'level_0' => __( 'Subscriber', 'easy-property-listings' ), |
| 1136: | ); |
| 1137: | $fields = array( |
| 1138: | array( |
| 1139: | 'label' => __( 'Listing Types and Location Taxonomy', 'easy-property-listings' ), |
| 1140: | 'class' => 'core', |
| 1141: | 'id' => 'general', |
| 1142: | 'help' => __( 'Select the listing types you want to enable and press Save Changes. Refresh the page to see your new activated listing types.', 'easy-property-listings' ) . '<hr/>', |
| 1143: | 'fields' => array( |
| 1144: | array( |
| 1145: | 'name' => 'activate_post_types', |
| 1146: | 'label' => __( 'Listing Types to Enable', 'easy-property-listings' ), |
| 1147: | 'type' => 'checkbox', |
| 1148: | 'opts' => $epl_post_types, |
| 1149: | 'help' => __( 'Note: If they are not visible on the front end visit Dashboard > Settings > Permalinks and press Save Changes.', 'easy-property-listings' ), |
| 1150: | ), |
| 1151: | |
| 1152: | array( |
| 1153: | 'name' => 'label_location', |
| 1154: | 'label' => __( 'Location Taxonomy', 'easy-property-listings' ), |
| 1155: | 'type' => 'text', |
| 1156: | 'help' => __( 'After changing this setting visit Dashboard > Settings > Permalinks to save the settings.', 'easy-property-listings' ), |
| 1157: | 'default' => __( 'Location', 'easy-property-listings' ), |
| 1158: | ), |
| 1159: | ), |
| 1160: | ), |
| 1161: | |
| 1162: | array( |
| 1163: | 'label' => __( 'Address', 'easy-property-listings' ), |
| 1164: | 'class' => 'core', |
| 1165: | 'id' => 'address', |
| 1166: | 'help' => __( 'Use these settings to adjust the address labels to suite your location and address format for your listings.', 'easy-property-listings' ) . '<hr/>', |
| 1167: | 'fields' => array( |
| 1168: | |
| 1169: | array( |
| 1170: | 'name' => 'label_suburb', |
| 1171: | 'label' => __( 'Suburb/Town/City Label', 'easy-property-listings' ), |
| 1172: | 'type' => 'text', |
| 1173: | 'default' => __( 'Suburb', 'easy-property-listings' ), |
| 1174: | ), |
| 1175: | |
| 1176: | array( |
| 1177: | 'name' => 'epl_enable_city_field', |
| 1178: | 'label' => __( 'Additional Address Field', 'easy-property-listings' ), |
| 1179: | 'type' => 'radio', |
| 1180: | 'opts' => array( |
| 1181: | 'yes' => __( 'Enable', 'easy-property-listings' ), |
| 1182: | 'no' => __( 'Disable', 'easy-property-listings' ), |
| 1183: | ), |
| 1184: | 'default' => 'no', |
| 1185: | 'help' => __( 'Use when you need an additional Municipality/Town/City/Region.', 'easy-property-listings' ), |
| 1186: | ), |
| 1187: | |
| 1188: | array( |
| 1189: | 'name' => 'label_city', |
| 1190: | 'label' => __( 'Additional Address Field Label', 'easy-property-listings' ), |
| 1191: | 'type' => 'text', |
| 1192: | 'default' => __( 'City', 'easy-property-listings' ), |
| 1193: | ), |
| 1194: | |
| 1195: | array( |
| 1196: | 'name' => 'label_state', |
| 1197: | 'label' => __( 'State/Province/Region Label', 'easy-property-listings' ), |
| 1198: | 'type' => 'text', |
| 1199: | 'default' => __( 'State', 'easy-property-listings' ), |
| 1200: | ), |
| 1201: | |
| 1202: | array( |
| 1203: | 'name' => 'label_postcode', |
| 1204: | 'label' => __( 'Postcode/ZIP Label', 'easy-property-listings' ), |
| 1205: | 'type' => 'text', |
| 1206: | 'default' => __( 'Postcode', 'easy-property-listings' ), |
| 1207: | ), |
| 1208: | |
| 1209: | array( |
| 1210: | 'name' => 'epl_enable_country_field', |
| 1211: | 'label' => __( 'Display Country', 'easy-property-listings' ), |
| 1212: | 'type' => 'radio', |
| 1213: | 'opts' => array( |
| 1214: | 'yes' => __( 'Enable', 'easy-property-listings' ), |
| 1215: | 'no' => __( 'Disable', 'easy-property-listings' ), |
| 1216: | ), |
| 1217: | 'default' => 'no', |
| 1218: | 'help' => __( 'Display country with listing address.', 'easy-property-listings' ), |
| 1219: | ), |
| 1220: | |
| 1221: | array( |
| 1222: | 'name' => 'epl_default_country', |
| 1223: | 'label' => __( 'Default Country', 'easy-property-listings' ), |
| 1224: | 'type' => 'select', |
| 1225: | 'opts' => epl_get_countries_list(), |
| 1226: | 'default' => 'Australia', |
| 1227: | 'help' => __( 'This is used for map when listing has no address details', 'easy-property-listings' ), |
| 1228: | ), |
| 1229: | |
| 1230: | ), |
| 1231: | ), |
| 1232: | |
| 1233: | array( |
| 1234: | 'label' => __( 'Labels', 'easy-property-listings' ), |
| 1235: | 'class' => 'core', |
| 1236: | 'id' => 'labels', |
| 1237: | 'help' => __( 'Customise the labels that are used to show the status and information on the archive and individual listing pages.', 'easy-property-listings' ) . '<hr/>', |
| 1238: | 'fields' => array( |
| 1239: | |
| 1240: | array( |
| 1241: | 'name' => 'label_new', |
| 1242: | 'label' => __( 'New/Just Listed Label', 'easy-property-listings' ), |
| 1243: | 'type' => 'text', |
| 1244: | 'default' => __( 'New', 'easy-property-listings' ), |
| 1245: | ), |
| 1246: | |
| 1247: | array( |
| 1248: | 'name' => 'sticker_new_range', |
| 1249: | 'label' => __( 'Keep Listings flagged "New" for', 'easy-property-listings' ), |
| 1250: | 'type' => 'number', |
| 1251: | 'default' => '7', |
| 1252: | 'help' => __( 'Listings will have a "NEW" Sticker for the defined number of days.', 'easy-property-listings' ), |
| 1253: | ), |
| 1254: | |
| 1255: | array( |
| 1256: | 'name' => 'label_home_open', |
| 1257: | 'label' => __( 'Home Open Label', 'easy-property-listings' ), |
| 1258: | 'type' => 'text', |
| 1259: | 'default' => __( 'Home Open', 'easy-property-listings' ), |
| 1260: | ), |
| 1261: | |
| 1262: | array( |
| 1263: | 'name' => 'label_poa', |
| 1264: | 'label' => __( 'No Price Label', 'easy-property-listings' ), |
| 1265: | 'type' => 'text', |
| 1266: | 'default' => __( 'POA', 'easy-property-listings' ), |
| 1267: | ), |
| 1268: | |
| 1269: | array( |
| 1270: | 'name' => 'label_under_offer', |
| 1271: | 'label' => __( 'Under Offer Label', 'easy-property-listings' ), |
| 1272: | 'type' => 'text', |
| 1273: | 'default' => __( 'Under Offer', 'easy-property-listings' ), |
| 1274: | ), |
| 1275: | |
| 1276: | array( |
| 1277: | 'name' => 'display_price_under_offer', |
| 1278: | 'label' => __( 'Under Offer Price Display', 'easy-property-listings' ), |
| 1279: | 'type' => 'radio', |
| 1280: | 'opts' => array( |
| 1281: | 'yes' => __( 'Show the price', 'easy-property-listings' ), |
| 1282: | 'no' => __( 'Hide the price', 'easy-property-listings' ), |
| 1283: | ), |
| 1284: | 'default' => 'no', |
| 1285: | 'help' => __( 'Example: Under Offer | $500,000', 'easy-property-listings' ) . ' <a href="' . esc_url( 'https://codex.easypropertylistings.com.au/article/626-under-offer-price-display' ) . '" target="_blank">' . __( 'Read More', 'easy-property-listings' ) . '</a>', |
| 1286: | ), |
| 1287: | |
| 1288: | array( |
| 1289: | 'name' => 'label_sold', |
| 1290: | 'label' => __( 'Sold Label', 'easy-property-listings' ), |
| 1291: | 'type' => 'text', |
| 1292: | 'default' => __( 'Sold', 'easy-property-listings' ), |
| 1293: | ), |
| 1294: | |
| 1295: | array( |
| 1296: | 'name' => 'label_leased', |
| 1297: | 'label' => __( 'Leased Label', 'easy-property-listings' ), |
| 1298: | 'type' => 'text', |
| 1299: | 'default' => __( 'Leased', 'easy-property-listings' ), |
| 1300: | ), |
| 1301: | |
| 1302: | array( |
| 1303: | 'name' => 'label_bond', |
| 1304: | 'label' => __( 'Rental Bond/Deposit Label', 'easy-property-listings' ), |
| 1305: | 'type' => 'text', |
| 1306: | 'default' => __( 'Bond', 'easy-property-listings' ), |
| 1307: | ), |
| 1308: | |
| 1309: | array( |
| 1310: | 'name' => 'display_bond', |
| 1311: | 'label' => __( 'Rental Bond/Deposit Display', 'easy-property-listings' ), |
| 1312: | 'type' => 'radio', |
| 1313: | 'opts' => array( |
| 1314: | 1 => __( 'Enable', 'easy-property-listings' ), |
| 1315: | 0 => __( 'Disable', 'easy-property-listings' ), |
| 1316: | ), |
| 1317: | 'help' => __( 'Display the Bond/Deposit on rental listings.', 'easy-property-listings' ), |
| 1318: | ), |
| 1319: | ), |
| 1320: | ), |
| 1321: | |
| 1322: | array( |
| 1323: | 'label' => __( 'Listing Single View', 'easy-property-listings' ), |
| 1324: | 'class' => 'core', |
| 1325: | 'id' => 'general', |
| 1326: | 'help' => __( 'Configure the default options when viewing a single listing.', 'easy-property-listings' ) . '<hr/>', |
| 1327: | 'fields' => array( |
| 1328: | array( |
| 1329: | 'name' => 'display_single_gallery', |
| 1330: | 'label' => __( 'Automatically display image gallery?', 'easy-property-listings' ), |
| 1331: | 'type' => 'radio', |
| 1332: | 'opts' => array( |
| 1333: | 1 => __( 'Enable', 'easy-property-listings' ), |
| 1334: | 0 => __( 'Disable', 'easy-property-listings' ), |
| 1335: | ), |
| 1336: | 'default' => 1, |
| 1337: | 'help' => __( 'Images uploaded and attached to a listing will automatically display on the single listing page.', 'easy-property-listings' ), |
| 1338: | ), |
| 1339: | |
| 1340: | array( |
| 1341: | 'name' => 'display_gallery_n', |
| 1342: | 'label' => __( 'Gallery columns?', 'easy-property-listings' ), |
| 1343: | 'type' => 'select', |
| 1344: | 'opts' => $opts_epl_gallery_n, |
| 1345: | 'default' => 4, |
| 1346: | ), |
| 1347: | |
| 1348: | array( |
| 1349: | 'name' => 'display_feature_columns', |
| 1350: | 'label' => __( 'Feature list columns?', 'easy-property-listings' ), |
| 1351: | 'type' => 'select', |
| 1352: | 'opts' => $opts_epl_features, |
| 1353: | 'default' => 2, |
| 1354: | ), |
| 1355: | |
| 1356: | array( |
| 1357: | 'name' => 'epl_video_width', |
| 1358: | 'label' => __( 'Video width on single listings', 'easy-property-listings' ), |
| 1359: | 'type' => 'number', |
| 1360: | 'help' => __( 'Width should be in pixels', 'easy-property-listings' ), |
| 1361: | ), |
| 1362: | ), |
| 1363: | ), |
| 1364: | |
| 1365: | array( |
| 1366: | 'label' => __( 'Listing Archive View', 'easy-property-listings' ), |
| 1367: | 'class' => 'core', |
| 1368: | 'id' => 'general', |
| 1369: | 'help' => __( 'Configure the default options for when viewing the archive listing pages.', 'easy-property-listings' ) . '<hr/>', |
| 1370: | 'fields' => array( |
| 1371: | array( |
| 1372: | 'name' => 'display_excerpt_length', |
| 1373: | 'label' => __( 'Excerpt words', 'easy-property-listings' ), |
| 1374: | 'type' => 'select', |
| 1375: | 'opts' => $opts_epl_property_card_excerpt_length, |
| 1376: | 'default' => 10, |
| 1377: | 'help' => __( 'This is ignored when using manual excerpts.', 'easy-property-listings' ), |
| 1378: | ), |
| 1379: | array( |
| 1380: | 'name' => 'display_archive_view_type', |
| 1381: | 'label' => __( 'Listing view type', 'easy-property-listings' ), |
| 1382: | 'type' => 'radio', |
| 1383: | 'opts' => array( |
| 1384: | 'list' => __( 'List', 'easy-property-listings' ), |
| 1385: | 'grid' => __( 'Grid', 'easy-property-listings' ), |
| 1386: | ), |
| 1387: | 'default' => 'list', |
| 1388: | ), |
| 1389: | |
| 1390: | array( |
| 1391: | 'name' => 'use_fancy_navigation', |
| 1392: | 'label' => __( 'Fancy pagination', 'easy-property-listings' ), |
| 1393: | 'type' => 'select', |
| 1394: | 'opts' => array( |
| 1395: | 0 => __( 'No, use WordPress default pagination', 'easy-property-listings' ), |
| 1396: | 1 => __( 'Yes, use fancy navigation', 'easy-property-listings' ), |
| 1397: | ), |
| 1398: | 'default' => 0, |
| 1399: | ), |
| 1400: | ), |
| 1401: | ), |
| 1402: | |
| 1403: | array( |
| 1404: | 'label' => __( 'Search Widget: Tab Labels', 'easy-property-listings' ), |
| 1405: | 'class' => 'core', |
| 1406: | 'id' => 'labels', |
| 1407: | 'help' => __( 'Customise the tab labels of the EPL - Search Widget or [listing_search] shortcode.', 'easy-property-listings' ) . '<hr/>', |
| 1408: | 'fields' => array( |
| 1409: | array( |
| 1410: | 'name' => 'widget_label_all', |
| 1411: | 'label' => __( 'All', 'easy-property-listings' ), |
| 1412: | 'type' => 'text', |
| 1413: | 'default' => __( 'All', 'easy-property-listings' ), |
| 1414: | ), |
| 1415: | array( |
| 1416: | 'name' => 'widget_label_property', |
| 1417: | 'label' => __( 'Property', 'easy-property-listings' ), |
| 1418: | 'type' => 'text', |
| 1419: | 'default' => __( 'Property', 'easy-property-listings' ), |
| 1420: | ), |
| 1421: | array( |
| 1422: | 'name' => 'widget_label_land', |
| 1423: | 'label' => __( 'Land', 'easy-property-listings' ), |
| 1424: | 'type' => 'text', |
| 1425: | 'default' => __( 'Land', 'easy-property-listings' ), |
| 1426: | ), |
| 1427: | array( |
| 1428: | 'name' => 'widget_label_rental', |
| 1429: | 'label' => __( 'Rental', 'easy-property-listings' ), |
| 1430: | 'type' => 'text', |
| 1431: | 'default' => __( 'Rental', 'easy-property-listings' ), |
| 1432: | ), |
| 1433: | array( |
| 1434: | 'name' => 'widget_label_rural', |
| 1435: | 'label' => __( 'Rural', 'easy-property-listings' ), |
| 1436: | 'type' => 'text', |
| 1437: | 'default' => __( 'Rural', 'easy-property-listings' ), |
| 1438: | ), |
| 1439: | array( |
| 1440: | 'name' => 'widget_label_commercial', |
| 1441: | 'label' => __( 'Commercial', 'easy-property-listings' ), |
| 1442: | 'type' => 'text', |
| 1443: | 'default' => __( 'Commercial', 'easy-property-listings' ), |
| 1444: | ), |
| 1445: | array( |
| 1446: | 'name' => 'widget_label_commercial_land', |
| 1447: | 'label' => __( 'Commercial Land', 'easy-property-listings' ), |
| 1448: | 'type' => 'text', |
| 1449: | 'default' => __( 'Commercial Land', 'easy-property-listings' ), |
| 1450: | ), |
| 1451: | array( |
| 1452: | 'name' => 'widget_label_business', |
| 1453: | 'label' => __( 'Business', 'easy-property-listings' ), |
| 1454: | 'type' => 'text', |
| 1455: | 'default' => __( 'Business', 'easy-property-listings' ), |
| 1456: | ), |
| 1457: | ), |
| 1458: | ), |
| 1459: | |
| 1460: | array( |
| 1461: | 'label' => __( 'Listings', 'easy-property-listings' ), |
| 1462: | 'class' => 'core', |
| 1463: | 'id' => 'admin_general', |
| 1464: | 'help' => __( 'Use the following settings to change how the Dashboard > Property or any listing of the types you have enabled display.', 'easy-property-listings' ) . '<hr/>', |
| 1465: | 'fields' => array( |
| 1466: | |
| 1467: | array( |
| 1468: | 'name' => 'epl_max_graph_sales_price', |
| 1469: | 'label' => __( 'Graph Max', 'easy-property-listings' ), |
| 1470: | 'type' => 'number', |
| 1471: | 'default' => '2000000', |
| 1472: | 'help' => __( 'Used for bar chart display on listings for sale.', 'easy-property-listings' ), |
| 1473: | ), |
| 1474: | |
| 1475: | array( |
| 1476: | 'name' => 'epl_max_graph_rent_price', |
| 1477: | 'label' => __( 'Graph Rental Max', 'easy-property-listings' ), |
| 1478: | 'type' => 'number', |
| 1479: | 'default' => '2000', |
| 1480: | 'help' => __( 'Rental range.', 'easy-property-listings' ), |
| 1481: | ), |
| 1482: | |
| 1483: | array( |
| 1484: | 'name' => 'epl_admin_thumb_size', |
| 1485: | 'label' => __( 'Image size', 'easy-property-listings' ), |
| 1486: | 'type' => 'radio', |
| 1487: | 'opts' => array( |
| 1488: | 'admin-list-thumb' => __( '100 X 100', 'easy-property-listings' ), |
| 1489: | 'epl-image-medium-crop' => __( '300 X 200', 'easy-property-listings' ), |
| 1490: | ), |
| 1491: | 'default' => 'admin-list-thumb', |
| 1492: | 'help' => __( 'Size of the image shown in listing columns in admin area', 'easy-property-listings' ), |
| 1493: | ), |
| 1494: | |
| 1495: | array( |
| 1496: | 'name' => 'admin_unique_id', |
| 1497: | 'label' => __( 'Unique Listing ID column', 'easy-property-listings' ), |
| 1498: | 'type' => 'radio', |
| 1499: | 'opts' => array( |
| 1500: | 1 => __( 'Enable', 'easy-property-listings' ), |
| 1501: | 0 => __( 'Disable', 'easy-property-listings' ), |
| 1502: | ), |
| 1503: | 'default' => 0, |
| 1504: | ), |
| 1505: | |
| 1506: | array( |
| 1507: | 'name' => 'debug', |
| 1508: | 'label' => __( 'Geocode Lat/Long results column', 'easy-property-listings' ), |
| 1509: | 'type' => 'radio', |
| 1510: | 'opts' => array( |
| 1511: | 1 => __( 'Enable', 'easy-property-listings' ), |
| 1512: | 0 => __( 'Disable', 'easy-property-listings' ), |
| 1513: | ), |
| 1514: | 'default' => 0, |
| 1515: | ), |
| 1516: | |
| 1517: | array( |
| 1518: | 'name' => 'display_hidden_fields', |
| 1519: | 'label' => __( 'Display Hidden Fields', 'easy-property-listings' ), |
| 1520: | 'type' => 'radio', |
| 1521: | 'opts' => array( |
| 1522: | 1 => __( 'Enable', 'easy-property-listings' ), |
| 1523: | 0 => __( 'Disable', 'easy-property-listings' ), |
| 1524: | ), |
| 1525: | 'help' => __( 'Display hidden fields on the edit listing screen.', 'easy-property-listings' ), |
| 1526: | 'default' => 0, |
| 1527: | ), |
| 1528: | ), |
| 1529: | ), |
| 1530: | |
| 1531: | array( |
| 1532: | 'label' => __( 'Theme Setup', 'easy-property-listings' ), |
| 1533: | 'class' => 'core', |
| 1534: | 'id' => 'theme_setup', |
| 1535: | 'help' => __( 'The following settings will use your theme templates to generate your listing pages. If your listings appear too wide or your sidebar is in the wrong place enable theme compatibility. When this is enabled you can use the included shortcodes like [listing post_type="property" tools_top="on"] to display your listings with sorting and grid options.', 'easy-property-listings' ) . '<hr/>', |
| 1536: | 'fields' => array( |
| 1537: | |
| 1538: | array( |
| 1539: | 'name' => 'epl_feeling_lucky', |
| 1540: | 'label' => __( 'Theme Compatibility', 'easy-property-listings' ), |
| 1541: | 'type' => 'radio', |
| 1542: | 'opts' => array( |
| 1543: | 'on' => __( 'Enable', 'easy-property-listings' ), |
| 1544: | 'off' => __( 'Disable', 'easy-property-listings' ), |
| 1545: | ), |
| 1546: | 'default' => 'off', |
| 1547: | 'help' => __( 'When using iThemes, Genesis frameworks or your listings look good, leave this disabled.', 'easy-property-listings' ), |
| 1548: | ), |
| 1549: | ), |
| 1550: | ), |
| 1551: | |
| 1552: | array( |
| 1553: | 'label' => __( 'Theme Setup: Featured Images', 'easy-property-listings' ), |
| 1554: | 'class' => 'core', |
| 1555: | 'id' => 'theme_setup_featured_images', |
| 1556: | 'help' => __( 'Some WordPress themes automatically display featured images on posts and pages which may cause you to see double on your listings. Use the following settings to adjust the featured image behaviour.', 'easy-property-listings' ) . '<hr/>', |
| 1557: | 'fields' => array( |
| 1558: | |
| 1559: | array( |
| 1560: | 'name' => 'help_lucky_theme_featured_image', |
| 1561: | 'type' => 'help', |
| 1562: | 'content' => __( 'Theme Featured Image Settings', 'easy-property-listings' ), |
| 1563: | ), |
| 1564: | |
| 1565: | array( |
| 1566: | 'name' => 'epl_lucky_disable_theme_single_thumb', |
| 1567: | 'label' => __( 'Single Listing', 'easy-property-listings' ), |
| 1568: | 'type' => 'checkbox_option', |
| 1569: | 'opts' => array( |
| 1570: | 'on' => __( 'Disable', 'easy-property-listings' ), |
| 1571: | ), |
| 1572: | 'default' => 'off', |
| 1573: | ), |
| 1574: | |
| 1575: | array( |
| 1576: | 'name' => 'epl_lucky_disable_archive_thumb', |
| 1577: | 'label' => __( 'Archive Listing', 'easy-property-listings' ), |
| 1578: | 'type' => 'checkbox_option', |
| 1579: | 'opts' => array( |
| 1580: | 'on' => __( 'Disable', 'easy-property-listings' ), |
| 1581: | ), |
| 1582: | 'default' => 'off', |
| 1583: | ), |
| 1584: | |
| 1585: | array( |
| 1586: | 'name' => 'help_lucky_epl_featured_image', |
| 1587: | 'type' => 'help', |
| 1588: | 'content' => '<hr/>' . __( 'Easy Property Listings Featured Image Settings', 'easy-property-listings' ), |
| 1589: | ), |
| 1590: | |
| 1591: | array( |
| 1592: | 'name' => 'epl_lucky_disable_single_thumb', |
| 1593: | 'label' => __( 'Single Listing', 'easy-property-listings' ), |
| 1594: | 'type' => 'checkbox_option', |
| 1595: | 'opts' => array( |
| 1596: | 'on' => __( 'Disable', 'easy-property-listings' ), |
| 1597: | ), |
| 1598: | 'default' => 'off', |
| 1599: | ), |
| 1600: | |
| 1601: | array( |
| 1602: | 'name' => 'epl_lucky_disable_epl_archive_thumb', |
| 1603: | 'label' => __( 'Archive Listing', 'easy-property-listings' ), |
| 1604: | 'type' => 'checkbox_option', |
| 1605: | 'opts' => array( |
| 1606: | 'on' => __( 'Disable', 'easy-property-listings' ), |
| 1607: | ), |
| 1608: | 'default' => 'off', |
| 1609: | ), |
| 1610: | ), |
| 1611: | ), |
| 1612: | |
| 1613: | array( |
| 1614: | 'label' => __( 'Currency', 'easy-property-listings' ), |
| 1615: | 'class' => 'core', |
| 1616: | 'id' => 'currency', |
| 1617: | |
| 1618: | 'help' => sprintf( __( 'Select your default currency. If you can not find the currency you are looking for, you can add additional currencies with a filter, <a href="%s" target="_blank">visit the codex to see how</a>.', 'easy-property-listings' ), esc_url( 'https://codex.easypropertylistings.com.au/article/153-eplgetcurrencies' ) ) . '<hr/>', |
| 1619: | 'fields' => array( |
| 1620: | array( |
| 1621: | 'name' => 'currency', |
| 1622: | 'label' => __( 'Currency Type', 'easy-property-listings' ), |
| 1623: | 'type' => 'select', |
| 1624: | 'opts' => $epl_currency_types, |
| 1625: | ), |
| 1626: | |
| 1627: | array( |
| 1628: | 'name' => 'currency_position', |
| 1629: | 'label' => __( 'Symbol Position', 'easy-property-listings' ), |
| 1630: | 'type' => 'select', |
| 1631: | 'opts' => $epl_currency_positions, |
| 1632: | ), |
| 1633: | |
| 1634: | array( |
| 1635: | 'name' => 'currency_thousands_separator', |
| 1636: | 'label' => __( 'Thousands Separator', 'easy-property-listings' ), |
| 1637: | 'type' => 'text', |
| 1638: | ), |
| 1639: | |
| 1640: | array( |
| 1641: | 'name' => 'currency_decimal_separator', |
| 1642: | 'label' => __( 'Decimal Separator', 'easy-property-listings' ), |
| 1643: | 'type' => 'text', |
| 1644: | ), |
| 1645: | ), |
| 1646: | ), |
| 1647: | |
| 1648: | array( |
| 1649: | 'label' => __( 'Inspection Date & Time Format', 'easy-property-listings' ), |
| 1650: | 'class' => 'core', |
| 1651: | 'id' => 'inspection_date_time', |
| 1652: | 'help' => __( 'These settings allow you to control how your inspection times display by default.', 'easy-property-listings' ) . '<hr/>', |
| 1653: | 'fields' => array( |
| 1654: | array( |
| 1655: | 'name' => 'inspection_date_format', |
| 1656: | 'label' => __( 'Date Format', 'easy-property-listings' ), |
| 1657: | 'type' => 'radio', |
| 1658: | 'opts' => array( |
| 1659: | |
| 1660: | 'd-M-Y' => gmdate( 'd-M-Y', epl_get_local_timestamp() ), |
| 1661: | 'l, dS F' => gmdate( 'l, dS F', epl_get_local_timestamp() ), |
| 1662: | 'D d M' => gmdate( 'D d M', epl_get_local_timestamp() ), |
| 1663: | 'custom_inspection_date_format' => __( 'Custom', 'easy-property-listings' ), |
| 1664: | |
| 1665: | ), |
| 1666: | ), |
| 1667: | array( |
| 1668: | 'name' => 'custom_inspection_date_format', |
| 1669: | 'label' => __( 'Custom Date Format', 'easy-property-listings' ), |
| 1670: | 'type' => 'text', |
| 1671: | ), |
| 1672: | array( |
| 1673: | 'name' => 'inspection_time_format', |
| 1674: | 'label' => __( 'Time Format', 'easy-property-listings' ), |
| 1675: | 'type' => 'radio', |
| 1676: | 'opts' => array( |
| 1677: | |
| 1678: | 'h:i A' => gmdate( 'h:i A', epl_get_local_timestamp() ), |
| 1679: | 'h:i a' => gmdate( 'h:i a', epl_get_local_timestamp() ), |
| 1680: | 'H:i' => gmdate( 'h:i', epl_get_local_timestamp() ) . __( ' ( 24 Hours Format ) ', 'easy-property-listings' ), |
| 1681: | 'custom_inspection_time_format' => __( 'Custom', 'easy-property-listings' ), |
| 1682: | |
| 1683: | ), |
| 1684: | ), |
| 1685: | array( |
| 1686: | 'name' => 'custom_inspection_time_format', |
| 1687: | 'label' => __( 'Custom Time Format', 'easy-property-listings' ), |
| 1688: | 'type' => 'text', |
| 1689: | ), |
| 1690: | ), |
| 1691: | ), |
| 1692: | |
| 1693: | array( |
| 1694: | 'label' => __( 'Contact Settings', 'easy-property-listings' ), |
| 1695: | 'class' => 'core', |
| 1696: | 'id' => 'contact', |
| 1697: | 'help' => __( 'You can allow access to the Contacts system for logged in users.', 'easy-property-listings' ) . '<hr/>', |
| 1698: | 'fields' => array( |
| 1699: | array( |
| 1700: | 'name' => 'min_contact_access', |
| 1701: | 'label' => __( 'Contact Access Level', 'easy-property-listings' ), |
| 1702: | 'type' => 'radio', |
| 1703: | 'opts' => $roles, |
| 1704: | ), |
| 1705: | |
| 1706: | ), |
| 1707: | 'default' => 'administrator', |
| 1708: | ), |
| 1709: | |
| 1710: | array( |
| 1711: | 'label' => __( 'Reports Settings', 'easy-property-listings' ), |
| 1712: | 'class' => 'core', |
| 1713: | 'id' => 'reports', |
| 1714: | 'help' => __( 'You can allow access to the Reports system for logged in users.', 'easy-property-listings' ) . '<hr/>', |
| 1715: | |
| 1716: | 'fields' => array( |
| 1717: | array( |
| 1718: | 'name' => 'min_reports_access', |
| 1719: | 'label' => __( 'Reports Access Level', 'easy-property-listings' ), |
| 1720: | 'type' => 'radio', |
| 1721: | 'opts' => $roles, |
| 1722: | ), |
| 1723: | |
| 1724: | ), |
| 1725: | 'default' => 'administrator', |
| 1726: | ), |
| 1727: | |
| 1728: | array( |
| 1729: | 'label' => __( 'Advanced Settings', 'easy-property-listings' ), |
| 1730: | 'class' => 'core', |
| 1731: | 'id' => 'advanced', |
| 1732: | |
| 1733: | 'help' => sprintf( __( 'Additional settings to control how Easy Property Listings works. For even more advanced filters and hooks, <a href="%s" target="_blank">visit the codex</a>.', 'easy-property-listings' ), esc_url( 'https://codex.easypropertylistings.com.au/' ) ) . '<hr/>', |
| 1734: | 'fields' => array( |
| 1735: | array( |
| 1736: | 'name' => 'epl_use_core_css', |
| 1737: | 'label' => __( 'Disable Styles', 'easy-property-listings' ), |
| 1738: | 'type' => 'checkbox_option', |
| 1739: | 'opts' => array( |
| 1740: | 'on' => __( 'Yes', 'easy-property-listings' ), |
| 1741: | ), |
| 1742: | 'default' => 'off', |
| 1743: | 'help' => __( 'Check this to disable all elements.', 'easy-property-listings' ), |
| 1744: | ), |
| 1745: | |
| 1746: | array( |
| 1747: | 'name' => 'epl_css_legacy', |
| 1748: | 'label' => __( 'Legacy Styles', 'easy-property-listings' ), |
| 1749: | 'type' => 'checkbox_option', |
| 1750: | 'opts' => array( |
| 1751: | 'on' => __( 'Enable', 'easy-property-listings' ), |
| 1752: | ), |
| 1753: | 'default' => 'off', |
| 1754: | 'help' => __( 'Check this to enable legacy css styles.', 'easy-property-listings' ), |
| 1755: | ), |
| 1756: | |
| 1757: | array( |
| 1758: | 'name' => 'epl_css_enhanced', |
| 1759: | 'label' => __( 'Enhanced Styles', 'easy-property-listings' ), |
| 1760: | 'type' => 'checkbox_option', |
| 1761: | 'opts' => array( |
| 1762: | 'on' => __( 'Enable', 'easy-property-listings' ), |
| 1763: | ), |
| 1764: | 'default' => 'off', |
| 1765: | 'help' => __( 'Check this to enable enhanced structural css styles. This implements inline-block mode for a better grid format on your listings.', 'easy-property-listings' ), |
| 1766: | ), |
| 1767: | |
| 1768: | array( |
| 1769: | 'name' => 'epl_icons_svg_listings', |
| 1770: | 'label' => __( 'SVG Icons for Listings', 'easy-property-listings' ), |
| 1771: | 'type' => 'checkbox_option', |
| 1772: | 'opts' => array( |
| 1773: | 'on' => __( 'Enable', 'easy-property-listings' ), |
| 1774: | ), |
| 1775: | 'default' => 'off', |
| 1776: | 'help' => __( 'Check this to enable SVG icons on listings.', 'easy-property-listings' ), |
| 1777: | ), |
| 1778: | |
| 1779: | array( |
| 1780: | 'name' => 'epl_icons_svg_author', |
| 1781: | 'label' => __( 'SVG Icons for Author Social Links', 'easy-property-listings' ), |
| 1782: | 'type' => 'checkbox_option', |
| 1783: | 'opts' => array( |
| 1784: | 'on' => __( 'Enable', 'easy-property-listings' ), |
| 1785: | ), |
| 1786: | 'default' => 'off', |
| 1787: | 'help' => __( 'Check this to enable SVG icons on author social links.', 'easy-property-listings' ), |
| 1788: | ), |
| 1789: | |
| 1790: | array( |
| 1791: | 'name' => 'epl_disable_google_api', |
| 1792: | 'label' => __( 'Google Maps API', 'easy-property-listings' ), |
| 1793: | 'type' => 'radio', |
| 1794: | 'opts' => array( |
| 1795: | '' => __( 'Enable', 'easy-property-listings' ), |
| 1796: | 'on' => __( 'Disable', 'easy-property-listings' ), |
| 1797: | ), |
| 1798: | 'default' => '', |
| 1799: | 'help' => __( 'Set to disabled if Google Maps API has already been loaded in your theme or other plugin.', 'easy-property-listings' ), |
| 1800: | |
| 1801: | ), |
| 1802: | |
| 1803: | array( |
| 1804: | 'name' => 'epl_google_api_key', |
| 1805: | 'label' => __( 'Google Maps API Key', 'easy-property-listings' ), |
| 1806: | 'type' => 'text', |
| 1807: | |
| 1808: | 'help' => sprintf( __( 'Register for a %s here.', 'easy-property-listings' ), $get_google_maps_api_key_uri ), |
| 1809: | ), |
| 1810: | |
| 1811: | array( |
| 1812: | 'name' => 'epl_plugin_mode', |
| 1813: | 'label' => __( 'Mode', 'easy-property-listings' ), |
| 1814: | 'type' => 'radio', |
| 1815: | 'opts' => array( |
| 1816: | 'development' => __( 'Development', 'easy-property-listings' ), |
| 1817: | 'production' => __( 'Production', 'easy-property-listings' ), |
| 1818: | ), |
| 1819: | 'help' => __( 'Production mode enqueue minified js & css for faster page loads.', 'easy-property-listings' ), |
| 1820: | 'default' => 'production', |
| 1821: | ), |
| 1822: | |
| 1823: | array( |
| 1824: | 'name' => 'uninstall_on_delete', |
| 1825: | 'label' => __( 'Remove Data on Uninstall?', 'easy-property-listings' ), |
| 1826: | 'type' => 'radio', |
| 1827: | 'opts' => array( |
| 1828: | 1 => __( 'Enable', 'easy-property-listings' ), |
| 1829: | 0 => __( 'Disable', 'easy-property-listings' ), |
| 1830: | ), |
| 1831: | 'help' => __( 'Select Enable if you would like EPL to completely remove all of its data when the plugin is deleted.', 'easy-property-listings' ), |
| 1832: | 'default' => 0, |
| 1833: | ), |
| 1834: | ), |
| 1835: | ), |
| 1836: | |
| 1837: | ); |
| 1838: | |
| 1839: | if ( did_action( 'elementor/loaded' ) ) { |
| 1840: | |
| 1841: | |
| 1842: | |
| 1843: | $epl_archive_type_fields = array(); |
| 1844: | $epl_archive_type_opts = array( '' => __( 'Use Default', 'easy-property-listings' ) ) + $opts_pages; |
| 1845: | |
| 1846: | foreach ( epl_get_active_post_types() as $epl_archive_type => $epl_archive_type_label ) { |
| 1847: | $epl_archive_type_fields[] = array( |
| 1848: | 'name' => 'epl_archive_page_id_' . $epl_archive_type, |
| 1849: | |
| 1850: | 'label' => sprintf( __( '%s Archive Page', 'easy-property-listings' ), $epl_archive_type_label ), |
| 1851: | 'type' => 'select', |
| 1852: | 'opts' => $epl_archive_type_opts, |
| 1853: | 'default' => '', |
| 1854: | ); |
| 1855: | } |
| 1856: | |
| 1857: | $fields[] = array( |
| 1858: | 'label' => __( 'Elementor Templates', 'easy-property-listings' ), |
| 1859: | 'class' => 'core', |
| 1860: | 'id' => 'elementor-templates', |
| 1861: | 'help' => __( 'Design listing pages in Elementor (beta).', 'easy-property-listings' ) . ' <a href="' . esc_url( 'https://codex.easypropertylistings.com.au/article/676-elementor-templates-settings' ) . '" target="_blank">' . __( 'Read More', 'easy-property-listings' ) . '</a><hr/>', |
| 1862: | 'fields' => array_merge( array( |
| 1863: | array( |
| 1864: | 'type' => 'help', |
| 1865: | 'name' => 'epl_elementor_templates_help', |
| 1866: | 'content' => sprintf( |
| 1867: | '<p><a class="button" href="%1$s" target="_blank">%2$s</a> <a class="button" href="%3$s" target="_blank">%4$s</a></p>', |
| 1868: | esc_url( admin_url( 'edit.php?post_type=elementor_library&elementor_library_type=epl-single' ) ), |
| 1869: | esc_html__( 'View Single Listing Templates', 'easy-property-listings' ), |
| 1870: | esc_url( admin_url( 'edit.php?post_type=elementor_library&elementor_library_type=epl-loop-card' ) ), |
| 1871: | esc_html__( 'View Listing Card Templates', 'easy-property-listings' ) |
| 1872: | ), |
| 1873: | ), |
| 1874: | |
| 1875: | array( |
| 1876: | 'name' => 'epl_archive_page_enabled', |
| 1877: | 'label' => __( 'Use An Elementor Page As The Archive', 'easy-property-listings' ), |
| 1878: | 'type' => 'radio', |
| 1879: | 'opts' => array( |
| 1880: | 'yes' => __( 'Enable', 'easy-property-listings' ), |
| 1881: | 'no' => __( 'Disable', 'easy-property-listings' ), |
| 1882: | ), |
| 1883: | 'default' => 'no', |
| 1884: | 'help' => __( 'Show your Elementor page instead of the listings archive.', 'easy-property-listings' ), |
| 1885: | ), |
| 1886: | |
| 1887: | array( |
| 1888: | 'name' => 'epl_archive_page_id', |
| 1889: | 'label' => __( 'Listings Archive Page', 'easy-property-listings' ), |
| 1890: | 'type' => 'select', |
| 1891: | 'opts' => $opts_pages, |
| 1892: | 'default' => '', |
| 1893: | 'help' => __( 'The page needs the Listings Results widget.', 'easy-property-listings' ), |
| 1894: | ), |
| 1895: | |
| 1896: | array( |
| 1897: | 'type' => 'help', |
| 1898: | 'name' => 'epl_archive_page_per_type_help', |
| 1899: | 'content' => '<hr/><p><strong>' . esc_html__( 'Per Listing Type Archive Pages', 'easy-property-listings' ) . '</strong><br/>' |
| 1900: | . esc_html__( 'Optional.', 'easy-property-listings' ) . '</p>', |
| 1901: | ), |
| 1902: | ), |
| 1903: | $epl_archive_type_fields, |
| 1904: | array( |
| 1905: | array( |
| 1906: | 'name' => 'epl_archive_page_apply_search', |
| 1907: | 'label' => __( 'Apply To Search Results', 'easy-property-listings' ), |
| 1908: | 'type' => 'radio', |
| 1909: | 'opts' => array( |
| 1910: | 'yes' => __( 'Enable', 'easy-property-listings' ), |
| 1911: | 'no' => __( 'Disable', 'easy-property-listings' ), |
| 1912: | ), |
| 1913: | 'default' => 'yes', |
| 1914: | ), |
| 1915: | |
| 1916: | array( |
| 1917: | 'name' => 'epl_archive_page_apply_taxonomy', |
| 1918: | 'label' => __( 'Apply To Location/Feature Archives', 'easy-property-listings' ), |
| 1919: | 'type' => 'radio', |
| 1920: | 'opts' => array( |
| 1921: | 'yes' => __( 'Enable', 'easy-property-listings' ), |
| 1922: | 'no' => __( 'Disable', 'easy-property-listings' ), |
| 1923: | ), |
| 1924: | 'default' => 'yes', |
| 1925: | ), |
| 1926: | ) ), |
| 1927: | ); |
| 1928: | } |
| 1929: | |
| 1930: | if ( defined( 'EPL_BETA_VERSIONS' ) && true === EPL_BETA_VERSIONS ) { |
| 1931: | $fields[] = array( |
| 1932: | 'label' => __( 'Beta Versions', 'easy-property-listings' ), |
| 1933: | 'class' => 'core', |
| 1934: | 'id' => 'beta-versions', |
| 1935: | 'fields' => array( |
| 1936: | array( |
| 1937: | 'name' => 'enabled_betas', |
| 1938: | 'label' => __( 'Enable Beta Versions', 'easy-property-listings' ), |
| 1939: | 'type' => 'checkbox', |
| 1940: | 'opts' => epl_get_beta_enabled_extensions(), |
| 1941: | 'help' => __( 'Checking any of the checkboxes will opt you in to receive pre-release update notifications. You can opt-out at any time. Pre-release updates do not install automatically, you will still have the opportunity to ignore update notifications.', 'easy-property-listings' ), |
| 1942: | ), |
| 1943: | |
| 1944: | ), |
| 1945: | ); |
| 1946: | } |
| 1947: | |
| 1948: | $fields = apply_filters( 'epl_display_options_filter', $fields ); |
| 1949: | return $fields; |
| 1950: | } |
| 1951: | |
| 1952: | |
| 1953: | |
| 1954: | |
| 1955: | |
| 1956: | |
| 1957: | function epl_sold_label_status_filter_callback() { |
| 1958: | global $epl_settings; |
| 1959: | $epl_settings['label_sold'] = ! isset( $epl_settings['label_sold'] ) ? '' : $epl_settings['label_sold']; |
| 1960: | $sold_label = 'Sold' !== $epl_settings['label_sold'] || ! empty( $epl_settings['label_sold'] ) ? $epl_settings['label_sold'] : __( 'Sold', 'easy-property-listings' ); |
| 1961: | return $sold_label; |
| 1962: | } |
| 1963: | add_filter( 'epl_sold_label_status_filter', 'epl_sold_label_status_filter_callback' ); |
| 1964: | |
| 1965: | |
| 1966: | |
| 1967: | |
| 1968: | |
| 1969: | |
| 1970: | function epl_under_offer_label_status_filter_callback() { |
| 1971: | global $epl_settings; |
| 1972: | $epl_settings['label_under_offer'] = ! isset( $epl_settings['label_under_offer'] ) ? '' : $epl_settings['label_under_offer']; |
| 1973: | $under_offer_label = 'Under Offer' !== $epl_settings['label_under_offer'] || ! empty( $epl_settings['label_under_offer'] ) ? $epl_settings['label_under_offer'] : __( 'Under Offer', 'easy-property-listings' ); |
| 1974: | return $under_offer_label; |
| 1975: | } |
| 1976: | add_filter( 'epl_under_offer_label_status_filter', 'epl_under_offer_label_status_filter_callback' ); |
| 1977: | |
| 1978: | |
| 1979: | |
| 1980: | |
| 1981: | |
| 1982: | |
| 1983: | function epl_leased_label_status_filter_callback() { |
| 1984: | global $epl_settings; |
| 1985: | $epl_settings['label_leased'] = ! isset( $epl_settings['label_leased'] ) ? '' : $epl_settings['label_leased']; |
| 1986: | $leased_label = 'Leased' !== $epl_settings['label_leased'] || ! empty( $epl_settings['label_leased'] ) ? $epl_settings['label_leased'] : __( 'Leased', 'easy-property-listings' ); |
| 1987: | return $leased_label; |
| 1988: | } |
| 1989: | add_filter( 'epl_leased_label_status_filter', 'epl_leased_label_status_filter_callback' ); |
| 1990: | |
| 1991: | |
| 1992: | |
| 1993: | |
| 1994: | |
| 1995: | |
| 1996: | |
| 1997: | |
| 1998: | |
| 1999: | |
| 2000: | |
| 2001: | |
| 2002: | |
| 2003: | |
| 2004: | |
| 2005: | |
| 2006: | |
| 2007: | |
| 2008: | |
| 2009: | |
| 2010: | function epl_listing_query_cache( $sql, $return_type = 'col' ) { |
| 2011: | static $memory = array(); |
| 2012: | static $checked = false; |
| 2013: | |
| 2014: | $key = md5( $return_type . '|' . $sql ); |
| 2015: | |
| 2016: | if ( isset( $memory[ $key ] ) ) { |
| 2017: | return $memory[ $key ]; |
| 2018: | } |
| 2019: | |
| 2020: | |
| 2021: | |
| 2022: | |
| 2023: | |
| 2024: | |
| 2025: | |
| 2026: | |
| 2027: | $enabled = (bool) apply_filters( 'epl_listing_query_cache_enabled', true ); |
| 2028: | |
| 2029: | if ( ! $enabled ) { |
| 2030: | $memory[ $key ] = epl_listing_query_run( $sql, $return_type ); |
| 2031: | return $memory[ $key ]; |
| 2032: | } |
| 2033: | |
| 2034: | |
| 2035: | if ( ! $checked ) { |
| 2036: | $checked = true; |
| 2037: | $stale = (int) get_option( 'epl_listing_query_cache_stale', 0 ); |
| 2038: | |
| 2039: | |
| 2040: | |
| 2041: | |
| 2042: | |
| 2043: | |
| 2044: | |
| 2045: | |
| 2046: | |
| 2047: | if ( $stale && time() - $stale > (int) apply_filters( 'epl_listing_query_cache_stale_limit', 10 * MINUTE_IN_SECONDS ) ) { |
| 2048: | epl_flush_listing_query_cache( true ); |
| 2049: | } |
| 2050: | } |
| 2051: | |
| 2052: | $transient = epl_listing_query_cache_transient( $key ); |
| 2053: | $result = get_transient( $transient ); |
| 2054: | |
| 2055: | if ( ! is_array( $result ) ) { |
| 2056: | $result = epl_listing_query_run( $sql, $return_type ); |
| 2057: | set_transient( $transient, $result, epl_listing_query_cache_expiration() ); |
| 2058: | epl_listing_query_cache_remember( $key, $sql, $return_type ); |
| 2059: | } |
| 2060: | |
| 2061: | $memory[ $key ] = $result; |
| 2062: | |
| 2063: | return $result; |
| 2064: | } |
| 2065: | |
| 2066: | |
| 2067: | |
| 2068: | |
| 2069: | |
| 2070: | |
| 2071: | |
| 2072: | |
| 2073: | |
| 2074: | |
| 2075: | |
| 2076: | function epl_listing_query_run( $sql, $return_type = 'col' ) { |
| 2077: | global $wpdb; |
| 2078: | |
| 2079: | $result = 'results' === $return_type ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); |
| 2080: | |
| 2081: | return is_array( $result ) ? $result : array(); |
| 2082: | } |
| 2083: | |
| 2084: | |
| 2085: | |
| 2086: | |
| 2087: | |
| 2088: | |
| 2089: | |
| 2090: | |
| 2091: | |
| 2092: | |
| 2093: | |
| 2094: | function epl_listing_query_cache_transient( $key, $version = null ) { |
| 2095: | if ( null === $version ) { |
| 2096: | $version = (int) get_option( 'epl_listing_query_cache_version', 1 ); |
| 2097: | } |
| 2098: | return 'epl_lqc_' . md5( $version . '|' . $key ); |
| 2099: | } |
| 2100: | |
| 2101: | |
| 2102: | |
| 2103: | |
| 2104: | |
| 2105: | |
| 2106: | |
| 2107: | |
| 2108: | function epl_listing_query_cache_expiration() { |
| 2109: | |
| 2110: | |
| 2111: | |
| 2112: | |
| 2113: | |
| 2114: | |
| 2115: | |
| 2116: | return (int) apply_filters( 'epl_listing_query_cache_expiration', 12 * HOUR_IN_SECONDS ); |
| 2117: | } |
| 2118: | |
| 2119: | |
| 2120: | |
| 2121: | |
| 2122: | |
| 2123: | |
| 2124: | |
| 2125: | |
| 2126: | |
| 2127: | |
| 2128: | |
| 2129: | |
| 2130: | |
| 2131: | |
| 2132: | function epl_listing_query_cache_remember( $key, $sql, $return_type ) { |
| 2133: | $queries = get_option( 'epl_listing_query_cache_queries', array() ); |
| 2134: | $queries = is_array( $queries ) ? $queries : array(); |
| 2135: | |
| 2136: | |
| 2137: | if ( isset( $queries[ $key ] ) && $queries[ $key ]['used'] > time() - DAY_IN_SECONDS ) { |
| 2138: | return; |
| 2139: | } |
| 2140: | |
| 2141: | $queries[ $key ] = array( |
| 2142: | 'sql' => $sql, |
| 2143: | 'return' => $return_type, |
| 2144: | 'used' => time(), |
| 2145: | ); |
| 2146: | |
| 2147: | if ( count( $queries ) > 300 ) { |
| 2148: | uasort( |
| 2149: | $queries, |
| 2150: | function ( $a, $b ) { |
| 2151: | return $b['used'] - $a['used']; |
| 2152: | } |
| 2153: | ); |
| 2154: | $queries = array_slice( $queries, 0, 300, true ); |
| 2155: | } |
| 2156: | |
| 2157: | update_option( 'epl_listing_query_cache_queries', $queries, false ); |
| 2158: | } |
| 2159: | |
| 2160: | |
| 2161: | |
| 2162: | |
| 2163: | |
| 2164: | |
| 2165: | |
| 2166: | |
| 2167: | |
| 2168: | |
| 2169: | |
| 2170: | |
| 2171: | |
| 2172: | |
| 2173: | |
| 2174: | function epl_flush_listing_query_cache( $now = false ) { |
| 2175: | if ( $now ) { |
| 2176: | $old_version = (int) get_option( 'epl_listing_query_cache_version', 1 ); |
| 2177: | update_option( 'epl_listing_query_cache_version', $old_version + 1, true ); |
| 2178: | delete_option( 'epl_listing_query_cache_stale' ); |
| 2179: | epl_delete_listing_query_cache_version( $old_version ); |
| 2180: | return; |
| 2181: | } |
| 2182: | |
| 2183: | if ( ! get_option( 'epl_listing_query_cache_stale' ) ) { |
| 2184: | update_option( 'epl_listing_query_cache_stale', time(), true ); |
| 2185: | } |
| 2186: | |
| 2187: | if ( ! wp_next_scheduled( 'epl_listing_query_cache_rebuild' ) ) { |
| 2188: | wp_schedule_single_event( time(), 'epl_listing_query_cache_rebuild' ); |
| 2189: | } |
| 2190: | |
| 2191: | |
| 2192: | if ( ! wp_doing_cron() && function_exists( 'spawn_cron' ) ) { |
| 2193: | spawn_cron(); |
| 2194: | } |
| 2195: | } |
| 2196: | |
| 2197: | |
| 2198: | |
| 2199: | |
| 2200: | |
| 2201: | |
| 2202: | |
| 2203: | |
| 2204: | |
| 2205: | |
| 2206: | |
| 2207: | function epl_rebuild_listing_query_cache() { |
| 2208: | $started = time(); |
| 2209: | $version = (int) get_option( 'epl_listing_query_cache_version', 1 ) + 1; |
| 2210: | $queries = get_option( 'epl_listing_query_cache_queries', array() ); |
| 2211: | $queries = is_array( $queries ) ? $queries : array(); |
| 2212: | |
| 2213: | if ( function_exists( 'set_time_limit' ) ) { |
| 2214: | set_time_limit( 600 ); |
| 2215: | } |
| 2216: | |
| 2217: | foreach ( $queries as $key => $query ) { |
| 2218: | if ( $query['used'] < $started - 14 * DAY_IN_SECONDS ) { |
| 2219: | unset( $queries[ $key ] ); |
| 2220: | continue; |
| 2221: | } |
| 2222: | set_transient( epl_listing_query_cache_transient( $key, $version ), epl_listing_query_run( $query['sql'], $query['return'] ), epl_listing_query_cache_expiration() ); |
| 2223: | } |
| 2224: | |
| 2225: | update_option( 'epl_listing_query_cache_queries', $queries, false ); |
| 2226: | update_option( 'epl_listing_query_cache_version', $version, true ); |
| 2227: | epl_delete_listing_query_cache_version( $version - 1, $queries ); |
| 2228: | |
| 2229: | |
| 2230: | if ( (int) get_option( 'epl_listing_query_cache_stale', 0 ) >= $started ) { |
| 2231: | wp_schedule_single_event( time(), 'epl_listing_query_cache_rebuild' ); |
| 2232: | } else { |
| 2233: | delete_option( 'epl_listing_query_cache_stale' ); |
| 2234: | } |
| 2235: | } |
| 2236: | add_action( 'epl_listing_query_cache_rebuild', 'epl_rebuild_listing_query_cache' ); |
| 2237: | |
| 2238: | |
| 2239: | |
| 2240: | |
| 2241: | |
| 2242: | |
| 2243: | |
| 2244: | |
| 2245: | |
| 2246: | |
| 2247: | |
| 2248: | |
| 2249: | |
| 2250: | |
| 2251: | function epl_delete_listing_query_cache_version( $version, $queries = null ) { |
| 2252: | if ( null === $queries ) { |
| 2253: | $queries = get_option( 'epl_listing_query_cache_queries', array() ); |
| 2254: | } |
| 2255: | |
| 2256: | foreach ( array_keys( (array) $queries ) as $key ) { |
| 2257: | delete_transient( epl_listing_query_cache_transient( $key, (int) $version ) ); |
| 2258: | } |
| 2259: | } |
| 2260: | |
| 2261: | |
| 2262: | |
| 2263: | |
| 2264: | |
| 2265: | |
| 2266: | |
| 2267: | |
| 2268: | |
| 2269: | |
| 2270: | |
| 2271: | |
| 2272: | |
| 2273: | |
| 2274: | function epl_listing_query_cache_ignores_meta_key( $meta_key ) { |
| 2275: | $ignore = is_string( $meta_key ) && 0 === strpos( $meta_key, '_' ); |
| 2276: | |
| 2277: | |
| 2278: | |
| 2279: | |
| 2280: | |
| 2281: | |
| 2282: | |
| 2283: | |
| 2284: | |
| 2285: | return (bool) apply_filters( 'epl_listing_query_cache_ignores_meta_key', $ignore, $meta_key ); |
| 2286: | } |
| 2287: | |
| 2288: | |
| 2289: | |
| 2290: | |
| 2291: | |
| 2292: | |
| 2293: | |
| 2294: | |
| 2295: | |
| 2296: | |
| 2297: | |
| 2298: | |
| 2299: | |
| 2300: | |
| 2301: | |
| 2302: | |
| 2303: | function epl_listing_query_cache_changed( $arg1 = null, $arg2 = null, $arg3 = null ) { |
| 2304: | static $scheduled = false; |
| 2305: | |
| 2306: | if ( $scheduled ) { |
| 2307: | return; |
| 2308: | } |
| 2309: | |
| 2310: | $post_id = 0; |
| 2311: | switch ( current_filter() ) { |
| 2312: | case 'transition_post_status': |
| 2313: | $post_id = $arg3 instanceof WP_Post ? $arg3->ID : 0; |
| 2314: | break; |
| 2315: | case 'added_post_meta': |
| 2316: | case 'updated_post_meta': |
| 2317: | case 'deleted_post_meta': |
| 2318: | if ( epl_listing_query_cache_ignores_meta_key( $arg3 ) ) { |
| 2319: | return; |
| 2320: | } |
| 2321: | $post_id = (int) $arg2; |
| 2322: | break; |
| 2323: | default: |
| 2324: | $post_id = (int) $arg1; |
| 2325: | } |
| 2326: | |
| 2327: | $types = array_unique( array_merge( epl_get_core_post_types(), (array) epl_all_post_types() ) ); |
| 2328: | |
| 2329: | if ( ! $post_id || ! in_array( get_post_type( $post_id ), $types, true ) ) { |
| 2330: | return; |
| 2331: | } |
| 2332: | |
| 2333: | $scheduled = true; |
| 2334: | add_action( 'shutdown', 'epl_flush_listing_query_cache' ); |
| 2335: | } |
| 2336: | add_action( 'save_post', 'epl_listing_query_cache_changed', 10, 1 ); |
| 2337: | add_action( 'before_delete_post', 'epl_listing_query_cache_changed', 10, 1 ); |
| 2338: | add_action( 'transition_post_status', 'epl_listing_query_cache_changed', 10, 3 ); |
| 2339: | add_action( 'added_post_meta', 'epl_listing_query_cache_changed', 10, 3 ); |
| 2340: | add_action( 'updated_post_meta', 'epl_listing_query_cache_changed', 10, 3 ); |
| 2341: | add_action( 'deleted_post_meta', 'epl_listing_query_cache_changed', 10, 3 ); |
| 2342: | add_action( 'set_object_terms', 'epl_listing_query_cache_changed', 10, 1 ); |
| 2343: | |
| 2344: | |
| 2345: | |
| 2346: | |
| 2347: | |
| 2348: | |
| 2349: | |
| 2350: | |
| 2351: | |
| 2352: | |
| 2353: | |
| 2354: | function epl_search_template_reserved_vars() { |
| 2355: | return array( 'atts', 'user_atts', 'atts_key', 'atts_val', 'config', 'epl_frontend_field', 'epl_frontend_fields', 'epl_settings', 'get_data', 'get_key', 'get_val', 'global_counters', 'global_tab_counter', 'is_sb_current', 'post_type_label', 'queried_post_type', 'selected_post_types', 'show_title', 'tabcounter', 'value', 'GLOBALS', 'this', '_GET', '_POST', '_REQUEST', '_SERVER', '_COOKIE', '_FILES', '_ENV', '_SESSION' ); |
| 2356: | } |
| 2357: | |
| 2358: | |
| 2359: | |
| 2360: | |
| 2361: | |
| 2362: | |
| 2363: | |
| 2364: | |
| 2365: | |
| 2366: | |
| 2367: | |
| 2368: | |
| 2369: | |
| 2370: | function epl_search_known_statuses( $requested ) { |
| 2371: | $requested = is_array( $requested ) ? $requested : explode( ',', (string) $requested ); |
| 2372: | $known = array_keys( epl_get_property_status_opts() ); |
| 2373: | $statuses = array(); |
| 2374: | |
| 2375: | foreach ( $requested as $status ) { |
| 2376: | $status = trim( (string) $status ); |
| 2377: | if ( in_array( $status, $known, true ) ) { |
| 2378: | $statuses[] = $status; |
| 2379: | } |
| 2380: | } |
| 2381: | |
| 2382: | return implode( ',', $statuses ); |
| 2383: | } |
| 2384: | |
| 2385: | |
| 2386: | |
| 2387: | |
| 2388: | |
| 2389: | |
| 2390: | |
| 2391: | |
| 2392: | |
| 2393: | |
| 2394: | |
| 2395: | |
| 2396: | |
| 2397: | |
| 2398: | |
| 2399: | |
| 2400: | |
| 2401: | |
| 2402: | |
| 2403: | |
| 2404: | |
| 2405: | |
| 2406: | |
| 2407: | function epl_get_unique_post_meta_values( $key = '', $type = '', $status = 'publish', $property_status = '' ) { |
| 2408: | |
| 2409: | |
| 2410: | $property_status = epl_search_known_statuses( $property_status ); |
| 2411: | |
| 2412: | global $wpdb; |
| 2413: | |
| 2414: | if ( empty( $key ) ) { |
| 2415: | return; |
| 2416: | } |
| 2417: | |
| 2418: | if ( empty( $type ) || 'all' === $type ) { |
| 2419: | $type = epl_get_core_post_types(); |
| 2420: | } |
| 2421: | |
| 2422: | $type = (array) $type; |
| 2423: | $type = array_map( 'sanitize_text_field', $type ); |
| 2424: | |
| 2425: | |
| 2426: | |
| 2427: | $type = array_values( array_filter( $type, 'post_type_exists' ) ); |
| 2428: | |
| 2429: | if ( empty( $type ) ) { |
| 2430: | $type = epl_get_core_post_types(); |
| 2431: | } |
| 2432: | |
| 2433: | $type_placeholders = implode( ', ', array_fill( 0, count( $type ), '%s' ) ); |
| 2434: | |
| 2435: | |
| 2436: | |
| 2437: | |
| 2438: | $status_join = ''; |
| 2439: | $status_where = ''; |
| 2440: | |
| 2441: | if ( ! empty( $property_status ) ) { |
| 2442: | |
| 2443: | $property_status = array_map( 'trim', explode( ',', $property_status ) ); |
| 2444: | |
| 2445: | if ( count( $property_status ) ) { |
| 2446: | $prepared_status_values = array(); |
| 2447: | foreach ( $property_status as $status_value ) { |
| 2448: | $prepared_status_values[] = $wpdb->prepare( '%s', $status_value ); |
| 2449: | } |
| 2450: | |
| 2451: | $status_join = "INNER JOIN {$wpdb->postmeta} pm2 ON ( pm2.post_id = pm.post_id AND pm2.meta_key = 'property_status' )"; |
| 2452: | $status_where = ' AND pm2.meta_value IN (' . implode( ',', $prepared_status_values ) . ') '; |
| 2453: | } |
| 2454: | } |
| 2455: | |
| 2456: | $query = " |
| 2457: | SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm |
| 2458: | INNER JOIN {$wpdb->posts} p ON p.ID = pm.post_id |
| 2459: | {$status_join} |
| 2460: | WHERE pm.meta_key = '%s' |
| 2461: | AND p.post_status = '%s' |
| 2462: | AND p.post_type IN ( {$type_placeholders} ) |
| 2463: | {$status_where} |
| 2464: | "; |
| 2465: | |
| 2466: | $prepare_args = array_merge( array( $key, $status ), $type ); |
| 2467: | $sql = $wpdb->prepare( $query, $prepare_args ); |
| 2468: | |
| 2469: | $res = array_filter( epl_listing_query_cache( $sql ) ); |
| 2470: | |
| 2471: | foreach ( $res as $key => &$elem ) { |
| 2472: | $elem = maybe_unserialize( $elem ); |
| 2473: | if ( ! empty( $elem ) && is_array( $elem ) ) { |
| 2474: | foreach ( $elem as $el ) { |
| 2475: | $res[] = $el; |
| 2476: | } |
| 2477: | unset( $res[ $key ] ); |
| 2478: | } |
| 2479: | } |
| 2480: | |
| 2481: | $res = array_filter( $res ); |
| 2482: | $results = array(); |
| 2483: | |
| 2484: | foreach ( $res as $s_res ) { |
| 2485: | $results[ $s_res ] = ucwords( $s_res ); |
| 2486: | } |
| 2487: | |
| 2488: | asort( $results ); |
| 2489: | |
| 2490: | return apply_filters( 'epl_get_unique_post_meta_values', $results, $key, $type ); |
| 2491: | } |
| 2492: | |
| 2493: | |
| 2494: | |
| 2495: | |
| 2496: | |
| 2497: | |
| 2498: | |
| 2499: | |
| 2500: | |
| 2501: | |
| 2502: | |
| 2503: | |
| 2504: | |
| 2505: | function epl_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null, $status = null, $day_by_day = true ) { |
| 2506: | |
| 2507: | $post_type = isset( $_GET['view'] ) ? sanitize_text_field( wp_unslash( $_GET['view'] ) ) : 'property'; |
| 2508: | $args = array( |
| 2509: | 'post_type' => $post_type, |
| 2510: | 'nopaging' => true, |
| 2511: | 'year' => $year, |
| 2512: | 'fields' => 'ids', |
| 2513: | 'post_status' => array( 'publish' ), |
| 2514: | 'update_post_meta_cache' => false, |
| 2515: | 'update_post_term_cache' => false, |
| 2516: | ); |
| 2517: | |
| 2518: | if ( in_array( $status, array( 'sold', 'leased' ), true ) ) { |
| 2519: | |
| 2520: | $month_num = is_null( $month_num ) ? 00 : $month_num; |
| 2521: | $day = is_null( $day ) ? 00 : $day; |
| 2522: | $year = is_null( $year ) ? 0000 : $year; |
| 2523: | $range = isset( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : 'other'; |
| 2524: | |
| 2525: | $args['meta_query'] = array( |
| 2526: | array( |
| 2527: | 'key' => 'property_status', |
| 2528: | 'value' => (array) $status, |
| 2529: | 'compare' => 'IN', |
| 2530: | ), |
| 2531: | ); |
| 2532: | |
| 2533: | if ( in_array( $range, array( 'other', 'last_year', 'this_year', 'last_quarter', 'this_quarter' ), true ) ) { |
| 2534: | |
| 2535: | $sold_key = 'leased' === $status ? 'property_date_available' : 'property_sold_date'; |
| 2536: | |
| 2537: | $sold_date_end = gmdate( 'Y-m-d', strtotime( $year . '-' . $month_num . '-' . $day ) ); |
| 2538: | $sold_date_start = true === $day_by_day ? $sold_date_end : gmdate( 'Y-m-01', strtotime( $year . '-' . $month_num . '-' . $day ) ); |
| 2539: | |
| 2540: | $args['meta_query'][] = array( |
| 2541: | 'key' => $sold_key, |
| 2542: | 'value' => array( $sold_date_start, $sold_date_end ), |
| 2543: | 'type' => 'DATE', |
| 2544: | 'compare' => 'BETWEEN', |
| 2545: | ); |
| 2546: | |
| 2547: | } else { |
| 2548: | |
| 2549: | $sold_key = 'leased' === $status ? 'property_date_available' : 'property_sold_date'; |
| 2550: | $sold_date = gmdate( 'Y-m-d', strtotime( $year . '-' . $month_num . '-' . $day ) ); |
| 2551: | |
| 2552: | $args['meta_query'][] = array( |
| 2553: | 'key' => $sold_key, |
| 2554: | 'value' => $sold_date, |
| 2555: | 'type' => 'DATE', |
| 2556: | ); |
| 2557: | } |
| 2558: | } else { |
| 2559: | |
| 2560: | if ( ! empty( $month_num ) ) { |
| 2561: | $args['monthnum'] = $month_num; |
| 2562: | } |
| 2563: | |
| 2564: | if ( ! empty( $day ) ) { |
| 2565: | $args['day'] = $day; |
| 2566: | } |
| 2567: | |
| 2568: | if ( ! empty( $hour ) ) { |
| 2569: | $args['hour'] = $hour; |
| 2570: | } |
| 2571: | } |
| 2572: | |
| 2573: | $args = apply_filters( 'epl_get_sales_by_date_args', $args ); |
| 2574: | |
| 2575: | $key = 'epl_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
| 2576: | $count = get_transient( $key ); |
| 2577: | if ( false === $count ) { |
| 2578: | $sales = new WP_Query( $args ); |
| 2579: | $count = (int) $sales->post_count; |
| 2580: | |
| 2581: | set_transient( $key, $count, HOUR_IN_SECONDS ); |
| 2582: | } |
| 2583: | |
| 2584: | return $count; |
| 2585: | } |
| 2586: | |
| 2587: | |
| 2588: | |
| 2589: | |
| 2590: | |
| 2591: | |
| 2592: | |
| 2593: | |
| 2594: | |
| 2595: | |
| 2596: | |
| 2597: | function epl_month_num_to_name( $n ) { |
| 2598: | $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
| 2599: | |
| 2600: | return date_i18n( 'M', $timestamp ); |
| 2601: | } |
| 2602: | |
| 2603: | |
| 2604: | |
| 2605: | |
| 2606: | |
| 2607: | |
| 2608: | |
| 2609: | |
| 2610: | |
| 2611: | |
| 2612: | |
| 2613: | function epl_get_contacts( $args = array() ) { |
| 2614: | |
| 2615: | global $wpdb; |
| 2616: | |
| 2617: | $defaults = array( |
| 2618: | 'post_type' => 'epl_contact', |
| 2619: | 'posts_per_page' => 20, |
| 2620: | 'offset' => 0, |
| 2621: | 'orderby' => 'ID', |
| 2622: | 'order' => 'DESC', |
| 2623: | ); |
| 2624: | |
| 2625: | $args = wp_parse_args( $args, $defaults ); |
| 2626: | |
| 2627: | if ( $args['posts_per_page'] < 1 ) { |
| 2628: | $args['number'] = -1; |
| 2629: | } |
| 2630: | |
| 2631: | $where = ' WHERE 1=1 '; |
| 2632: | |
| 2633: | |
| 2634: | if ( ! empty( $args['ID'] ) ) { |
| 2635: | $args['post__in'] = $args['ID']; |
| 2636: | |
| 2637: | } |
| 2638: | |
| 2639: | |
| 2640: | if ( ! empty( $args['email'] ) ) { |
| 2641: | |
| 2642: | $email_query = array( |
| 2643: | 'key' => 'contact_email', |
| 2644: | 'value' => $args['email'], |
| 2645: | ); |
| 2646: | |
| 2647: | if ( is_array( $args['email'] ) ) { |
| 2648: | $email_query['comparison'] = 'IN'; |
| 2649: | |
| 2650: | } |
| 2651: | $args['meta_query'][] = $email_query; |
| 2652: | } |
| 2653: | |
| 2654: | |
| 2655: | if ( ! empty( $args['name'] ) ) { |
| 2656: | $args['post_title'] = $args['name']; |
| 2657: | } |
| 2658: | |
| 2659: | $cache_key = md5( 'epl_contacts_' . serialize( $args ) ); |
| 2660: | |
| 2661: | $contacts = wp_cache_get( $cache_key, 'contacts' ); |
| 2662: | |
| 2663: | $args['orderby'] = esc_sql( $args['orderby'] ); |
| 2664: | $args['order'] = esc_sql( $args['order'] ); |
| 2665: | |
| 2666: | if ( false === $contacts ) { |
| 2667: | $contacts = get_posts( $args ); |
| 2668: | wp_cache_set( $cache_key, $contacts, 'contacts', 3600 ); |
| 2669: | } |
| 2670: | return $contacts; |
| 2671: | } |
| 2672: | |
| 2673: | |
| 2674: | |
| 2675: | |
| 2676: | |
| 2677: | |
| 2678: | |
| 2679: | function epl_search_listing() { |
| 2680: | $search_array = array( |
| 2681: | 's' => isset( $_POST['s'] ) ? sanitize_text_field( wp_unslash( $_POST['s'] ) ) : '', |
| 2682: | 'showposts' => 6, |
| 2683: | 'post_type' => epl_get_core_post_types(), |
| 2684: | 'post_status' => 'publish', |
| 2685: | ); |
| 2686: | $query = http_build_query( $search_array ); |
| 2687: | $listings = get_posts( $query ); |
| 2688: | if ( ! empty( $listings ) ) { |
| 2689: | echo '<ul class="epl-popup-box epl-property-suggestion epl-striped">'; |
| 2690: | foreach ( $listings as $listing ) { |
| 2691: | $status = get_post_meta( $listing->ID, 'property_status', true ); |
| 2692: | echo '<li data-id="' . esc_attr( $listing->ID ) . '"><span class="epl-listing-type">' . esc_attr( $listing->post_type ) . '</span>' . esc_attr( $listing->post_title ) . '<span class="epl-listing-status type_' . esc_attr( $status ) . '">' . esc_attr( $status ) . '</span></li>'; |
| 2693: | } |
| 2694: | echo '</ul>'; |
| 2695: | } |
| 2696: | wp_die(); |
| 2697: | } |
| 2698: | add_action( 'wp_ajax_nopriv_epl_search_listing', 'epl_search_listing' ); |
| 2699: | add_action( 'wp_ajax_epl_search_listing', 'epl_search_listing' ); |
| 2700: | |
| 2701: | |
| 2702: | |
| 2703: | |
| 2704: | |
| 2705: | |
| 2706: | |
| 2707: | function epl_get_contact_categories() { |
| 2708: | return apply_filters( |
| 2709: | 'epl_contact_categories', |
| 2710: | array( |
| 2711: | 'appraisal' => __( 'Appraisal', 'easy-property-listings' ), |
| 2712: | 'buyer' => __( 'Buyer', 'easy-property-listings' ), |
| 2713: | 'contact' => __( 'Contact', 'easy-property-listings' ), |
| 2714: | 'lead' => __( 'Lead', 'easy-property-listings' ), |
| 2715: | 'landlord' => __( 'Landlord', 'easy-property-listings' ), |
| 2716: | 'new' => __( 'New', 'easy-property-listings' ), |
| 2717: | 'past_customer' => __( 'Past Customer', 'easy-property-listings' ), |
| 2718: | 'seller' => __( 'Seller', 'easy-property-listings' ), |
| 2719: | 'tenant' => __( 'Tenant', 'easy-property-listings' ), |
| 2720: | 'widget' => __( 'Widget Lead', 'easy-property-listings' ), |
| 2721: | 'contract' => __( 'Under Contract', 'easy-property-listings' ), |
| 2722: | ) |
| 2723: | ); |
| 2724: | } |
| 2725: | |
| 2726: | |
| 2727: | |
| 2728: | |
| 2729: | |
| 2730: | |
| 2731: | |
| 2732: | |
| 2733: | |
| 2734: | |
| 2735: | function get_category_label( $category ) { |
| 2736: | foreach ( epl_get_contact_categories() as $key => $cat ) { |
| 2737: | if ( $key === $category ) { |
| 2738: | return $cat; |
| 2739: | } |
| 2740: | } |
| 2741: | return $category; |
| 2742: | } |
| 2743: | |
| 2744: | |
| 2745: | |
| 2746: | |
| 2747: | |
| 2748: | |
| 2749: | |
| 2750: | |
| 2751: | |
| 2752: | |
| 2753: | function epl_starts_with( $haystack, $needle ) { |
| 2754: | |
| 2755: | return empty( $needle ) || strrpos( $haystack, $needle, -strlen( $haystack ) ) !== false; |
| 2756: | } |
| 2757: | |
| 2758: | |
| 2759: | |
| 2760: | |
| 2761: | |
| 2762: | |
| 2763: | |
| 2764: | |
| 2765: | |
| 2766: | |
| 2767: | function epl_ends_with( $haystack, $needle ) { |
| 2768: | |
| 2769: | $temp = strlen( $haystack ) - strlen( $needle ); |
| 2770: | return empty( $needle ) || ( $temp >= 0 && strpos( $haystack, $needle, $temp ) !== false ); |
| 2771: | } |
| 2772: | |
| 2773: | |
| 2774: | |
| 2775: | |
| 2776: | |
| 2777: | |
| 2778: | |
| 2779: | |
| 2780: | |
| 2781: | |
| 2782: | function epl_parse_atts( $atts ) { |
| 2783: | |
| 2784: | $query = array(); |
| 2785: | |
| 2786: | if ( empty( $atts ) ) { |
| 2787: | return $atts; |
| 2788: | } |
| 2789: | |
| 2790: | $compare_operators = array( |
| 2791: | '_min' => '>=', |
| 2792: | '_max' => '<=', |
| 2793: | '_not_equal' => '!=', |
| 2794: | '_like' => 'LIKE', |
| 2795: | '_not_like' => 'NOT LIKE', |
| 2796: | '_exists' => 'EXISTS', |
| 2797: | '_not_exists' => 'NOT EXISTS', |
| 2798: | '_in' => 'IN', |
| 2799: | '_not_in' => 'NOT IN', |
| 2800: | '_between' => 'BETWEEN', |
| 2801: | '_not_between' => 'NOT BETWEEN', |
| 2802: | ); |
| 2803: | |
| 2804: | foreach ( $atts as $key => &$value ) { |
| 2805: | |
| 2806: | $this_query = array( |
| 2807: | 'compare' => '=', |
| 2808: | 'value' => $value, |
| 2809: | ); |
| 2810: | |
| 2811: | |
| 2812: | if ( epl_starts_with( $key, '_' ) ) { |
| 2813: | |
| 2814: | $key = preg_replace( '/^_/', '', $key ); |
| 2815: | |
| 2816: | foreach ( $compare_operators as $look_for => $compare_operator ) { |
| 2817: | |
| 2818: | if ( epl_ends_with( $key, $look_for ) ) { |
| 2819: | |
| 2820: | $key = preg_replace( '/' . $look_for . '$/', '', $key ); |
| 2821: | $this_query['compare'] = $compare_operator; |
| 2822: | |
| 2823: | if ( in_array( $look_for, array( '_in', '_not_in', '_between', '_not_between' ), true ) ) { |
| 2824: | |
| 2825: | $this_query['value'] = |
| 2826: | array_map( 'trim', explode( ',', $this_query['value'] ) ); |
| 2827: | |
| 2828: | if ( in_array( $look_for, array( '_between', '_not_between' ), true ) ) { |
| 2829: | |
| 2830: | if ( is_numeric( $this_query['value'][0] ) ) { |
| 2831: | $this_query['type'] = 'numeric'; |
| 2832: | } |
| 2833: | } |
| 2834: | } |
| 2835: | |
| 2836: | if ( in_array( $look_for, array( '_min', '_max' ), true ) ) { |
| 2837: | if ( is_numeric( $this_query['value'] ) ) { |
| 2838: | $this_query['type'] = 'numeric'; |
| 2839: | } |
| 2840: | } |
| 2841: | |
| 2842: | if ( in_array( $look_for, array( '_exists', '_not_exists' ), true ) ) { |
| 2843: | unset( $this_query['value'] ); |
| 2844: | } |
| 2845: | } |
| 2846: | } |
| 2847: | $this_query['key'] = $key; |
| 2848: | $query['meta_query'][ $key . '_clause' ] = $this_query; |
| 2849: | } |
| 2850: | } |
| 2851: | return isset( $query['meta_query'] ) ? $query['meta_query'] : array(); |
| 2852: | } |
| 2853: | |
| 2854: | |
| 2855: | |
| 2856: | |
| 2857: | |
| 2858: | |
| 2859: | |
| 2860: | |
| 2861: | function epl_get_beta_enabled_extensions() { |
| 2862: | return apply_filters( 'epl_beta_enabled_extensions', array() ); |
| 2863: | } |
| 2864: | |
| 2865: | |
| 2866: | |
| 2867: | |
| 2868: | |
| 2869: | |
| 2870: | function epl_get_countries_list() { |
| 2871: | |
| 2872: | $countries = array( 'Australia', 'Afghanistan', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antarctica', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegowina', 'Botswana', 'Bouvet Island', 'Brazil', 'British Indian Ocean Territory', 'Brunei Darussalam', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', 'China', 'Christmas Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo', 'Congo, the Democratic Republic of the', 'Cook Islands', 'Costa Rica', "Cote d'Ivoire", 'Croatia (Hrvatska)', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'East Timor', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Falkland Islands (Malvinas)', 'Faroe Islands', 'Fiji', 'Finland', 'France', 'France Metropolitan', 'French Guiana', 'French Polynesia', 'French Southern Territories', 'Gabon', 'Gambia', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Heard and Mc Donald Islands', 'Holy See (Vatican City State)', 'Honduras', 'Hong Kong', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran (Islamic Republic of)', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kiribati', "Korea, Democratic People's Republic of", 'Korea, Republic of', 'Kuwait', 'Kyrgyzstan', "Lao, People's Democratic Republic", 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libyan Arab Jamahiriya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macau', 'Macedonia, The Former Yugoslav Republic of', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Martinique', 'Mauritania', 'Mauritius', 'Mayotte', 'Mexico', 'Micronesia, Federated States of', 'Moldova, Republic of', 'Monaco', 'Mongolia', 'Montserrat', 'Morocco', 'Mozambique', 'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'Netherlands', 'Netherlands Antilles', 'New Caledonia', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Niue', 'Norfolk Island', 'Northern Mariana Islands', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Pitcairn', 'Poland', 'Portugal', 'Puerto Rico', 'Qatar', 'Reunion', 'Romania', 'Russian Federation', 'Rwanda', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia (Slovak Republic)', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'South Georgia and the South Sandwich Islands', 'Spain', 'Sri Lanka', 'St. Helena', 'St. Pierre and Miquelon', 'Sudan', 'Suriname', 'Svalbard and Jan Mayen Islands', 'Swaziland', 'Sweden', 'Switzerland', 'Syrian Arab Republic', 'Taiwan, Province of China', 'Tajikistan', 'Tanzania, United Republic of', 'Thailand', 'Togo', 'Tokelau', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Turks and Caicos Islands', 'Tuvalu', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'United States Minor Outlying Islands', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Venezuela', 'Vietnam', 'Virgin Islands (British)', 'Virgin Islands (U.S.)', 'Wallis and Futuna Islands', 'Western Sahara', 'Yemen', 'Yugoslavia', 'Zambia', 'Zimbabwe' ); |
| 2873: | |
| 2874: | return apply_filters( 'epl_get_countries_list', array_combine( $countries, $countries ) ); |
| 2875: | } |
| 2876: | |
| 2877: | |
| 2878: | |
| 2879: | |
| 2880: | |
| 2881: | |
| 2882: | |
| 2883: | function epl_get_property_status_opts() { |
| 2884: | |
| 2885: | return apply_filters( |
| 2886: | 'epl_opts_property_status_filter', |
| 2887: | array( |
| 2888: | 'current' => __( 'Current', 'easy-property-listings' ), |
| 2889: | 'sold' => array( |
| 2890: | 'label' => apply_filters( 'epl_sold_label_status_filter', __( 'Sold', 'easy-property-listings' ) ), |
| 2891: | 'exclude' => array( 'rental' ), |
| 2892: | ), |
| 2893: | 'leased' => array( |
| 2894: | 'label' => apply_filters( 'epl_leased_label_status_filter', __( 'Leased', 'easy-property-listings' ) ), |
| 2895: | 'include' => array( 'rental', 'commercial', 'commercial_land', 'business' ), |
| 2896: | ), |
| 2897: | 'withdrawn' => __( 'Withdrawn', 'easy-property-listings' ), |
| 2898: | 'offmarket' => __( 'Off Market', 'easy-property-listings' ), |
| 2899: | 'deleted' => __( 'Deleted', 'easy-property-listings' ), |
| 2900: | ) |
| 2901: | ); |
| 2902: | } |
| 2903: | |
| 2904: | |
| 2905: | |
| 2906: | |
| 2907: | |
| 2908: | |
| 2909: | |
| 2910: | |
| 2911: | |
| 2912: | function epl_get_the_status_label( $status = '' ) { |
| 2913: | |
| 2914: | $status_opts = epl_get_property_status_opts(); |
| 2915: | |
| 2916: | if ( 0 === strlen( $status ) ) { |
| 2917: | return null; |
| 2918: | } |
| 2919: | |
| 2920: | $status_data = $status_opts[ $status ]; |
| 2921: | |
| 2922: | $label = is_array( $status_data ) && isset( $status_data['label'] ) ? $status_data['label'] : $status_data; |
| 2923: | |
| 2924: | return $label; |
| 2925: | } |
| 2926: | |
| 2927: | |
| 2928: | |
| 2929: | |
| 2930: | |
| 2931: | |
| 2932: | |
| 2933: | |
| 2934: | |
| 2935: | |
| 2936: | |
| 2937: | function epl_get_available_status_list( $key, $type ) { |
| 2938: | |
| 2939: | $status_list = epl_get_unique_post_meta_values( $key, $type ); |
| 2940: | $available = array(); |
| 2941: | |
| 2942: | if ( empty( $status_list ) ) { |
| 2943: | return array(); |
| 2944: | } |
| 2945: | |
| 2946: | foreach ( $status_list as $key => $key_label ) { |
| 2947: | $available[ $key ] = epl_get_the_status_label( $key ); |
| 2948: | } |
| 2949: | |
| 2950: | return apply_filters( 'epl_get_available_status_list', $available, $key, $type ); |
| 2951: | } |
| 2952: | |
| 2953: | |
| 2954: | |
| 2955: | |
| 2956: | |
| 2957: | |
| 2958: | function epl_get_property_authority_opts() { |
| 2959: | |
| 2960: | return apply_filters( |
| 2961: | 'epl_property_authority_filter', |
| 2962: | array( |
| 2963: | 'exclusive' => __( 'Exclusive', 'easy-property-listings' ), |
| 2964: | 'auction' => __( 'Auction', 'easy-property-listings' ), |
| 2965: | 'multilist' => __( 'Multilist', 'easy-property-listings' ), |
| 2966: | 'conjunctional' => __( 'Conjunctional', 'easy-property-listings' ), |
| 2967: | 'open' => __( 'Open', 'easy-property-listings' ), |
| 2968: | 'sale' => __( 'Sale', 'easy-property-listings' ), |
| 2969: | 'setsale' => __( 'Set Sale', 'easy-property-listings' ), |
| 2970: | ) |
| 2971: | ); |
| 2972: | } |
| 2973: | |
| 2974: | |
| 2975: | |
| 2976: | |
| 2977: | |
| 2978: | |
| 2979: | function epl_get_property_exclusivity_opts() { |
| 2980: | |
| 2981: | return apply_filters( |
| 2982: | 'epl_opts_property_exclusivity_filter', |
| 2983: | array( |
| 2984: | 'exclusive' => __( 'Exclusive', 'easy-property-listings' ), |
| 2985: | 'open' => __( 'Open', 'easy-property-listings' ), |
| 2986: | ) |
| 2987: | ); |
| 2988: | } |
| 2989: | |
| 2990: | |
| 2991: | |
| 2992: | |
| 2993: | |
| 2994: | |
| 2995: | |
| 2996: | function epl_get_property_com_authority_opts() { |
| 2997: | |
| 2998: | return apply_filters( |
| 2999: | 'epl_opts_property_com_authority_filter', |
| 3000: | array( |
| 3001: | 'Forsale' => __( 'For Sale', 'easy-property-listings' ), |
| 3002: | 'auction' => __( 'Auction', 'easy-property-listings' ), |
| 3003: | 'eoi' => __( 'EOI', 'easy-property-listings' ), |
| 3004: | 'offers' => __( 'Offers', 'easy-property-listings' ), |
| 3005: | 'Sale' => __( 'Sale', 'easy-property-listings' ), |
| 3006: | 'tender' => __( 'Tender', 'easy-property-listings' ), |
| 3007: | ) |
| 3008: | ); |
| 3009: | } |
| 3010: | |
| 3011: | |
| 3012: | |
| 3013: | |
| 3014: | |
| 3015: | |
| 3016: | |
| 3017: | |
| 3018: | |
| 3019: | |
| 3020: | function epl_get_property_com_authority_label( $key ) { |
| 3021: | $opts = epl_get_property_com_authority_opts(); |
| 3022: | |
| 3023: | return ( is_scalar( $key ) && isset( $opts[ $key ] ) ) ? (string) $opts[ $key ] : ''; |
| 3024: | } |
| 3025: | |
| 3026: | |
| 3027: | |
| 3028: | |
| 3029: | |
| 3030: | |
| 3031: | |
| 3032: | |
| 3033: | function epl_get_listing_status() { |
| 3034: | global $property; |
| 3035: | |
| 3036: | $status = $property instanceof EPL_Property_Meta ? (string) $property->get_property_meta( 'property_status' ) : ''; |
| 3037: | |
| 3038: | return apply_filters( 'epl_get_listing_status', $status ); |
| 3039: | } |
| 3040: | |
| 3041: | |
| 3042: | |
| 3043: | |
| 3044: | |
| 3045: | |
| 3046: | |
| 3047: | |
| 3048: | |
| 3049: | |
| 3050: | |
| 3051: | |
| 3052: | |
| 3053: | |
| 3054: | |
| 3055: | |
| 3056: | function epl_get_listing_status_label( $labels = array() ) { |
| 3057: | global $property; |
| 3058: | |
| 3059: | if ( ! $property instanceof EPL_Property_Meta ) { |
| 3060: | return ''; |
| 3061: | } |
| 3062: | |
| 3063: | $label_sold = epl_get_option( 'label_sold', __( 'Sold', 'easy-property-listings' ) ); |
| 3064: | $label_leased = epl_get_option( 'label_leased', __( 'Leased', 'easy-property-listings' ) ); |
| 3065: | |
| 3066: | $labels = array_merge( |
| 3067: | array( |
| 3068: | 'label_for_sale' => __( 'For Sale', 'easy-property-listings' ), |
| 3069: | 'label_auction' => __( 'Auction', 'easy-property-listings' ), |
| 3070: | 'label_sold' => $label_sold, |
| 3071: | 'label_for_lease' => __( 'For Rent', 'easy-property-listings' ), |
| 3072: | 'label_leased' => $label_leased, |
| 3073: | 'label_commercial_sale' => __( 'Buy', 'easy-property-listings' ), |
| 3074: | 'label_commercial_lease' => __( 'Lease', 'easy-property-listings' ), |
| 3075: | 'label_commercial_both' => __( 'Buy or Lease', 'easy-property-listings' ), |
| 3076: | 'label_commercial_sold' => $label_sold, |
| 3077: | 'label_commercial_leased' => $label_leased, |
| 3078: | ), |
| 3079: | (array) $labels |
| 3080: | ); |
| 3081: | |
| 3082: | $post_type = $property->post_type; |
| 3083: | $status = epl_get_listing_status(); |
| 3084: | $label = ''; |
| 3085: | |
| 3086: | if ( 'rental' === $post_type ) { |
| 3087: | if ( 'current' === $status ) { |
| 3088: | $label = $labels['label_for_lease']; |
| 3089: | } elseif ( 'leased' === $status ) { |
| 3090: | $label = $labels['label_leased']; |
| 3091: | } |
| 3092: | } elseif ( 'commercial' === $post_type ) { |
| 3093: | if ( 'sold' === $status ) { |
| 3094: | $label = $labels['label_commercial_sold']; |
| 3095: | } elseif ( 'leased' === $status ) { |
| 3096: | $label = $labels['label_commercial_leased']; |
| 3097: | } elseif ( 'current' === $status ) { |
| 3098: | $type = $property->get_property_meta( 'property_com_listing_type' ); |
| 3099: | if ( 'sale' === $type ) { |
| 3100: | $label = $labels['label_commercial_sale']; |
| 3101: | } elseif ( 'lease' === $type ) { |
| 3102: | $label = $labels['label_commercial_lease']; |
| 3103: | } else { |
| 3104: | $label = $labels['label_commercial_both']; |
| 3105: | } |
| 3106: | } |
| 3107: | } elseif ( 'current' === $status ) { |
| 3108: | $label = 'auction' === $property->get_property_meta( 'property_authority' ) ? $labels['label_auction'] : $labels['label_for_sale']; |
| 3109: | } elseif ( 'sold' === $status ) { |
| 3110: | $label = $labels['label_sold']; |
| 3111: | } |
| 3112: | |
| 3113: | return apply_filters( 'epl_get_listing_status_label', $label, $status, $post_type, $labels ); |
| 3114: | } |
| 3115: | |
| 3116: | |
| 3117: | |
| 3118: | |
| 3119: | |
| 3120: | |
| 3121: | function epl_get_property_area_unit_opts() { |
| 3122: | |
| 3123: | return apply_filters( |
| 3124: | 'epl_opts_area_unit_filter', |
| 3125: | array( |
| 3126: | 'square' => __( 'Square', 'easy-property-listings' ), |
| 3127: | 'squareMeter' => __( 'Square Meter', 'easy-property-listings' ), |
| 3128: | 'acre' => __( 'Acre', 'easy-property-listings' ), |
| 3129: | 'hectare' => __( 'Hectare', 'easy-property-listings' ), |
| 3130: | 'sqft' => __( 'Square Feet', 'easy-property-listings' ), |
| 3131: | ) |
| 3132: | ); |
| 3133: | } |
| 3134: | |
| 3135: | |
| 3136: | |
| 3137: | |
| 3138: | |
| 3139: | |
| 3140: | function epl_get_property_rent_period_opts() { |
| 3141: | |
| 3142: | return apply_filters( |
| 3143: | 'epl_opts_rent_period_filter', |
| 3144: | array( |
| 3145: | 'day' => __( 'Day', 'easy-property-listings' ), |
| 3146: | 'daily' => __( 'Daily', 'easy-property-listings' ), |
| 3147: | 'week' => __( 'Week', 'easy-property-listings' ), |
| 3148: | 'weekly' => __( 'Weekly', 'easy-property-listings' ), |
| 3149: | 'month' => __( 'Month', 'easy-property-listings' ), |
| 3150: | 'monthly' => __( 'Monthly', 'easy-property-listings' ), |
| 3151: | ) |
| 3152: | ); |
| 3153: | } |
| 3154: | |
| 3155: | |
| 3156: | |
| 3157: | |
| 3158: | |
| 3159: | |
| 3160: | function epl_get_property_com_listing_type_opts() { |
| 3161: | |
| 3162: | return apply_filters( |
| 3163: | 'epl_opts_property_com_listing_type_filter', |
| 3164: | array( |
| 3165: | 'sale' => __( 'Sale', 'easy-property-listings' ), |
| 3166: | 'lease' => __( 'Lease', 'easy-property-listings' ), |
| 3167: | 'both' => __( 'Both', 'easy-property-listings' ), |
| 3168: | ) |
| 3169: | ); |
| 3170: | } |
| 3171: | |
| 3172: | |
| 3173: | |
| 3174: | |
| 3175: | |
| 3176: | |
| 3177: | function epl_get_property_com_tenancy_opts() { |
| 3178: | |
| 3179: | return apply_filters( |
| 3180: | 'epl_opts_property_com_tenancy_filter', |
| 3181: | array( |
| 3182: | 'unknown' => __( 'Unknown', 'easy-property-listings' ), |
| 3183: | 'vacant' => __( 'Vacant', 'easy-property-listings' ), |
| 3184: | 'tenanted' => __( 'Tenanted', 'easy-property-listings' ), |
| 3185: | ) |
| 3186: | ); |
| 3187: | } |
| 3188: | |
| 3189: | |
| 3190: | |
| 3191: | |
| 3192: | |
| 3193: | |
| 3194: | function epl_get_property_com_property_extent_opts() { |
| 3195: | |
| 3196: | return apply_filters( |
| 3197: | 'epl_opts_property_com_property_extent_filter', |
| 3198: | array( |
| 3199: | 'whole' => __( 'Whole', 'easy-property-listings' ), |
| 3200: | 'part' => __( 'Part', 'easy-property-listings' ), |
| 3201: | ) |
| 3202: | ); |
| 3203: | } |
| 3204: | |
| 3205: | |
| 3206: | |
| 3207: | |
| 3208: | |
| 3209: | |
| 3210: | |
| 3211: | |
| 3212: | |
| 3213: | function epl_get_author_id_from_name( $author ) { |
| 3214: | if ( is_numeric( $author ) ) { |
| 3215: | return absint( $author ); |
| 3216: | } else { |
| 3217: | $user = get_user_by( 'login', $author ); |
| 3218: | return $user->ID; |
| 3219: | } |
| 3220: | } |
| 3221: | |
| 3222: | |
| 3223: | |
| 3224: | |
| 3225: | |
| 3226: | |
| 3227: | |
| 3228: | function epl_pmxi_import_post_saved( $id ) { |
| 3229: | |
| 3230: | $post = get_post( $id ); |
| 3231: | |
| 3232: | if ( is_null( $post ) ) { |
| 3233: | return; |
| 3234: | } |
| 3235: | |
| 3236: | if ( is_epl_post( $post->post_type ) ) { |
| 3237: | |
| 3238: | if ( 'rental' === $post->post_type ) { |
| 3239: | $price = get_post_meta( $id, 'property_rent', true ); |
| 3240: | update_post_meta( $id, 'property_price_global', $price ); |
| 3241: | } elseif ( 'commercial' === $post->post_type ) { |
| 3242: | $price = get_post_meta( $id, 'property_price', true ); |
| 3243: | if ( empty( $price ) ) { |
| 3244: | $price = get_post_meta( $id, 'property_com_rent', true ); |
| 3245: | } |
| 3246: | update_post_meta( $id, 'property_price_global', $price ); |
| 3247: | } else { |
| 3248: | $price = get_post_meta( $id, 'property_price', true ); |
| 3249: | update_post_meta( $id, 'property_price_global', $price ); |
| 3250: | } |
| 3251: | } |
| 3252: | } |
| 3253: | add_action( 'pmxi_saved_post', 'epl_pmxi_import_post_saved', 10, 1 ); |
| 3254: | |
| 3255: | |
| 3256: | |
| 3257: | |
| 3258: | |
| 3259: | |
| 3260: | function epl_single_and_archive_functions() { |
| 3261: | |
| 3262: | if ( is_epl_post_single() && file_exists( get_stylesheet_directory() . '/easypropertylistings/functions-single.php' ) ) { |
| 3263: | include_once get_stylesheet_directory() . '/easypropertylistings/functions-single.php'; |
| 3264: | } |
| 3265: | |
| 3266: | if ( is_epl_post_archive() && file_exists( get_stylesheet_directory() . '/easypropertylistings/functions-archive.php' ) ) { |
| 3267: | include_once get_stylesheet_directory() . '/easypropertylistings/functions-archive.php'; |
| 3268: | } |
| 3269: | } |
| 3270: | add_action( 'wp', 'epl_single_and_archive_functions', 99 ); |
| 3271: | |
| 3272: | |
| 3273: | |
| 3274: | |
| 3275: | |
| 3276: | |
| 3277: | |
| 3278: | |
| 3279: | |
| 3280: | |
| 3281: | function epl_array_map_recursive( $callback, $input_array ) { |
| 3282: | $func = function ( $item ) use ( &$func, &$callback ) { |
| 3283: | return is_array( $item ) ? array_map( $func, $item ) : call_user_func( $callback, $item ); |
| 3284: | }; |
| 3285: | return array_map( $func, $input_array ); |
| 3286: | } |
| 3287: | |
| 3288: | |
| 3289: | |
| 3290: | |
| 3291: | |
| 3292: | |
| 3293: | |
| 3294: | |
| 3295: | |
| 3296: | function epl_sanitize_html_tags( $content ) { |
| 3297: | |
| 3298: | $allowed_tags = wp_kses_allowed_html( 'post' ); |
| 3299: | |
| 3300: | return wp_kses( $content, $allowed_tags ); |
| 3301: | } |
| 3302: | |
| 3303: | |
| 3304: | |
| 3305: | |
| 3306: | |
| 3307: | |
| 3308: | |
| 3309: | function epl_generate_unique_tab_counter() { |
| 3310: | |
| 3311: | global $epl_search_shortcode_counter; |
| 3312: | |
| 3313: | if ( empty( $epl_search_shortcode_counter ) ) { |
| 3314: | $epl_search_shortcode_counter = 0; |
| 3315: | } |
| 3316: | |
| 3317: | ++$epl_search_shortcode_counter; |
| 3318: | return $epl_search_shortcode_counter; |
| 3319: | } |
| 3320: | |
| 3321: | |
| 3322: | |
| 3323: | |
| 3324: | |
| 3325: | |
| 3326: | |
| 3327: | function epl_generate_search_instance_counter() { |
| 3328: | |
| 3329: | global $epl_search_instance_counter; |
| 3330: | |
| 3331: | if ( empty( $epl_search_instance_counter ) ) { |
| 3332: | $epl_search_instance_counter = 0; |
| 3333: | } |
| 3334: | |
| 3335: | ++$epl_search_instance_counter; |
| 3336: | return $epl_search_instance_counter; |
| 3337: | } |
| 3338: | |
| 3339: | |
| 3340: | |
| 3341: | |
| 3342: | |
| 3343: | |
| 3344: | |
| 3345: | |
| 3346: | |
| 3347: | function epl_get_property_meta_label( $meta_key ) { |
| 3348: | |
| 3349: | $value = get_property_meta( $meta_key ); |
| 3350: | $return = $value; |
| 3351: | |
| 3352: | if ( function_exists( 'epl_get_' . $meta_key . '_opts' ) ) { |
| 3353: | |
| 3354: | $labels = call_user_func( 'epl_get_' . $meta_key . '_opts' ); |
| 3355: | |
| 3356: | if ( is_string( $value ) && isset( $labels[ $value ] ) ) { |
| 3357: | $return = $labels[ $value ]; |
| 3358: | } |
| 3359: | } |
| 3360: | |
| 3361: | return $return; |
| 3362: | } |
| 3363: | |
| 3364: | |
| 3365: | |
| 3366: | |
| 3367: | |
| 3368: | |
| 3369: | function epl_get_local_timestamp() { |
| 3370: | $local_time = current_datetime(); |
| 3371: | return $local_time->getTimestamp() + $local_time->getOffset(); |
| 3372: | } |
| 3373: | |