<?php
declare( strict_types=1 );

use FiboFilters\Config\Env;

$fibofilters_plugin_dir  = __DIR__;
$fibofilters_main_file   = $fibofilters_plugin_dir . '/fibofilters.php';
$fibofilters_plugin_data = get_file_data(
	$fibofilters_main_file,
	[
		'version'        => 'Version',
		'wc_min_version' => 'WC requires at least',
	],
	'plugin'
);
$fibofilters_readme_file = $fibofilters_plugin_dir . '/readme.txt';
$fibofilters_readme_data = get_file_data(
	$fibofilters_readme_file,
	[
		'wp_min_version' => 'Requires at least',
	],
	'plugin'
);

if (
	file_exists( $fibofilters_plugin_dir . '/vendor/autoload.php' ) &&
	file_exists( $fibofilters_plugin_dir . '/vendor/freemius/wordpress-sdk/start.php' )
) {
	require_once $fibofilters_plugin_dir . '/vendor/autoload.php';
	require_once $fibofilters_plugin_dir . '/vendor/freemius/wordpress-sdk/start.php';
} else {
	return;
}

Env::init( $fibofilters_main_file, array_merge( $fibofilters_plugin_data, $fibofilters_readme_data ) );

/** @var FiboFilters\Config\Initializer $fibofilters_initializer */
$fibofilters_initializer = FiboFilters\DI\ContainerWrapper::get_instance()->get( FiboFilters\Config\Initializer::class );
$fibofilters_initializer->init();

if ( did_action( 'pre_uninstall_plugin' ) ) {
	$fibofilters_freemius = FiboFilters\DI\ContainerWrapper::get_instance()->get( Freemius::class );
	$fibofilters_freemius->add_action( 'after_uninstall', [ '\FiboFilters\Config\Uninstall', 'after_uninstall' ] );
}
