<?php
/**
 * Plugin Name:       SandboxPress AI
 * Plugin URI:        https://www.soyebsalar.com/sandboxpress-ai/
 * Description:       Generates deep, advanced, and varied dummy content including hierarchical pages, taxonomy, Gutenberg blocks, and WooCommerce variations.
 * Version:           1.0.1
 * Author:            Soyeb Salar
 * Author URI:        https://www.soyebsalar.com/
 * License:           GPL-2.0+
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       sandboxpress-ai
 * Domain Path:       /languages
 * Requires at least: 6.0
 * Requires PHP:      7.4
 * Tested up to:      7.0
 * WC tested up to:   9.3.3
 */
if (!defined('WPINC'))
    die;

define('SBPAI_VERSION', '1.0.1');
define('SBPAI_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('SBPAI_PLUGIN_URL', plugin_dir_url(__FILE__));

// Composer Autoload
if (file_exists(SBPAI_PLUGIN_DIR . 'vendor/autoload.php')) {
    require_once SBPAI_PLUGIN_DIR . 'vendor/autoload.php';
}

// Ensure Action Scheduler is loaded if available via Composer
if (file_exists(SBPAI_PLUGIN_DIR . 'vendor/woocommerce/action-scheduler/action-scheduler.php')) {
    require_once SBPAI_PLUGIN_DIR . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
}

// Declare compatibility with WooCommerce HPOS (Custom Order Tables) and Cart/Checkout Blocks
add_action('before_woocommerce_init', function () {
    if (class_exists('Automattic\WooCommerce\Utilities\FeaturesUtil')) {
        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('cart_checkout_blocks', __FILE__, true);
    }
});

// Require System Files
require_once SBPAI_PLUGIN_DIR . 'includes/class-sbpai-core.php';
require_once SBPAI_PLUGIN_DIR . 'includes/class-sbpai-admin.php';
require_once SBPAI_PLUGIN_DIR . 'includes/class-sbpai-ajax-handler.php';
require_once SBPAI_PLUGIN_DIR . 'includes/class-sbpai-action-scheduler.php';

// Require Services
require_once SBPAI_PLUGIN_DIR . 'includes/services/class-sbpai-service-media.php';
require_once SBPAI_PLUGIN_DIR . 'includes/services/class-sbpai-service-ai.php';

// Require Modules
require_once SBPAI_PLUGIN_DIR . 'includes/modules/class-sbpai-module-base.php';
require_once SBPAI_PLUGIN_DIR . 'includes/modules/class-sbpai-module-posts.php';
require_once SBPAI_PLUGIN_DIR . 'includes/modules/class-sbpai-module-pages.php';
require_once SBPAI_PLUGIN_DIR . 'includes/modules/class-sbpai-module-users.php';
require_once SBPAI_PLUGIN_DIR . 'includes/modules/class-sbpai-module-products.php';
require_once SBPAI_PLUGIN_DIR . 'includes/modules/class-sbpai-module-orders.php';
require_once SBPAI_PLUGIN_DIR . 'includes/modules/class-sbpai-module-coupons.php';
require_once SBPAI_PLUGIN_DIR . 'includes/modules/class-sbpai-module-acf.php';

/**
 * Bootstrap the plugin.
 */
function sbpai_run()
{
    $plugin = new SBPAI_Core();
    $plugin->init();
}

add_action('plugins_loaded', 'sbpai_run');
