<?php
/**
 * Donation Router for GiveWP & PayPal
 *
 * Route GiveWP donations to multiple PayPal Business accounts by donor
 * country — each with its own credentials, receipts, and webhooks.
 *
 * @package           DonationRouter
 * @author            Al Amin Ahamed
 * @copyright         2026 Al Amin Ahamed
 * @license           GPL-2.0-or-later
 *
 * @wordpress-plugin
 * Plugin Name:       Donation Router for GiveWP & PayPal
 * Plugin URI:        https://github.com/mralaminahamed/donation-router-for-givewp-paypal-donations
 * Description:       Route GiveWP donations to multiple PayPal Business accounts by donor country — each with its own credentials, receipts, and webhooks.
 * Version:           1.1.0
 * Requires at least: 6.4
 * Requires PHP:      8.1
 * Author:            Al Amin Ahamed
 * Author URI:        https://github.com/mralaminahamed
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       alamin-donation-router
 * Domain Path:       /languages
 * Requires Plugins:  give
 *
 * @since 1.0.0
 */

declare( strict_types=1 );

namespace DonationRouter;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

define( 'ADOR_VERSION', '1.1.0' );
define( 'ADOR_FILE', __FILE__ );
define( 'ADOR_PATH', plugin_dir_path( __FILE__ ) );
define( 'ADOR_URL', plugin_dir_url( __FILE__ ) );
define( 'ADOR_BASENAME', plugin_basename( __FILE__ ) );

/**
 * Show admin notice when vendor directory is missing.
 *
 * @since 1.0.0
 *
 * @return void
 */
function ador_notice_missing_vendor(): void {
	echo '<div class="notice notice-error"><p>' .
		esc_html__( 'Donation Router for GiveWP & PayPal: Please run `composer install` to generate the autoloader.', 'alamin-donation-router' ) .
		'</p></div>';
}

if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
	add_action( 'admin_notices', __NAMESPACE__ . '\\ador_notice_missing_vendor' );
	return;
}

require_once __DIR__ . '/vendor/autoload.php';

/**
 * Helper to access the plugin singleton.
 *
 * @since 1.0.0
 *
 * @return Plugin
 */
function ador(): Plugin {
	return Plugin::instance();
}

ador()->boot();
