<?php

/**
 * Plugin Name:       SmartWait Animated Preloader
 * Plugin URI:        https://wordpress.org/plugins/smartwait-animated-preloader/
 * Description:       Lightweight, beautiful page preloader.
 * Version:           1.0.1
 * Requires at least: 5.8
 * Requires PHP:      7.4
 * Author:            shoiswp
 * Author URI:        https://profiles.wordpress.org/shoiswp
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       smartwait-animated-preloader
 * Domain Path:       /languages
 *
 * @package           SmartWait_Animated_Preloader
 */
// Exit if accessed directly.
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
// Define Constants.
define( 'SWAP_VERSION', '1.0.1' );
define( 'SWAP_FILE', __FILE__ );
define( 'SWAP_PATH', plugin_dir_path( __FILE__ ) );
define( 'SWAP_URL', plugin_dir_url( __FILE__ ) );
// Freemius SDK Integration.
if ( !function_exists( 'swap_fs' ) ) {
    /**
     * Create a helper function for easy SDK access.
     *
     * @return Freemius
     */
    function swap_fs() {
        global $swap_fs;
        if ( !isset( $swap_fs ) ) {
            // Activate multisite network integration.
            if ( !defined( 'WP_FS__PRODUCT_24815_MULTISITE' ) ) {
                define( 'WP_FS__PRODUCT_24815_MULTISITE', true );
            }
            // Include Freemius SDK.
            require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
            $swap_fs = fs_dynamic_init( array(
                'id'               => '24815',
                'slug'             => 'smartwait-animated-preloader',
                'type'             => 'plugin',
                'public_key'       => 'pk_3036dad48f342d0af6c7a11dac63e',
                'is_premium'       => false,
                'is_premium_only'  => false,
                'has_addons'       => false,
                'has_paid_plans'   => true,
                'is_org_compliant' => true,
                'menu'             => array(
                    'slug'       => 'smartwait-animated-preloader',
                    'first-path' => 'admin.php?page=smartwait-animated-preloader',
                ),
                'is_live'          => true,
            ) );
        }
        return $swap_fs;
    }

    // Init Freemius.
    swap_fs();
    // Signal that SDK was initiated.
    do_action( 'swap_fs_loaded' );
    /**
     * Cleanup plugin data on uninstall via Freemius.
     */
    function swap_fs_uninstall_cleanup() {
        delete_option( 'swap_settings' );
    }

    swap_fs()->add_action( 'after_uninstall', 'swap_fs_uninstall_cleanup' );
}
/**
 * Main Plugin Class.
 */
final class SWAP_Loader {
    /**
     * Instance of this class.
     *
     * @var object
     */
    private static $instance;

    /**
     * Get the instance of the class.
     *
     * @return object
     */
    public static function get_instance() {
        if ( !isset( self::$instance ) && !self::$instance instanceof SWAP_Loader ) {
            self::$instance = new self();
            self::$instance->includes();
        }
        return self::$instance;
    }

    /**
     * Constructor.
     */
    private function __construct() {
        // Singleton.
    }

    /**
     * Include required files.
     */
    private function includes() {
        require_once SWAP_PATH . 'includes/class-swap-helpers.php';
        require_once SWAP_PATH . 'includes/class-swap-admin.php';
        require_once SWAP_PATH . 'includes/class-swap-frontend.php';
    }

}

/**
 * Initialize the plugin.
 */
function swap_init() {
    return SWAP_Loader::get_instance();
}

add_action( 'plugins_loaded', 'swap_init' );