<?php
/**
 * Plugin Name: Firevert – Sale booster for WooCommerce
 * Plugin URI: https://firevert.com/
 * Description: Fire up your e-commerce sales with a simple to configure but powerful WooCommerce Plugin! Firevert is a set of widgets that not only makes it easier for your customers to take advantage of promotions, but also helps them make faster and more accurate purchasing decisions. Get it now!
 * Version: 1.0.3
 * Requires at least: 6.0
 * Tested up to: 6.8
 * Requires PHP: 7.4
 * Requires Plugins: woocommerce
 * Author: iLabs LTD
 * Author URI: https://ilabs.dev/
 * Text Domain: firevert
 * Domain Path: /languages
 * License: GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 *
 * Copyright 2025 iLabs LTD
 *
 * @package Firevert
 */

declare( strict_types=1 );

use Ilabs\Firevert\Core\Exceptions\CoreBootException;
use Ilabs\Firevert\Core\ServiceContainer;
use Ilabs\Firevert\Firevert;

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

$headers = get_file_data(
	__FILE__,
	array(
		'name'             => 'Plugin Name',
		'description'      => 'Description',
		'version'          => 'Version',
		'author'           => 'Author',
		'author_uri'       => 'Author URI',
		'requires_php'     => 'Requires PHP',
		'requires_plugins' => 'Requires Plugins',
		'tested_up_to'     => 'Tested up to',
		'text_domain'      => 'Text Domain',
		'domain_path'      => 'Domain Path',
	),
	'plugin'
);

$config = array(
	'__FILE__'                => __FILE__,
	'name'                    => 'Firevert',
	'slug'                    => 'firevert',
	'lang_dir'                => 'lang',
	'text_domain'             => 'firevert',
	'min_php_int'             => 70400,
	'min_php'                 => 7.4,
	'required_plugins'        => array( 'woocommerce' ),
	'required_php_extensions' => array( 'curl' ),
);

require_once __DIR__.'/system.php';

if ( ( new Firevert_System_Check( $config ) )->evaluate_system() ) {
	require_once __DIR__ . '/vendor/autoload.php';
	require_once 'dependencies.php';
	require_once __DIR__ . '/src/Core/Helpers.php';

	$container = new ServiceContainer();
	firevert_container( $container );
	$container->load_external_dependencies();
	$container->initialize_defaults( $config, $headers );

	/**
	 * Returns singleton instance of the Firevert plugin.
	 *
	 * Used to initialize and retrieve the main plugin class instance.
	 *
	 * @param ServiceContainer $container Dependency injection container.
	 *
	 * @return Firevert Main plugin instance.
	 */
	function ilabs_firevert( ServiceContainer $container ): Firevert {
		static $plugin = null;

		if ( ! $plugin ) {
			$plugin = new Firevert( $container );
		}

		return $plugin;
	}

	try {
		ilabs_firevert( $container )->execute( $config );
	} catch ( Exception $e ) {
		throw new CoreBootException( esc_html( $e->getMessage() ) );
	}
}
