<?php
/**
 * Plugin Name: Ultimate Pricing Plan Switcher for Elementor
 * Description: It is a Elementor addons with awesome useful pricing plan switcher widgets to create nice looking month/anual pricing plan switcher design using Elementor.
 * Plugin URI: https://addons.dynamiclayers.net/pricing-plan-switcher/
 * Author: DynamicLayers
 * Author URI: https://codecanyon.net/user/dynamiclayers/portfolio
 * Version: 1.0.2
 * Requires PHP: 7.2
 * Requires at least: 5.0
 * Elementor tested up to: 3.7.1
 * License: GPL2 or later
 * Text Domain: uppsae
 * Domain Path: /languages
 * @package UPPSAE
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

require_once __DIR__ . '/vendor/autoload.php';

/**
 * The main plugin class
 */
final class UPPSAE {

    /**
     * Plugin version
     *
     * @var string
     */
    const version = '1.0.2';

    /**
     * Class construcotr
     */
    private function __construct() {
        $this->define_constants();

        register_activation_hook( __FILE__, [ $this, 'activate' ] );

        add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );

        add_action( 'elementor/init', [ $this, 'elementor_init' ] );
    }

    /**
     * Initializes a singleton instance
     *
     * @return \UPPSAE
     */
    public static function init() {
        static $instance = false;

        if ( ! $instance ) {
            $instance = new self();
        }

        return $instance;
    }

    /**
     * Define the required plugin constants
     *
     * @return void
     */
    public function define_constants() {
        define( 'UPPSAE_VERSION', self::version );
        define( 'UPPSAE_FILE', __FILE__ );
        define( 'UPPSAE_PATH', __DIR__ );
        define( 'UPPSAE_URL', plugins_url( '', UPPSAE_FILE ) );
        define( 'UPPSAE_ASSETS', UPPSAE_URL . '/assets' );
    }

    /**
     * Initialize the plugin
     *
     * @return void
     */
    public function init_plugin() {

        load_plugin_textdomain( 'uppsae', false, basename( dirname( __FILE__ ) ) . '/languages' );

        if ( is_admin() ) {
            new \DynamicLayers\UPPSAE\Classes\Elementor();

        } else {
            new \DynamicLayers\UPPSAE\Classes\Assets();
        }


    }

    /**
     * Elementor Initialize
     *
     * @return void
     */
    public function elementor_init(){
        
        new \DynamicLayers\UPPSAE\Classes\Widgets();
    }

    /**
     * Do stuff upon plugin activation
     *
     * @return void
     */
    public function activate() {
        $installer = new \DynamicLayers\UPPSAE\Classes\Installer();
        $installer->run();
    }
}

/**
 * Initializes the main plugin
 *
 * @return \UPPSAE
 */
function uppsae_init() {
    return UPPSAE::init();
}

// kick-off the plugin
uppsae_init();
