Easy Property Listings 3.5.15 Code Reference
  • Package
  • Class
  • Tree
  • Todo
  • Hook Reference

Packages

  • EPL
    • Admin
      • Actions
      • Classes
        • ContactsTable
        • ReportsGraph
        • Welcome
      • Contacts
      • ContactsActions
      • ContactsFunctions
      • Elements
      • Functions
      • Help
      • HelpSingle
      • Menus
      • MenusAddons
      • MenusExtensions
      • MenusLicenses
      • Plugins
      • Reports
      • ReportsGraphing
      • User
    • Assets
      • ScriptsStyles
      • SVG
    • Classes
      • AuthorLoader
      • AuthorMeta
      • Contact
      • Cron
      • CustomPostType
      • Forms
      • License
      • ListingAdvanced
      • ListingElements
      • MetaboxesCustomFields
      • Pagination
      • PropertyMeta
      • RenderFields
      • RestAPI
      • Search
      • Session
      • Updater
    • Compatibility
      • Extensions
      • Functions
      • Shortcodes
    • Functions
      • Actions
      • ConditionalTags
      • ErrorTracking
      • Formatting
      • Front
      • Global
      • Install
      • Pagination
      • Settings
      • Templates
    • Hooks
      • EnergyCertificate
      • ExternalLinks
      • FloorPlan
      • Map
      • ReadMore
      • WebLink
    • Meta
      • InitCustomFields
      • Meta
    • PostTypes
      • Business
      • Commercial
      • CommercialLand
      • Contact
      • Functions
      • Land
      • Property
      • Rental
      • Rural
    • Shortcode
      • CommercialListingSearch
      • ContactForm
      • Listing
      • ListingAdvanced
      • ListingAuction
      • ListingCategory
      • ListingFeature
      • ListingLocation
      • ListingMetaDoc
      • ListingOpen
      • ListingResults
      • ListingSearch
      • Map
    • Taxonomy
      • BusinessCategories
      • ContactTag
      • Features
      • Location
    • Templates
      • Themes
        • iThemes
        • iThemesBuilder
    • Widget
      • Admin
        • Dashboard
      • Classes
        • Author
        • ContactCapture
        • Gallery
        • Listing
        • Search
      • Functions
  • None
  • WordPress
    • Session

Classes

  • EPL_Advanced_Shortcode_Listing
  • EPL_Author
  • EPL_Author_Loader
  • EPL_Author_Meta
  • EPL_Contact
  • EPL_Contact_Reports_Table
  • EPL_CPT
  • EPL_Cron
  • EPL_FORM_BUILDER
  • EPL_Graph
  • EPL_License
  • EPL_Listing_Elements
  • EPL_METABOX
  • EPL_Pagination_Call
  • EPL_Property_Meta
  • EPL_Render_Fields
  • EPL_Rest_API
  • EPL_SEARCH
  • EPL_Search_Fields
  • EPL_Session
  • EPL_SL_Plugin_Updater
  • EPL_Welcome
  • EPL_Widget_Author
  • EPL_Widget_Contact_Capture
  • EPL_Widget_Property_Gallery
  • EPL_Widget_Property_Search
  • EPL_Widget_Recent_Property

Functions

  • EPL
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 
<?php
/**
 * Install Function
 *
 * @package     EPL
 * @subpackage  Functions/Install
 * @copyright   Copyright (c) 2020, Merv Barrett
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       1.0
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Get array of default settings
 *
 * @return array
 * @since 3.3.5
 */
function epl_get_default_settings() {

    return array(

        'currency'                             => 'AUD',
        'currency_position'                    => 'before',
        'currency_thousands_separator'         => ',',
        'currency_decimal_separator'           => '.',
        'admin_unique_id'                      => 0,
        'debug'                                => 0,
        'display_bond'                         => 0,
        'display_single_gallery'               => 1,
        'display_gallery_n'                    => 4,
        'display_feature_columns'              => 2,
        'display_excerpt_length'               => 10,
        'display_archive_view_type'            => 'list',
        'use_fancy_navigation'                 => 0,
        'label_bond'                           => __( 'Bond', 'easy-property-listings' ),
        'label_location'                       => __( 'Suburb', 'easy-property-listings' ),
        'label_suburb'                         => __( 'Suburb', 'easy-property-listings' ),
        'label_city'                           => __( 'City', 'easy-property-listings' ),
        'label_state'                          => __( 'State', 'easy-property-listings' ),
        'label_postcode'                       => __( 'Post Code', 'easy-property-listings' ),
        'label_home_open'                      => __( 'Home Open', 'easy-property-listings' ),
        'label_poa'                            => __( 'POA', 'easy-property-listings' ),
        'label_new'                            => __( 'New', 'easy-property-listings' ),
        'label_under_offer'                    => __( 'Under Offer', 'easy-property-listings' ),
        'label_leased'                         => __( 'Leased', 'easy-property-listings' ),
        'label_sold'                           => __( 'Sold', 'easy-property-listings' ),
        'widget_label_all'                     => __( 'All', 'easy-property-listings' ),
        'widget_label_property'                => __( 'Buy', 'easy-property-listings' ),
        'widget_label_land'                    => __( 'Land', 'easy-property-listings' ),
        'widget_label_rental'                  => __( 'Rent', 'easy-property-listings' ),
        'widget_label_rural'                   => __( 'Rural', 'easy-property-listings' ),
        'widget_label_business'                => __( 'Business', 'easy-property-listings' ),
        'widget_label_commercial'              => __( 'Commercial', 'easy-property-listings' ),
        'widget_label_commercial_land'         => __( 'Commercial Land', 'easy-property-listings' ),
        'epl_max_graph_sales_price'            => 2000000,
        'epl_max_graph_rent_price'             => 2000,
        'sticker_new_range'                    => 7,
        'epl_admin_thumb_size'                 => 'admin-list-thumb',
        'epl_enable_city_field'                => 'no',
        'epl_enable_country_field'             => 'no',
        'epl_feeling_lucky'                    => 'off',
        'epl_lucky_disable_single_thumb'       => 'off',
        'epl_lucky_disable_theme_single_thumb' => 'off',
        'epl_lucky_disable_archive_thumb'      => 'off',
        'epl_lucky_disable_epl_archive_thumb'  => 'off',
        'epl_use_core_css'                     => 'off', // Means Enable CSS.
        'epl_css_legacy'                       => 'off', // Legacy styles disabled by default.
        'epl_css_enhanced'                     => 'on', // Enhanced styles enabled for new installations by default.
        'epl_google_api_key'                   => '',
        'epl_disable_google_api'               => 'on',
        'uninstall_on_delete'                  => 0,
        'inspection_date_format'               => 'l, dS F',
        'inspection_time_format'               => 'h:i a',
        'custom_inspection_date_format'        => 'l, dS F',
        'custom_inspection_time_format'        => 'h:i a',
        'epl_video_width'                      => 600,
        'min_contact_access'                   => 'level_10',
        'min_reports_access'                   => 'level_10',
        'activate_post_types'                  => array( 'property' ),
        'epl_default_country'                  => 'Australia',
        'epl_icons_svg_listings'               => 'on',
        'epl_icons_svg_author'                 => 'on',
        'epl_plugin_mode'                      => 'production',
    );
}

/**
 * Install
 *
 * Runs on plugin install by setting up the current version,
 * flushing rewrite rules to initiate the new 'property' slug and also
 * creates the plugin and populates the settings fields for those plugin
 * pages. After successful install, the user is redirected to the EPL Welcome
 * screen.
 *
 * @global $wpdb
 * @global $epl_options
 * @global $wp_version
 * @return void
 *
 * @since 1.0
 * @since 3.4.20 Altered order of flush permalinks function.
 */
function epl_install() {
    global $wpdb, $epl_options, $wp_version;

    // Add default EPL Settings.
    $epl_settings = epl_settings();

    $new_fields_defaults = epl_get_default_settings();

    if ( ! empty( $epl_settings ) ) {

        // possible upgrade.
        foreach ( $new_fields_defaults as $key    => $value ) {
            if ( ! isset( $epl_settings[ $key ] ) ) {
                // sure upgrade, fields are not set lets set them for very first time.
                $epl_settings[ $key ] = $value;
            }
        }
    } else {
        // first time install . load with default values.
        $epl_settings = $new_fields_defaults;
    }
    update_option( 'epl_settings', $epl_settings );

    // Add Upgraded From Option.
    $current_version = get_option( 'epl_version' );
    if ( ! empty( $current_version ) ) {
        update_option( 'epl_version_upgraded_from', $current_version );

    } else {
        $epl_data = get_plugin_data( EPL_PLUGIN_PATH . '/easy-property-listings.php' );
        update_option( 'epl_version', $epl_data['Version'] );
    }

    $notice_display = get_transient( 'epl_admin_notices_display' );

    if ( ! $notice_display ) {
        set_transient( 'epl_admin_notices_display', true, 60 * 60 * 24 * 14 );
    }

    // Bail if activating from network, or bulk.
    if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { //phpcs:ignore
        return;
    }
    remove_role( 'epl_crm' );

    // Clear the permalinks.
    flush_rewrite_rules();

    // Add the transient to redirect.
    set_transient( '_epl_activation_redirect', true, 30 );
}
register_activation_hook( EPL_PLUGIN_FILE, 'epl_install' );

/**
 * Un-Install
 *
 * Runs on plugin un-install by setting up the current version, flushing rewrite rules
 *
 * @since 2.2
 */
function epl_uninstall() {
    update_option( 'epl_rewrite_rules', false );
    flush_rewrite_rules();
}
register_deactivation_hook( EPL_PLUGIN_FILE, 'epl_uninstall' );

/**
 * Post-installation
 *
 * Runs just after plugin installation and exposes the
 * epl_after_install hook.
 *
 * @since 1.0
 * @return void
 */
function epl_after_install() {

    if ( ! is_admin() ) {
        return;
    }

    $activation_pages = get_transient( '_epl_activation_pages' );

    // Exit if not in admin or the transient doesn't exist.
    if ( false === $activation_pages ) {
        return;
    }

    // Delete the transient.
    delete_transient( '_epl_activation_pages' );

    do_action( 'epl_after_install', $activation_pages );
}
add_action( 'admin_init', 'epl_after_install' );

/**
 * Apply new settings on update
 *
 * Runs just after plugin installation
 *
 * @since 1.0
 * @return void
 */
function epl_plugin_updates() {
    $current_version = get_option( 'epl_version' );

    if ( version_compare( $current_version, '1.3', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-1.3.1.php';
        update_option( 'epl_version', '1.3' );
    }
    if ( version_compare( $current_version, '2.1', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-2.1.php';
        update_option( 'epl_version', '2.1' );
    }
    if ( version_compare( $current_version, '2.1.8', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-2.1.8.php';
        update_option( 'epl_version', '2.1.8' );
    }
    if ( version_compare( $current_version, '2.1.11', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-2.1.11.php';
        update_option( 'epl_version', '2.1.11' );
    }
    if ( version_compare( $current_version, '2.2', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-2.2.php';
        update_option( 'epl_version', '2.2' );
    }
    if ( version_compare( $current_version, '3.0', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-3.0.php';
        update_option( 'epl_version', '3.0' );
    }
    if ( version_compare( $current_version, '30', '==' ) ) { // Fix for 3.0 version number.
        include EPL_PATH_UPDATES . 'epl-3.1.php';
        update_option( 'epl_version', '3.1' );
    }
    if ( version_compare( $current_version, '3.1', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-3.1.php';
        update_option( 'epl_version', '3.1' );
    }
    if ( version_compare( $current_version, '3.1.16', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-3.1.16.php';
        update_option( 'epl_version', '3.1.16' );
    }
    if ( version_compare( $current_version, '3.2', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-3.2.php';
        update_option( 'epl_version', '3.2' );
    }
    if ( version_compare( $current_version, '3.2.2', '<' ) ) {
        flush_rewrite_rules();
        update_option( 'epl_version', '3.2.2' );
    }
    if ( version_compare( $current_version, '3.3', '<' ) ) {
        include EPL_PATH_UPDATES . 'epl-3.3.php';
        flush_rewrite_rules();
        update_option( 'epl_version', '3.3' );
    }
}
add_action( 'admin_init', 'epl_plugin_updates' );
Easy Property Listings 3.5.15 Code Reference API documentation generated by ApiGen