<?php
/**
 * The plugin bootstrap file
 *
 * This file is read by WordPress to generate the plugin information in the plugin
 * admin area. This file also includes all of the dependencies used by the plugin,
 * registers the activation and deactivation functions, and defines a function
 * that starts the plugin.
 *
 * @link              https://untapwp.com/
 * @since             1.0.0
 * @package           vidplex
 *
 * @wordpress-plugin
 * Plugin Name:       Vidplex
 * Plugin URI:        https://untapwp.com/vidplex/
 * Description:       Showcase YouTube videos in responsive galleries with carousels, modal playback, and fully customizable layouts for your site.
 * Version:           1.0.2
 * Author:            Untapwp
 * Author URI:        https://untapwp.com/
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       vidplex
 * Requires at least: 5.8
 * Requires PHP: 7.3
 */

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

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

		if ( ! isset( $vidplex_fs ) ) {
			// Include Freemius SDK.
			require_once __DIR__ . '/vendor/freemius/start.php';
			$vidplex_fs = fs_dynamic_init(
				array(
					'id'                  => '20186',
					'slug'                => 'vidplex',
					'type'                => 'plugin',
					'public_key'          => 'pk_bd487eaf6bd217b753af80cd4da1f',
					'is_premium'          => true,
					'premium_suffix'      => 'Pro',
					// If your plugin is a serviceware, set this option to false.
					'has_premium_version' => false,
					'has_addons'          => false,
					'has_paid_plans'      => true,
					// Automatically removed in the free version. If you're not using the
					// auto-generated free version, delete this line before uploading to wp.org.
					'menu'                => array(
						'slug'    => '_vidplex',
						'support' => false,
					),
				)
			);
		}

		return $vidplex_fs;
	}

	// Init Freemius.
	vidplex_fs();
	// Signal that SDK was initiated.
	do_action( 'vidplex_fs_loaded' );
}

define( 'VIDPLEX_VERSION', '1.0.2' );
define( 'VIDPLEX_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'VIDPLEX_PLUGIN_URL', trailingslashit( plugins_url( '', __FILE__ ) ) );

require_once VIDPLEX_PLUGIN_DIR . 'autoload.php';

/**
 * Function to run during plugin activation.
 *
 * This function is hooked into the WordPress 'register_activation_hook'.
 * It triggers the static activate() method from the \Vidplex\Activate class,
 * which should handle all plugin setup tasks such as setting default options,
 * creating necessary database tables, etc.
 */
function vidplex_activator() {
	\Vidplex\Activate::activate();
}
register_activation_hook( __FILE__, 'vidplex_activator' );

/**
 * Function to run during plugin deactivation.
 *
 * This function is responsible for cleanup tasks when the plugin is deactivated.
 * It calls the static deactivate() method from the \Vidplex\Deactivate class,
 * where you can define logic such as unregistering custom post types, clearing scheduled events, etc.
 */
function vidplex_deactivator() {
	\Vidplex\Deactivate::deactivate();
}
register_deactivation_hook( __FILE__, 'vidplex_deactivator' );

\Vidplex\Init::get_instance();
