<?php
/*
Plugin Name: Pedro Demo Import
Plugin URI: 
Description:  import demo content, widgets, and customizer settings for the Pedro theme with just one click.
Version: 1.0.0
Author: hmrisad
Requires PHP: 7.4
Author URI: 
License: GPL3
License URI: http://www.gnu.org/licenses/gpl.html
Text Domain: pedro-demo-import
*/


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

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

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

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

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

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

    /**
     * Initializes a singleton instance
     *
     * @return \Pedro
     */
    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( 'PEDRO_DEMO_VERSION', self::version );
        define( 'PEDRO_DEMO_FILE', __FILE__ );
        define( 'PEDRO_DEMO_PATH', __DIR__ );
        define( 'PEDRO_DEMO_URL', plugins_url( '', PEDRO_DEMO_FILE ) );
    }

   /**
     * Initialize the plugin
     *
     * @return void
     */
    public function init_plugin() {
        if ( ! class_exists( 'TGM_Plugin_Activation' ) ) {
            require_once PEDRO_DEMO_PATH . '/tgm/class-tgm-plugin-activation.php';
        }
        require_once PEDRO_DEMO_PATH . '/tgm/pedro-activation.php';
        require_once PEDRO_DEMO_PATH . '/inc/pedro-function.php';
    }

    /**
     * Do stuff upon plugin activation
     *
     * @return void
     */
    public function activate() {
        
        if ( ! get_option( 'pedro_demo_installed' ) ) {
            update_option( 'pedro_demo_installed', time() );
        }

        update_option( 'pedro_demo_version', PEDRO_DEMO_VERSION );
    }
}

Pedro_Demo_Import::init();