<?php
/**
 * Plugin Name: UserMorph
 * Plugin URI: https://wordpress.org/plugins/usermorph/
 * Description: Instantly switch between user accounts with a searchable admin bar menu. Secure, fast, and developer-friendly.
 * Version: 1.0.1
 * Author: VerseSofts
 * Author Email: contact@versesofts.com
 * Tested up to: 7.0
 * Requires PHP: 7.4
 * License: GPLv2
 * Text Domain: usermorph
 */

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

if ( ! function_exists( 'use_fs' ) ) {
    // Create a helper function for easy SDK access.
    function use_fs() {
        global $use_fs;

        if ( ! isset( $use_fs ) ) {
            // Include Freemius SDK.
            require_once dirname( __FILE__ ) . '/freemius/start.php';

            $use_fs = fs_dynamic_init( array(
                'id'                  => '28083',
                'slug'                => 'usermorph',
                'type'                => 'plugin',
                'public_key'          => 'pk_8bc6ee5fc6c869ccbdbe7e20cf33c',
                'is_premium'          => false,
                'has_addons'          => false,
                'has_paid_plans'      => false,
                'is_org_compliant'    => true,
                'menu'                => array(
                    'first-path'     => 'plugins.php',
                    'account'        => false,
                    'support'        => false,
                ),
            ) );
        }

        return $use_fs;
    }

    // Init Freemius.
    use_fs();
    // Signal that SDK was initiated.
    do_action( 'use_fs_loaded' );
}

// Define Constants
define('USERMORPH_VERSION', '1.0.1');
define('USERMORPH_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('USERMORPH_PLUGIN_URL', plugin_dir_url(__FILE__));

/**
 * Main Plugin Class
 */
class UserMorph_Main
{

	private static $instance = null;

	public static function get_instance()
	{
		if (null === self::$instance) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	private function __construct()
	{
		$this->includes();
	}

	private function includes()
	{
		require_once USERMORPH_PLUGIN_DIR . 'inc/class-switcher.php';
		require_once USERMORPH_PLUGIN_DIR . 'inc/class-admin-bar.php';
		require_once USERMORPH_PLUGIN_DIR . 'inc/class-user-links.php';
	}
}

// Initialize the plugin
function usermorph_main()
{
	return UserMorph_Main::get_instance();
}
add_action('plugins_loaded', 'usermorph_main');
