<?php

// If this file is called directly, abort.
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
/**
 *
 * @link              https://wondercode.pro/
 * @since             1.0.0
 * @package           Easy_YouTube_Automate
 *
 * @wordpress-plugin
 * Plugin Name:       Easy YouTube Automate
 * Description:       Easy YouTube Automate allows you to add relevant YouTube videos either by searching for them using keywords or by automatically attaching videos.
 * Version:           1.0.0
 * Author:            Wondercode
 * Author URI:        https://wondercode.pro/
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       easy-youtube-automate
 * Domain Path:       /languages
 * 
 *
 */
// Currently plugin version.
define( 'YTAM_VERSION', '1.0.0' );
/**
 * Includes Freemius
 */
if ( function_exists( 'ytam_fs' ) ) {
    ytam_fs()->set_basename( false, __FILE__ );
} else {
    if ( !function_exists( 'ytam_fs' ) ) {
        // Create a helper function for easy SDK access.
        function ytam_fs() {
            global $ytam_fs;
            if ( !isset( $ytam_fs ) ) {
                // Include Freemius SDK.
                require_once dirname( __FILE__ ) . '/admin/partials/freemius/start.php';
                $ytam_fs = fs_dynamic_init( array(
                    'id'             => '15321',
                    'slug'           => 'easy-youtube-automate',
                    'type'           => 'plugin',
                    'public_key'     => 'pk_c5998841d74915e69e87062c18fdf',
                    'is_premium'     => false,
                    'premium_suffix' => 'Pro',
                    'has_addons'     => false,
                    'has_paid_plans' => true,
                    'menu'           => array(
                        'slug'           => 'youtube-automate',
                        'override_exact' => true,
                        'contact'        => false,
                        'support'        => false,
                        'affiliation'    => false,
                        'account'        => false,
                        'addons'         => false,
                    ),
                    'is_live'        => true,
                ) );
            }
            return $ytam_fs;
        }

        // Init Freemius.
        ytam_fs();
        // Signal that SDK was initiated.
        do_action( 'ytam_fs_loaded' );
        function ytam_fs_settings_url() {
            return admin_url( 'admin.php?page=ytam' );
        }

    }
}
/**
 * The code that runs during plugin activation.
 * This action is documented in includes/class-youtube-automate-activator.php
 */
function ytam_activate() {
    require_once esc_html( plugin_dir_path( __FILE__ ) ) . 'includes/class-youtube-automate-activator.php';
    YTAM_Activator::activate();
}

/**
 * The code that runs during plugin deactivation.
 * This action is documented in includes/class-youtube-automate-deactivator.php
 */
function ytam_deactivate() {
    require_once esc_html( plugin_dir_path( __FILE__ ) ) . 'includes/class-youtube-automate-deactivator.php';
    YTAM_Deactivator::deactivate();
}

register_activation_hook( __FILE__, 'ytam_activate' );
register_deactivation_hook( __FILE__, 'ytam_deactivate' );
/**
 * The core plugin class that is used to define internationalization,
 * admin-specific hooks, and public-facing site hooks.
 */
require esc_html( plugin_dir_path( __FILE__ ) ) . 'includes/class-youtube-automate.php';
/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function ytam_run() {
    $plugin = new YTAM_Automate();
    $plugin->run();
}

ytam_run();
// Fired when the plugin is uninstalled.
ytam_fs()->add_action( 'after_uninstall', 'ytam_freemius_uninstall_cleanup' );
function ytam_freemius_uninstall_cleanup() {
    // Remove logs
    define( "YTAM_FREEMIUS_UNINSTALL", true );
    require_once dirname( __FILE__ ) . '/admin/partials/delete_log.php';
    // Delete all current plugin options
    delete_option( 'YTAM_settings' );
    delete_option( 'YTAM_logs' );
}
