| 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: | function epl_get_admin_screens() { |
| 25: | |
| 26: | $screens = array( |
| 27: | 'easy-property-listings_page_epl-addons', |
| 28: | 'easy-property-listings_page_epl-tools', |
| 29: | 'toplevel_page_epl-general', |
| 30: | 'easy-property-listings_page_epl-settings', |
| 31: | 'easy-property-listings_page_epl-contacts', |
| 32: | 'easy-property-listings_page_epl-reports', |
| 33: | 'easy-property-listings_page_epl-extensions', |
| 34: | 'easy-property-listings_page_epl-licenses', |
| 35: | 'dashboard_page_epl-about', |
| 36: | 'dashboard_page_epl-getting-started', |
| 37: | 'edit.php', |
| 38: | 'index.php', |
| 39: | 'widgets.php', |
| 40: | ); |
| 41: | |
| 42: | return apply_filters( 'epl_admin_screens', $screens ); |
| 43: | } |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | |
| 60: | function epl_admin_enqueue_scripts( $screen ) { |
| 61: | |
| 62: | $mode = epl_get_option( 'epl_plugin_mode', 'development' ); |
| 63: | $suffix = 'production' === $mode ? '.min' : ''; |
| 64: | $current_dir_path = plugins_url( '', __FILE__ ); |
| 65: | $display_address_note = sprintf( |
| 66: | |
| 67: | __( 'When \'Display Street Address\' is unchecked, the map pin uses %1$s for positioning. Refer to the %2$s codex %3$s for further details.', 'easy-property-listings' ), |
| 68: | epl_get_option( 'label_suburb' ), |
| 69: | '<a href="' . esc_url( 'https://codex.easypropertylistings.com.au/article/430-how-the-address-system-works' ) . '" target="_blank">', |
| 70: | '</a>' |
| 71: | ); |
| 72: | |
| 73: | $js_vars = array( |
| 74: | 'default_map_address' => apply_filters( 'epl_default_map_address', epl_get_option( 'epl_default_country', 'Australia' ) ), |
| 75: | 'ajax_nonce' => wp_create_nonce( 'epl_ajax_nonce' ), |
| 76: | 'display_hidden_fields' => epl_get_option( 'display_hidden_fields', 0 ), |
| 77: | 'google_api_error' => __( 'Ensure you have set a Google Maps API Key from Dashboard > Easy Property Listings > Settings', 'easy-property-listings' ), |
| 78: | 'google_api_key' => epl_get_option( 'epl_google_api_key' ), |
| 79: | 'google_map_disabled' => epl_get_option( 'epl_disable_google_api' ), |
| 80: | 'display_address_note' => esc_html( $display_address_note ), |
| 81: | 'add_images_button_text' => __( 'Add Images', 'easy-property-listings' ), |
| 82: | ); |
| 83: | |
| 84: | wp_register_script( 'epl-admin-scripts', $current_dir_path . '/js/jquery-admin-scripts' . $suffix . '.js', array( 'jquery' ), EPL_PROPERTY_VER, false ); |
| 85: | wp_register_script( 'wp-color-picker-alpha', $current_dir_path . '/js/wp-color-picker-alpha.min.js', array( 'wp-color-picker' ), EPL_PROPERTY_VER, false ); |
| 86: | |
| 87: | wp_localize_script( 'epl-admin-scripts', 'epl_admin_vars', $js_vars ); |
| 88: | |
| 89: | if ( 'edit.php' === $screen || 'post.php' === $screen || 'post-new.php' === $screen || 'easy-property-listings_page_epl-extensions' === $screen || 'easy-property-listings_page_epl-settings' === $screen || 'easy-property-listings_page_epl-extensions' === $screen ) { |
| 90: | |
| 91: | $googleapiurl = 'https://maps.googleapis.com/maps/api/js?v=3.55&callback=Function.prototype&loading=async'; |
| 92: | $epl_google_api_key = epl_get_option( 'epl_google_api_key' ); |
| 93: | if ( ! empty( $epl_google_api_key ) ) { |
| 94: | $googleapiurl = $googleapiurl . '&key=' . epl_get_option( 'epl_google_api_key' ); |
| 95: | } |
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | wp_enqueue_script( 'epl-google-map-v-3', $googleapiurl, array(), EPL_PROPERTY_VER, false ); |
| 103: | |
| 104: | wp_enqueue_style( 'epl-jquery-validation-engine-style', $current_dir_path . '/css/validationEngine-jquery' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 105: | wp_enqueue_script( 'epl-jquery-validation-engine-lang-scripts', $current_dir_path . '/js/jquery-validationEngine-en' . $suffix . '.js', array( 'jquery' ), EPL_PROPERTY_VER, false ); |
| 106: | wp_enqueue_script( 'epl-jquery-validation-engine-scripts', $current_dir_path . '/js/jquery-validationEngine' . $suffix . '.js', array( 'jquery' ), EPL_PROPERTY_VER, false ); |
| 107: | wp_enqueue_script( 'jquery-datetime-picker', $current_dir_path . '/js/jquery-datetime-picker' . $suffix . '.js', array( 'jquery' ), EPL_PROPERTY_VER, false ); |
| 108: | wp_enqueue_style( 'jquery-ui-datetime-picker-style', $current_dir_path . '/css/jquery-ui' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 109: | |
| 110: | wp_enqueue_style( 'epl-admin-styles', $current_dir_path . '/css/style-admin' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 111: | |
| 112: | } |
| 113: | |
| 114: | |
| 115: | if ( in_array( $screen, epl_get_admin_screens(), true ) ) { |
| 116: | |
| 117: | wp_enqueue_style( 'epl-admin-styles', $current_dir_path . '/css/style-admin' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 118: | } |
| 119: | |
| 120: | wp_enqueue_script( 'epl-js-lib', $current_dir_path . '/js/epl' . $suffix . '.js', array( 'jquery' ), EPL_PROPERTY_VER, false ); |
| 121: | |
| 122: | wp_enqueue_script( 'epl-admin-scripts' ); |
| 123: | } |
| 124: | add_action( 'admin_enqueue_scripts', 'epl_admin_enqueue_scripts' ); |
| 125: | |
| 126: | |
| 127: | |
| 128: | |
| 129: | |
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | |
| 135: | |
| 136: | function epl_wp_enqueue_scripts() { |
| 137: | |
| 138: | $mode = epl_get_option( 'epl_plugin_mode', 'development' ); |
| 139: | $suffix = 'production' === $mode ? '.min' : ''; |
| 140: | $epl_default_view_type = epl_get_option( 'display_archive_view_type', 'list' ); |
| 141: | $current_dir_path = plugins_url( '', __FILE__ ); |
| 142: | wp_register_script( 'epl-front-scripts', $current_dir_path . '/js/jquery-front-scripts' . $suffix . '.js', array( 'jquery' ), EPL_PROPERTY_VER, false ); |
| 143: | |
| 144: | if ( is_epl_post() && shortcode_exists( 'listing_map' ) ) { |
| 145: | |
| 146: | $googleapiurl = 'https://maps.googleapis.com/maps/api/js?v=3.55&libraries=marker&loading=async&callback=EPL_Default_Map_Loader'; |
| 147: | $epl_google_api_key = epl_get_option( 'epl_google_api_key' ); |
| 148: | if ( ! empty( $epl_google_api_key ) ) { |
| 149: | $googleapiurl = $googleapiurl . '&key=' . epl_get_option( 'epl_google_api_key' ); |
| 150: | } |
| 151: | |
| 152: | |
| 153: | if ( epl_get_option( 'epl_disable_google_api' ) !== 'on' ) { |
| 154: | wp_enqueue_script( 'epl-google-map-v-3', $googleapiurl, array(), EPL_PROPERTY_VER, false ); |
| 155: | } |
| 156: | } |
| 157: | |
| 158: | |
| 159: | if ( 'on' === epl_get_option( 'epl_use_core_css', 'off' ) ) { |
| 160: | |
| 161: | } else { |
| 162: | |
| 163: | |
| 164: | if ( epl_get_option( 'epl_css_legacy', 'off' ) === 'on' ) { |
| 165: | |
| 166: | wp_enqueue_style( 'epl-front-styles', $current_dir_path . '/css/style-legacy' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 167: | |
| 168: | } else { |
| 169: | |
| 170: | wp_enqueue_style( 'epl-css-lib', $current_dir_path . '/css/style-structure' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 171: | wp_enqueue_style( 'epl-style', $current_dir_path . '/css/style' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 172: | } |
| 173: | |
| 174: | |
| 175: | if ( epl_get_option( 'epl_css_enhanced', 'off' ) === 'on' ) { |
| 176: | wp_enqueue_style( 'epl-style-enhanced', $current_dir_path . '/css/style-enhanced' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 177: | } |
| 178: | |
| 179: | wp_enqueue_style( 'epl-field-sliders', $current_dir_path . '/css/field-slider' . $suffix . '.css', false, EPL_PROPERTY_VER ); |
| 180: | |
| 181: | |
| 182: | |
| 183: | |
| 184: | |
| 185: | if ( file_exists( get_stylesheet_directory() . '/easypropertylistings/style.css' ) ) { |
| 186: | wp_enqueue_style( 'epl-theme-style', get_stylesheet_directory_uri() . '/easypropertylistings/style.css', false, EPL_PROPERTY_VER ); |
| 187: | } |
| 188: | |
| 189: | if ( is_epl_post_archive() && file_exists( get_stylesheet_directory() . '/easypropertylistings/style-archive.css' ) ) { |
| 190: | wp_enqueue_style( 'epl-theme-style-archive', get_stylesheet_directory_uri() . '/easypropertylistings/style-archive.css', false, EPL_PROPERTY_VER ); |
| 191: | } |
| 192: | |
| 193: | if ( is_epl_post_single() && file_exists( get_stylesheet_directory() . '/easypropertylistings/style-single.css' ) ) { |
| 194: | wp_enqueue_style( 'epl-theme-style-single', get_stylesheet_directory_uri() . '/easypropertylistings/style-single.css', false, EPL_PROPERTY_VER ); |
| 195: | } |
| 196: | } |
| 197: | |
| 198: | $js_vars = array( |
| 199: | 'ajax_nonce' => wp_create_nonce( 'epl_ajax_nonce' ), |
| 200: | 'site_url' => esc_url( home_url( '/' ) ), |
| 201: | 'epl_default_view_type' => $epl_default_view_type, |
| 202: | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 203: | 'image_base' => EPL_PLUGIN_URL . 'lib/assets/images/', |
| 204: | 'field_sliders' => epl_get_field_sliders(), |
| 205: | 'range_html' => epl_get_range_slider_label_html(), |
| 206: | 'thousand_sep' => epl_get_option( 'currency_thousands_separator' ), |
| 207: | 'decimal_sep' => epl_get_option( 'currency_decimal_separator' ), |
| 208: | |
| 209: | ); |
| 210: | wp_enqueue_script( 'jquery-ui-slider' ); |
| 211: | wp_enqueue_script( 'jquery-touch-punch' ); |
| 212: | |
| 213: | wp_enqueue_script( 'epl-js-lib', $current_dir_path . '/js/epl' . $suffix . '.js', array( 'jquery' ), EPL_PROPERTY_VER, false ); |
| 214: | |
| 215: | wp_localize_script( 'epl-front-scripts', 'epl_frontend_vars', $js_vars ); |
| 216: | wp_enqueue_script( 'epl-front-scripts' ); |
| 217: | } |
| 218: | add_action( 'wp_enqueue_scripts', 'epl_wp_enqueue_scripts' ); |
| 219: | |
| 220: | |
| 221: | |
| 222: | |
| 223: | |
| 224: | |
| 225: | |
| 226: | function epl_admin_styles() { |
| 227: | |
| 228: | global $current_screen; |
| 229: | |
| 230: | if ( ! is_null( $current_screen ) && 'edit' !== $current_screen->base ) { |
| 231: | return; |
| 232: | } |
| 233: | |
| 234: | $active_size = epl_get_option( 'epl_admin_thumb_size', 'admin-list-thumb' ); |
| 235: | $sizes = get_epl_image_sizes(); |
| 236: | $width = '120px'; |
| 237: | |
| 238: | foreach ( $sizes as $size ) { |
| 239: | if ( $size['id'] === $active_size ) { |
| 240: | |
| 241: | $width = min( (int) $size['width'], 300 ) + 20 . 'px'; |
| 242: | break; |
| 243: | } |
| 244: | } |
| 245: | |
| 246: | ?> |
| 247: | <style> |
| 248: | .column-property_thumb { |
| 249: | width: <?php echo esc_html( $width ); ?>; |
| 250: | } |
| 251: | .column-property_thumb img { |
| 252: | max-width: 100%; |
| 253: | height: auto; |
| 254: | } |
| 255: | .column-property_featured { |
| 256: | width: 60px; |
| 257: | } |
| 258: | .column-property_featured .dashicons-star-filled { |
| 259: | color: orange; |
| 260: | } |
| 261: | .column-property_featured .dashicons-star-empty { |
| 262: | color: #aaaaaa; |
| 263: | } |
| 264: | .column-property_featured .epl-manage-featured { |
| 265: | display: none; |
| 266: | } |
| 267: | </style> |
| 268: | <?php |
| 269: | } |
| 270: | add_action( 'admin_head', 'epl_admin_styles' ); |
| 271: | |
| 272: | |
| 273: | |
| 274: | |
| 275: | |
| 276: | |
| 277: | |
| 278: | |
| 279: | function epl_get_range_slider_label_html() { |
| 280: | |
| 281: | ob_start(); |
| 282: | ?> |
| 283: | <span class="epl-lf-label-txt"> {range_start} {range_sep} {range_end} </span> |
| 284: | <?php |
| 285: | |
| 286: | $html = ob_get_clean(); |
| 287: | |
| 288: | return apply_filters( 'epl_get_range_slider_label_html', $html ); |
| 289: | } |
| 290: | |