| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | function epl_get_default_settings() { |
| 26: | |
| 27: | return array( |
| 28: | |
| 29: | 'currency' => 'AUD', |
| 30: | 'currency_position' => 'before', |
| 31: | 'currency_thousands_separator' => ',', |
| 32: | 'currency_decimal_separator' => '.', |
| 33: | 'admin_unique_id' => 0, |
| 34: | 'debug' => 0, |
| 35: | 'display_bond' => 0, |
| 36: | 'display_single_gallery' => 1, |
| 37: | 'display_gallery_n' => 4, |
| 38: | 'display_feature_columns' => 2, |
| 39: | 'display_excerpt_length' => 10, |
| 40: | 'display_archive_view_type' => 'list', |
| 41: | 'use_fancy_navigation' => 0, |
| 42: | 'label_bond' => __( 'Bond', 'easy-property-listings' ), |
| 43: | 'label_location' => __( 'Suburb', 'easy-property-listings' ), |
| 44: | 'label_suburb' => __( 'Suburb', 'easy-property-listings' ), |
| 45: | 'label_city' => __( 'City', 'easy-property-listings' ), |
| 46: | 'label_state' => __( 'State', 'easy-property-listings' ), |
| 47: | 'label_postcode' => __( 'Post Code', 'easy-property-listings' ), |
| 48: | 'label_home_open' => __( 'Home Open', 'easy-property-listings' ), |
| 49: | 'label_poa' => __( 'POA', 'easy-property-listings' ), |
| 50: | 'label_new' => __( 'New', 'easy-property-listings' ), |
| 51: | 'label_under_offer' => __( 'Under Offer', 'easy-property-listings' ), |
| 52: | 'display_price_under_offer' => 'no', |
| 53: | 'label_leased' => __( 'Leased', 'easy-property-listings' ), |
| 54: | 'label_sold' => __( 'Sold', 'easy-property-listings' ), |
| 55: | 'widget_label_all' => __( 'All', 'easy-property-listings' ), |
| 56: | 'widget_label_property' => __( 'Buy', 'easy-property-listings' ), |
| 57: | 'widget_label_land' => __( 'Land', 'easy-property-listings' ), |
| 58: | 'widget_label_rental' => __( 'Rent', 'easy-property-listings' ), |
| 59: | 'widget_label_rural' => __( 'Rural', 'easy-property-listings' ), |
| 60: | 'widget_label_business' => __( 'Business', 'easy-property-listings' ), |
| 61: | 'widget_label_commercial' => __( 'Commercial', 'easy-property-listings' ), |
| 62: | 'widget_label_commercial_land' => __( 'Commercial Land', 'easy-property-listings' ), |
| 63: | 'epl_max_graph_sales_price' => 2000000, |
| 64: | 'epl_max_graph_rent_price' => 2000, |
| 65: | 'sticker_new_range' => 7, |
| 66: | 'epl_admin_thumb_size' => 'admin-list-thumb', |
| 67: | 'epl_enable_city_field' => 'no', |
| 68: | 'epl_enable_country_field' => 'no', |
| 69: | 'epl_feeling_lucky' => 'off', |
| 70: | 'epl_lucky_disable_single_thumb' => 'off', |
| 71: | 'epl_lucky_disable_theme_single_thumb' => 'off', |
| 72: | 'epl_lucky_disable_archive_thumb' => 'off', |
| 73: | 'epl_lucky_disable_epl_archive_thumb' => 'off', |
| 74: | 'epl_use_core_css' => 'off', |
| 75: | 'epl_css_legacy' => 'off', |
| 76: | 'epl_css_enhanced' => 'on', |
| 77: | 'epl_google_api_key' => '', |
| 78: | 'epl_disable_google_api' => 'on', |
| 79: | 'uninstall_on_delete' => 0, |
| 80: | 'inspection_date_format' => 'l, dS F', |
| 81: | 'inspection_time_format' => 'h:i a', |
| 82: | 'custom_inspection_date_format' => 'l, dS F', |
| 83: | 'custom_inspection_time_format' => 'h:i a', |
| 84: | 'epl_video_width' => 600, |
| 85: | 'min_contact_access' => 'level_10', |
| 86: | 'min_reports_access' => 'level_10', |
| 87: | 'activate_post_types' => array( 'property' ), |
| 88: | 'epl_default_country' => 'Australia', |
| 89: | 'epl_icons_svg_listings' => 'on', |
| 90: | 'epl_icons_svg_author' => 'on', |
| 91: | 'epl_plugin_mode' => 'production', |
| 92: | ); |
| 93: | } |
| 94: | |
| 95: | |
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | |
| 103: | |
| 104: | |
| 105: | |
| 106: | |
| 107: | |
| 108: | |
| 109: | |
| 110: | |
| 111: | |
| 112: | function epl_install() { |
| 113: | global $wpdb, $epl_options, $wp_version; |
| 114: | |
| 115: | |
| 116: | $epl_settings = epl_settings(); |
| 117: | |
| 118: | $new_fields_defaults = epl_get_default_settings(); |
| 119: | |
| 120: | if ( ! empty( $epl_settings ) ) { |
| 121: | |
| 122: | |
| 123: | foreach ( $new_fields_defaults as $key => $value ) { |
| 124: | if ( ! isset( $epl_settings[ $key ] ) ) { |
| 125: | |
| 126: | $epl_settings[ $key ] = $value; |
| 127: | } |
| 128: | } |
| 129: | } else { |
| 130: | |
| 131: | $epl_settings = $new_fields_defaults; |
| 132: | } |
| 133: | update_option( 'epl_settings', $epl_settings ); |
| 134: | |
| 135: | |
| 136: | $current_version = get_option( 'epl_version' ); |
| 137: | if ( ! empty( $current_version ) ) { |
| 138: | update_option( 'epl_version_upgraded_from', $current_version ); |
| 139: | |
| 140: | } else { |
| 141: | $epl_data = get_plugin_data( EPL_PLUGIN_PATH . '/easy-property-listings.php' ); |
| 142: | update_option( 'epl_version', $epl_data['Version'] ); |
| 143: | } |
| 144: | |
| 145: | $notice_display = get_transient( 'epl_admin_notices_display' ); |
| 146: | |
| 147: | if ( ! $notice_display ) { |
| 148: | set_transient( 'epl_admin_notices_display', true, 60 * 60 * 24 * 14 ); |
| 149: | } |
| 150: | |
| 151: | |
| 152: | if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
| 153: | return; |
| 154: | } |
| 155: | remove_role( 'epl_crm' ); |
| 156: | |
| 157: | |
| 158: | flush_rewrite_rules(); |
| 159: | |
| 160: | |
| 161: | set_transient( '_epl_activation_redirect', true, 30 ); |
| 162: | } |
| 163: | register_activation_hook( EPL_PLUGIN_FILE, 'epl_install' ); |
| 164: | |
| 165: | |
| 166: | |
| 167: | |
| 168: | |
| 169: | |
| 170: | |
| 171: | |
| 172: | function epl_uninstall() { |
| 173: | update_option( 'epl_rewrite_rules', false ); |
| 174: | flush_rewrite_rules(); |
| 175: | } |
| 176: | register_deactivation_hook( EPL_PLUGIN_FILE, 'epl_uninstall' ); |
| 177: | |
| 178: | |
| 179: | |
| 180: | |
| 181: | |
| 182: | |
| 183: | |
| 184: | |
| 185: | |
| 186: | |
| 187: | function epl_after_install() { |
| 188: | |
| 189: | if ( ! is_admin() ) { |
| 190: | return; |
| 191: | } |
| 192: | |
| 193: | $activation_pages = get_transient( '_epl_activation_pages' ); |
| 194: | |
| 195: | |
| 196: | if ( false === $activation_pages ) { |
| 197: | return; |
| 198: | } |
| 199: | |
| 200: | |
| 201: | delete_transient( '_epl_activation_pages' ); |
| 202: | |
| 203: | do_action( 'epl_after_install', $activation_pages ); |
| 204: | } |
| 205: | add_action( 'admin_init', 'epl_after_install' ); |
| 206: | |
| 207: | |
| 208: | |
| 209: | |
| 210: | |
| 211: | |
| 212: | |
| 213: | |
| 214: | |
| 215: | |
| 216: | function epl_plugin_updates() { |
| 217: | $current_version = get_option( 'epl_version' ); |
| 218: | |
| 219: | if ( version_compare( $current_version, '1.3', '<' ) ) { |
| 220: | include EPL_PATH_UPDATES . 'epl-1.3.1.php'; |
| 221: | update_option( 'epl_version', '1.3' ); |
| 222: | } |
| 223: | if ( version_compare( $current_version, '2.1', '<' ) ) { |
| 224: | include EPL_PATH_UPDATES . 'epl-2.1.php'; |
| 225: | update_option( 'epl_version', '2.1' ); |
| 226: | } |
| 227: | if ( version_compare( $current_version, '2.1.8', '<' ) ) { |
| 228: | include EPL_PATH_UPDATES . 'epl-2.1.8.php'; |
| 229: | update_option( 'epl_version', '2.1.8' ); |
| 230: | } |
| 231: | if ( version_compare( $current_version, '2.1.11', '<' ) ) { |
| 232: | include EPL_PATH_UPDATES . 'epl-2.1.11.php'; |
| 233: | update_option( 'epl_version', '2.1.11' ); |
| 234: | } |
| 235: | if ( version_compare( $current_version, '2.2', '<' ) ) { |
| 236: | include EPL_PATH_UPDATES . 'epl-2.2.php'; |
| 237: | update_option( 'epl_version', '2.2' ); |
| 238: | } |
| 239: | if ( version_compare( $current_version, '3.0', '<' ) ) { |
| 240: | include EPL_PATH_UPDATES . 'epl-3.0.php'; |
| 241: | update_option( 'epl_version', '3.0' ); |
| 242: | } |
| 243: | if ( version_compare( $current_version, '30', '==' ) ) { |
| 244: | include EPL_PATH_UPDATES . 'epl-3.1.php'; |
| 245: | update_option( 'epl_version', '3.1' ); |
| 246: | } |
| 247: | if ( version_compare( $current_version, '3.1', '<' ) ) { |
| 248: | include EPL_PATH_UPDATES . 'epl-3.1.php'; |
| 249: | update_option( 'epl_version', '3.1' ); |
| 250: | } |
| 251: | if ( version_compare( $current_version, '3.1.16', '<' ) ) { |
| 252: | include EPL_PATH_UPDATES . 'epl-3.1.16.php'; |
| 253: | update_option( 'epl_version', '3.1.16' ); |
| 254: | } |
| 255: | if ( version_compare( $current_version, '3.2', '<' ) ) { |
| 256: | include EPL_PATH_UPDATES . 'epl-3.2.php'; |
| 257: | update_option( 'epl_version', '3.2' ); |
| 258: | } |
| 259: | if ( version_compare( $current_version, '3.2.2', '<' ) ) { |
| 260: | flush_rewrite_rules(); |
| 261: | update_option( 'epl_version', '3.2.2' ); |
| 262: | } |
| 263: | if ( version_compare( $current_version, '3.3', '<' ) ) { |
| 264: | include EPL_PATH_UPDATES . 'epl-3.3.php'; |
| 265: | flush_rewrite_rules(); |
| 266: | update_option( 'epl_version', '3.3' ); |
| 267: | } |
| 268: | if ( version_compare( $current_version, '3.6.1', '<' ) ) { |
| 269: | include EPL_PATH_UPDATES . 'epl-3.6.1.php'; |
| 270: | update_option( 'epl_version', '3.6.1' ); |
| 271: | } |
| 272: | } |
| 273: | add_action( 'admin_init', 'epl_plugin_updates' ); |
| 274: | |