<?php
	
/**
* Plugin Name: Admin Starter Pack
* Description: As the plugin name says.
* Author: Arya Dhiratara
* Author URI: https://dhiratara.me
* Version: 1.0.1
* Requires at least: 5.8
* Requires PHP: 7.4
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: starterpack
*/

namespace AdminStarterPack;

if (!defined('ABSPATH')) exit; // Exit if accessed directly

define('STARTERPACK_NAME', 'Starter Pack');
define('STARTERPACK_DESC', 'WordPress Site Development Starter Pack by Arya Dhiratara');
define('STARTERPACK_SLUG', 'admin_starter_pack');
define('STARTERPACK_SHORT_SLUG', 'starterpack');
define('STARTERPACK_VERSION', '1.0.12');
define("STARTERPACK_DIR", plugin_dir_path(__FILE__));
define("STARTERPACK_URL", plugin_dir_url(__FILE__));

define("STARTERPACK_ASSETS_URL", plugin_dir_url(__FILE__) . 'assets/');
define("STARTERPACK_PUBLIC_URL", plugin_dir_url(__FILE__) . 'public/');
define("STARTERPACK_CLASSES_DIR", plugin_dir_path(__FILE__) . 'includes/classes/');
define("STARTERPACK_FUNCTIONS_URL", plugin_dir_url(__FILE__) . 'includes/functions/');
define("STARTERPACK_FUNCTIONS_DIR", plugin_dir_path(__FILE__) . 'includes/functions/');
define("STARTERPACK_LIBRARY_DIR", plugin_dir_path(__FILE__) . 'includes/library/');
define("STARTERPACK_BASENAME", plugin_basename(__FILE__));
define("STARTERPACK_ASSETS_DIR", STARTERPACK_DIR . 'assets/');

define('STARTERPACK_CLIENTAGENTNAME', 'Arya Dhiratara');

// include the required plugin files
include_once(STARTERPACK_DIR . 'includes/classes/Loader.php');
include_once(STARTERPACK_DIR . 'includes/Functions.php');

global $starterpack_instance;

function starterpack_instance()
    {
        global $starterpack_instance;

        $starterpack_instance = AspPluginLoader::getInstance();

        return $starterpack_instance;
}

starterpack_instance();

function STARTERPACK_activation_redirect($plugin)
{
    if ($plugin == plugin_basename(__FILE__)) {
        exit(wp_redirect(admin_url('admin.php?page=' . STARTERPACK_SHORT_SLUG)));
    }
}

spl_autoload_register('AdminStarterPack\STARTERPACK_autoloader');

function STARTERPACK_autoloader($class)
{
    // Convert class namespace to file path
    $class = str_replace('AdminStarterPack\\', '', $class);
    $file = STARTERPACK_CLASSES_DIR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';

    if (file_exists($file)) {
        require_once $file;
    }
}

add_action('activated_plugin', 'AdminStarterPack\STARTERPACK_activation_redirect');


function remove_plugin_htaccess_rules() {
    $asp_plugin_security = new \AdminStarterPack\AspPluginSecurity();
    $asp_plugin_security->removedeAllHtaccessRules();
}
register_deactivation_hook(__FILE__, 'AdminStarterPack\remove_plugin_htaccess_rules');