<?php
/**
 * Plugin Name: Manfi Expense Tracker
 * Description: A complete bookkeeping, invoicing, and budget management solution powered by React. Track expenses, manage clients/vendors, link bank accounts, and generate professional invoice PDFs.
 * Version: 1.1.8
 * Requires at least: 6.2
 * Requires PHP: 8.1
 * Author: nisan92
 * Author URI: https://www.manfii.com/
 * Text Domain: manfi-expense-tracker
 * Domain Path: /languages
 * License: GPL v2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 */

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

// Define Plugin Constants
define('MANFIET_EXPENSE_TRACKER_VERSION', '1.1.8');
define('MANFIET_EXPENSE_TRACKER_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('MANFIET_EXPENSE_TRACKER_PLUGIN_URL', plugin_dir_url(__FILE__));
define('MANFIET_EXPENSE_TRACKER_PLUGIN_BASENAME', plugin_basename(__FILE__));

// Autoload Classes using PSR-4 conventions
spl_autoload_register(function ($class) {
    if (strpos($class, 'Manfiet_') !== 0) {
        return;
    }

    if (strpos($class, 'Manfiet_Expense_Tracker_Widget_') === 0) {
        $file = MANFIET_EXPENSE_TRACKER_PLUGIN_DIR . 'includes/elementor/' . $class . '.php';
    } else {
        $file = MANFIET_EXPENSE_TRACKER_PLUGIN_DIR . 'includes/' . $class . '.php';
    }

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

// Register Activation and Deactivation Hooks
register_activation_hook(__FILE__, ['Manfiet_Expense_Tracker_Activator', 'activate']);
register_deactivation_hook(__FILE__, ['Manfiet_Expense_Tracker_Deactivator', 'deactivate']);

// Bootstrap the Plugin Setup
Manfiet_Expense_Tracker_Setup::get_instance();
