<?php
/**
 * Plugin Name:       AccessLens - Web Accessibility Audit
 * Plugin URI:        https://wordpress.org/plugins/accesslens/
 * Description:       Cliente de auditoria de accesibilidad web conforme a la Directiva EAA. Detecta violaciones WCAG mediante un motor externo. El escaner automatico identifica aprox. el 25-40% de los problemas; la revision manual sigue siendo necesaria.
 * Version:           0.1.0
 * Requires at least: 6.0
 * Requires PHP:      8.0
 * Author:            manitosdevs
 * Author URI:        https://profiles.wordpress.org/manitosdevs/
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       accesslens
 * Domain Path:       /languages
 *
 * @package AccessLens
 */

declare(strict_types=1);

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

// Constants.
define( 'ACCESSLENS_VERSION', '0.1.0' );
define( 'ACCESSLENS_PLUGIN_FILE', __FILE__ );
define( 'ACCESSLENS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'ACCESSLENS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'ACCESSLENS_TEXT_DOMAIN', 'accesslens' );

// --- Freemius SDK (licencias, free/Pro, actualizaciones) ---
// public_key es publica por diseno. El secret_key NUNCA va aqui (solo wp-config en dev local).
if ( ! function_exists( 'accesslens_fs' ) ) {
	function accesslens_fs() {
		global $accesslens_fs;

		if ( ! isset( $accesslens_fs ) ) {
			require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';

			$accesslens_fs = fs_dynamic_init(
				array(
					'id'                  => '32766',
					'slug'                => 'accesslens',
					'type'                => 'plugin',
					'public_key'          => 'pk_f51396c26e330b3e511adc8561174',
					'is_premium'          => false,
					'has_premium_version' => true,
					'has_addons'          => false,
					'has_paid_plans'      => true,
					'is_org_compliant'    => true,
					'menu'                => array(
						'slug'       => 'accesslens',
						'first-path' => 'admin.php?page=accesslens',
						'account'    => true,
						'support'    => false,
					),
				)
			);
		}

		return $accesslens_fs;
	}

	// Init Freemius.
	accesslens_fs();
	do_action( 'accesslens_fs_loaded' );
}

// Autoload classes.
require_once ACCESSLENS_PLUGIN_DIR . 'includes/class-accesslens-freemius.php';
require_once ACCESSLENS_PLUGIN_DIR . 'includes/class-accesslens-engine-client.php';
require_once ACCESSLENS_PLUGIN_DIR . 'includes/class-accesslens-ajax.php';
require_once ACCESSLENS_PLUGIN_DIR . 'includes/class-accesslens-admin.php';
require_once ACCESSLENS_PLUGIN_DIR . 'includes/class-accesslens-plugin.php';

/**
 * Bootstrap the plugin.
 */
function accesslens_audit_init(): void {
	AccessLens_Plugin::get_instance();
}
add_action( 'plugins_loaded', 'accesslens_audit_init' );
