<?php
/**
 * ==========================
 * 🔐 IGNY8 FILE RULE HEADER
 * ==========================
 * @file         : install.php
 * @location     : /install.php
 * @type         : Function Library
 * @scope        : Global
 * @allowed      : Plugin installation, database initialization, setup procedures
 * @reusability  : Single Use
 * @notes        : Plugin installation and database initialization
 */

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}

/**
 * ------------------------------------------------------------------------
 * MAIN INSTALLATION ENTRY
 * ------------------------------------------------------------------------
 */
function igny8_install() {
    // Load dbDelta if not already loaded
    if (!function_exists('dbDelta')) {
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    }

    // Load database functions
    require_once plugin_dir_path(__FILE__) . 'core/db/db.php';
    
    // Run complete installation using db.php function
    if (function_exists('igny8_install_database')) {
        igny8_install_database();
    }
    
    error_log('Igny8 Compact: Plugin installed successfully');
}

// Register activation hook
register_activation_hook(__FILE__, 'igny8_install');