<?php
/**
 * Plugin Name:       Icon Vault for Elementor
 * Plugin URI:        https://naimreza.com/code-lab/
 * Description:       Adds the free Themify Icons library to Elementor's native Icon Manager, available in every Elementor widget (Icon, Icon Box, Icon List, Icon Tabs, and more) with full color and style control support. Not affiliated with or endorsed by Elementor.
 * Version:           1.0.0
 * Requires at least: 6.0
 * Requires PHP:      7.4
 * Requires Plugins:  elementor
 * Author:            Naim Reza
 * Author URI:        https://naimreza.com
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       icon-vault-for-elementor
 * Domain Path:       /languages
 */

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

define( 'EIV_VERSION', '1.0.0' );
define( 'EIV_PLUGIN_FILE', __FILE__ );
define( 'EIV_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'EIV_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'EIV_OPTION_KEY', 'eiv_settings' );

/**
 * Show an admin notice if Elementor is not active.
 */
function eiv_missing_elementor_notice() {
	?>
	<div class="notice notice-warning">
		<p>
			<?php esc_html_e( 'Icon Vault for Elementor requires Elementor to be installed and active.', 'icon-vault-for-elementor' ); ?>
		</p>
	</div>
	<?php
}

/**
 * Bootstrap the plugin once all plugins are loaded, so we can reliably
 * check whether Elementor is active.
 */
function eiv_init() {

	if ( ! did_action( 'elementor/loaded' ) ) {
		add_action( 'admin_notices', 'eiv_missing_elementor_notice' );
		return;
	}

	require_once EIV_PLUGIN_DIR . 'includes/class-icon-library-loader.php';
	require_once EIV_PLUGIN_DIR . 'includes/class-admin-settings.php';

	Elementor_Icon_Vault\Icon_Library_Loader::instance();
	Elementor_Icon_Vault\Admin_Settings::instance();
}
add_action( 'plugins_loaded', 'eiv_init' );
