<?php

/*
Plugin Name: Realia for Realsite
Version: 0.4.0
Description: Complete real estate office in WordPress plugin. Realia is covering all needs of real estate agencies or portals. No problem for Realia to turn your website into directory solution with payment options. It allows you to create and customize website in just few clicks by using setting manager in customizer.  For full list of plugin features visit <a href="http://wprealia.com">wprealia.com</a>.
Author: Pragmatic Mates
Author URI: http://wprealia.com
Text Domain: realia
Domain Path: /languages/
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/

if ( ! class_exists( 'Realia' ) ) {
    /**
     * Class Realia
     *
     * @class Realia
     * @package Realia
     * @author Pragmatic Mates
     */
    final class Realia {
        /**
         * Initialize Realia plugin
         */
        public function __construct() {
            $this->constants();
            $this->libraries();
            $this->includes();
            $this->activation_hooks();
	        $this->load_plugin_textdomain();

	        add_filter( 'site_transient_update_plugins', array( __CLASS__, 'exclude_from_update' ) );
        }

        /**
         * Defines constants
         *
         * @access public
         * @return void
         */
        public function constants() {
            define( 'REALIA_DIR', plugin_dir_path( __FILE__ ) );
            define( 'REALIA_PROPERTY_PREFIX', 'property_' );
            define( 'REALIA_AGENCY_PREFIX', 'agency_' );
            define( 'REALIA_AGENT_PREFIX', 'agent_' );
            define( 'REALIA_PARTNER_PREFIX', 'partner_' );
            define( 'REALIA_LANDLORD_PREFIX', 'landlord_' );
            define( 'REALIA_TRANSACTION_PREFIX', 'transaction_' );
            define( 'REALIA_PACKAGE_PREFIX', 'user_' );
            define( 'REALIA_USER_PREFIX', 'user_' );
            define( 'REALIA_PRICING_PREFIX', 'pricing_' );
            define( 'REALIA_CURRENCY_REFRESH', 24 * 60 * 60 );
            define( 'REALIA_MAX_COMPARE', 4 );
            define( 'REALIA_RECAPTCHA_URL', 'https://www.google.com/recaptcha/api/siteverify' );
        }

        /**
         * Fires activation hooks
         *
         * @access public
         * @return void
         */
        public function activation_hooks() {
            register_activation_hook( __FILE__, array( 'Realia_Statistics', 'install_search_queries' ) );
            register_activation_hook( __FILE__, array( 'Realia_Statistics', 'install_property_views' ) );
        }

        /**
         * Include classes
         *
         * @access public
         * @return void
         */
        public function includes() {
            require_once REALIA_DIR . 'includes/class-realia-recaptcha.php';
            require_once REALIA_DIR . 'includes/class-realia-template-loader.php';
            require_once REALIA_DIR . 'includes/class-realia-post-types.php';
            require_once REALIA_DIR . 'includes/class-realia-taxonomies.php';
            require_once REALIA_DIR . 'includes/class-realia-customizations.php';
            require_once REALIA_DIR . 'includes/class-realia-query.php';
            require_once REALIA_DIR . 'includes/class-realia-price.php';
            require_once REALIA_DIR . 'includes/class-realia-scripts.php';
            require_once REALIA_DIR . 'includes/class-realia-widgets.php';
            require_once REALIA_DIR . 'includes/class-realia-reviews.php';
            require_once REALIA_DIR . 'includes/class-realia-filter.php';
            require_once REALIA_DIR . 'includes/class-realia-pages.php';
            require_once REALIA_DIR . 'includes/class-realia-currencies.php';
            require_once REALIA_DIR . 'includes/class-realia-shortcodes.php';
            require_once REALIA_DIR . 'includes/class-realia-import.php';
            require_once REALIA_DIR . 'includes/class-realia-favorites.php';
            require_once REALIA_DIR . 'includes/class-realia-compare.php';
            require_once REALIA_DIR . 'includes/class-realia-statistics.php';
            require_once REALIA_DIR . 'includes/class-realia-google-maps-styles.php';
            require_once REALIA_DIR . 'includes/class-realia-packages.php';
            require_once REALIA_DIR . 'includes/class-realia-paypal.php';
            require_once REALIA_DIR . 'includes/class-realia-submission.php';
            require_once REALIA_DIR . 'includes/class-realia-utilities.php';
            require_once REALIA_DIR . 'includes/class-realia-social.php';
        }

        /**
         * Loads third party libraries
         *
         * @access public
         * @return void
         */
        public static function libraries() {
            require_once REALIA_DIR . 'libraries/CMB2/init.php';
            require_once REALIA_DIR . 'libraries/cmb_field_map/cmb-field-map.php';
            require_once REALIA_DIR . 'libraries/cmb2-attached-posts/cmb2-attached-posts.php';
        }

	    /**
	     * Loads localization files
	     */
	    public function load_plugin_textdomain() {
		    load_plugin_textdomain( 'realia', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
	    }

	    /**
	     * Remove from updates
	     *
	     * @access public
	     * @param $item
	     * @return bool
	     */
	    public static function exclude_from_update( $item ) {
		    if ( is_object( $item ) ) {
			    unset( $item->response['realia/realia.php'] );
		    }

		    return $item;
	    }
    }
}

new Realia();
