<?php
/**
 * Plugin Name: MisticEase
 * Plugin URI:  https://mitum.me/misticease
 * Description: Turn video URLs into pop-up thumbnails or title links, with image pop-ups, thumbnail caching, and Floating UX mode.
 * Version:     1.3.0
 * Author:      MistiCuantum
 * Author URI:  https://mitum.me
 * License:     GPLv2
 * Text Domain: misticease
 * Domain Path: /languages
 * Requires at least: 6.0
 * Requires PHP: 7.4
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}

if ( function_exists( 'misticease_fs' ) ) {
    misticease_fs()->set_basename( false, __FILE__ );
} else {
    /**
     * DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE
     * `function_exists` CALL ABOVE TO PROPERLY WORK.
     */
    if ( !function_exists( 'misticease_fs' ) ) {
        // Create a helper function for easy SDK access.
        function misticease_fs() {
            global $misticease_fs;
            if ( !isset( $misticease_fs ) ) {
                // Activate multisite network integration.
                if ( !defined( 'WP_FS__PRODUCT_20584_MULTISITE' ) ) {
                    define( 'WP_FS__PRODUCT_20584_MULTISITE', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Required Freemius SDK multisite constant generated by the official SDK integration snippet.
                }
                // Include Freemius SDK.
                require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
                $misticease_fs = fs_dynamic_init( array(
                    'id'               => '20584',
                    'slug'             => 'misticease',
                    'premium_slug'     => 'misticease-arc',
                    'type'             => 'plugin',
                    'public_key'       => 'pk_9177daec6929671a5fc4efc4ffc61',
                    'is_premium'       => false,
                    'premium_suffix'   => 'Arc',
                    'has_addons'       => false,
                    'has_paid_plans'   => true,
                    'is_org_compliant' => true,
                    'trial'            => array(
                        'days'               => 10,
                        'is_require_payment' => true,
                    ),
                    'menu'            => array(
                        'slug'        => 'misticease-control-panel',
                        'first-path'  => 'admin.php?page=misticease-activate-router',
						'network'     => true,
                        'contact'     => false,
                        'support'     => true,
                        'addons'      => false,
                        'affiliation' => false,
                        'account'     => false,
                        'pricing'     => true,
                    ),
                    'is_live'          => true,
                ) );
            }
            return $misticease_fs;
        }

        function misticease_preserve_site_admin_menu_on_network_activation( $should_hide_site_admin_settings ) {
            return false;
        }

        // Init Freemius.
        misticease_fs();
        // Preserve the MisticEase menu on network-activated subsites.
        misticease_fs()->add_filter(
        	'should_hide_site_admin_settings_on_network_activation_mode',
        	'misticease_preserve_site_admin_menu_on_network_activation'
        );
        // Signal that SDK was initiated.
        // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Freemius generated hook name shared by the free and premium builds.
        do_action( 'misticease_fs_loaded' );
    }
    if ( !defined( 'MISTICEASE_VERSION' ) ) {
        define( 'MISTICEASE_VERSION', '1.3.0' );
    }
    if ( !defined( 'MISTICEASE_PACKAGE_SLUG' ) ) {
        define( 'MISTICEASE_PACKAGE_SLUG', basename( __DIR__ ) );
    }
    if ( !defined( 'MISTICEASE_MAIN_FILE' ) ) {
        define( 'MISTICEASE_MAIN_FILE', __FILE__ );
    }
    if ( !defined( 'MISTICEASE_BASENAME' ) ) {
        define( 'MISTICEASE_BASENAME', plugin_basename( __FILE__ ) );
    }
    if ( !defined( 'MISTICEASE_BASE_URL' ) ) {
        define( 'MISTICEASE_BASE_URL', plugin_dir_url( MISTICEASE_MAIN_FILE ) );
    }
    require_once __DIR__ . '/inc/bootstrap.php';
    function misticease_dispatch_activate(  $network_wide  ) : void {
        misticease_activation_handler( $network_wide );
    }

    function misticease_dispatch_deactivate() : void {
        misticease_deactivate();
    }

    function misticease_after_uninstall_cleanup() : void {
        require_once __DIR__ . '/inc/bootstrap.php';
        misticease_uninstall();
    }

    misticease_fs()->add_action( 'after_uninstall', 'misticease_after_uninstall_cleanup' );
    register_activation_hook( __FILE__, 'misticease_dispatch_activate' );
    register_deactivation_hook( __FILE__, 'misticease_dispatch_deactivate' );
}