<?php
/**
 * Plugin Name: SwapAds Client
 * Plugin URI:  https://swapads.eu
 * Description: SwapAds client - connects your WordPress site to the SwapAds network for 1:1 barter of ads and backlinks.
 * Version:     1.6.0
 * Author:      SwapAds
 * License:     GPL-2.0-or-later
 * Requires PHP: 8.1
 * Requires at least: 6.5
 * Text Domain: swapads-client
 * Domain Path: /languages
 *
 * @package SwapAds\Client
 */

declare(strict_types=1);

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

// Plugin constants
define('SWAPADS_CLIENT_VERSION', '1.6.0');
define('SWAPADS_CLIENT_FILE', __FILE__);
define('SWAPADS_CLIENT_PATH', plugin_dir_path(__FILE__));
define('SWAPADS_CLIENT_URL', plugin_dir_url(__FILE__));
define('SWAPADS_CLIENT_BASENAME', plugin_basename(__FILE__));

// Load Composer autoloader (when installed)
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
    require_once __DIR__ . '/vendor/autoload.php';
}

// Load Freemius SDK bootstrap (CF16/F56). The vendored SDK lives at /freemius/.
// This call defines the swa_fs() helper and triggers fs_dynamic_init().
if (file_exists(__DIR__ . '/freemius-init.php')) {
    require_once __DIR__ . '/freemius-init.php';
}

// Bootstrap the plugin
add_action('plugins_loaded', function (): void {
    \SwapAds\Client\Plugin::instance()->init();
});

// Activation hook
register_activation_hook(__FILE__, function (): void {
    \SwapAds\Client\Plugin::instance()->activate();
});

// Deactivation hook
register_deactivation_hook(__FILE__, function (): void {
    \SwapAds\Client\Plugin::instance()->deactivate();
});
