<?php
/*
Plugin Name: Vue-Plugin-1
Plugin URI: https://tfwtech.com/fai-room/vue-plugin-1-wp/
Description: 将vue构建的页面嵌入WordPress 中并产生交互
Author: TfwTech
Author URI: https://tfwtech.com/fai-room/
Version: 1.3.1
*/


if (!defined('ABSPATH')) exit(); // No direct access allowed

/** Autoloader from Composer ****/
require_once 'vendor/autoload.php';

use IvrVP1\Includes\Api\ApiEndPoints;
use IvrVP1\Includes\Backend\Activate;
use IvrVP1\Includes\Backend\CreateMenuPages;


final class Vue_plugin_1 {

	public function __construct() {
		$this->template_constants();
		$this->plugin_constants();
		register_activation_hook(__FILE__, [$this, 'activate']);
		register_deactivation_hook(__FILE__, [$this, 'deactivate']);
		add_action('plugins_loaded', [$this, 'init_others']);
	} // end __construct()



	public function template_constants() {
		define('SLUG', 'vueplugin1-id');						// admin menu url slug
		define('ADMIN_PAGE_TITLE', 'Vue Plugin 1');	// Admin menu page title
		define('LEFT_MENU_TEXT', 'Vue Plugin 1');		// menu text on left panel	
		define('CAPABILITY', 'manage_options');			// capability or permissions
		define('VUEAPP_MOUNT', 'vue-plugin-1-app');	// Vue App Mount ID
		define('MENU_ICON', 'dashicons-layout');		// Menu Icon
		define('POSITION', '25');								// Menu Item Position 
		define('REST_NAMESPACE', 'ivrvp1/v1');			// REST API namespace (../wp-json/ivrvp1/v1/)
		define('REST_BASE', 'settings');						// REST API base (../wp-json/ivrvp1/v1/settings/)
	} // end template_constants()

	public function plugin_constants() {
		$plugin_data = get_plugin_data(__FILE__);
		define('PLUGIN_VERSION', $plugin_data['Version']);
		define('PLUGIN_PATH', plugin_dir_path(__FILE__) . "/");
		define('PLUGIN_URL', plugin_dir_url(__FILE__) . "/");
	} // end plugin_constants()


	/*****  Create Singletone Instance *****/
	public static function init() {
		static $instance = false;
		if (!$instance) {
			$instance = new self();
		}
		return $instance;
	} // end init()


	/***** Init other classes *****/
	public function init_others() {
		new CreateMenuPages();
		new ApiEndPoints();

	} // end init_others()


	/***** Plugin activation *****/
	public function activate() {
		Activate::activate();
	}


	/*****  Plugin deactivation *****/
	public function deactivate() {
	}
} // end class Vue_plugin_1



// Instantiate the class & run
Vue_plugin_1::init();


