<?php
/**
 * Plugin Name: Everest Forms (Pro)
 * Plugin URI: https://everestforms.net/
 * Description: Everest Forms features and extensions controller.
 * Version: 1.9.5
 * Author: WPEverest
 * Author URI: https://wpeverest.com
 * Text Domain: everest-forms-pro
 * Domain Path: /languages/
 * Requires at least: 5.5
 * Requires PHP: 7.2
 *
 * EVF requires at least: 1.8.0
 * EVF tested up to: 3.0.8
 *
 * @package EverestForms_Pro
 */

defined( 'ABSPATH' ) || exit;

update_option( 'everest-forms-pro_license_active',  'valid' );
update_option( 'everest-forms-pro_errors',  [] );
update_option( 'everest-forms-pro_license_key', 'B5E0B5F8DD8689E6ACA49DD6E6E1A930' );

 // Create a stdClass object and set its properties
$license_data = new stdClass();
$license_data->success = true;
$license_data->license = 'valid';
$license_data->item_id = false;
$license_data->item_name = 'Everest Forms Pro';
$license_data->checksum = 'B5E0B5F8DD8689E6ACA49DD6E6E1A930';
$license_data->expires = '2030-01-01 11:11:11';
$license_data->payment_id = 00000;
$license_data->customer_name = 'GPL';
$license_data->customer_email = 'noreply@gmail.com';
$license_data->license_limit = 5;
$license_data->site_count = 1;
$license_data->activations_left = 4;
$license_data->price_id = false;
$license_data->item_plan = 'agency';

// Update the option in the database
update_option('_transient_evf_pro_license_plan', $license_data, 'yes');

// Define plugin version.
if ( ! defined( 'EFP_VERSION' ) ) {
	define( 'EFP_VERSION', '1.9.5' );
}

if ( ! defined( 'EFP_ABSPATH' ) ) {
	define( 'EFP_ABSPATH', __DIR__ . DIRECTORY_SEPARATOR );
}

// Define plugin root file.
if ( ! defined( 'EFP_PLUGIN_FILE' ) ) {
	define( 'EFP_PLUGIN_FILE', __FILE__ );
}

// Include the main EverestForms_Pro class.
if ( ! class_exists( 'EverestForms_Pro' ) ) {
	include_once __DIR__ . '/includes/class-everest-forms-pro.php';
}

// Include the main EVF_Plugin_Updater class.
if ( ! class_exists( 'EVF_Plugin_Updater' ) ) {
	include_once __DIR__ . '/includes/class-evf-plugin-updater.php';
}

// Initialize the plugin.
add_action( 'plugins_loaded', array( 'EverestForms_Pro', 'get_instance' ), 0 );

/**
 * To clear rewrite_rules.
 *
 * @since 1.7.9
 */
register_activation_hook( __FILE__, array( 'EverestForms_Pro', 'everest_forms_plugin_activation' ) );

/**
 * Autoload the packages.
 *
 * We want to fail gracefully if `composer install` has not been executed yet, so we are checking for the autoloader.
 * If the autoloader is not present, let's log the failure and display a nice admin notice.
 */
$autoloader = __DIR__ . '/vendor/autoload.php';
if ( is_readable( $autoloader ) && version_compare( PHP_VERSION, '7.1.3', '>=' ) ) {
	require $autoloader;
} else {
	if ( version_compare( PHP_VERSION, '7.1.3', '<=' ) ) {
		return;
	}

	if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
		error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
			sprintf(
				/* translators: 1: composer command. 2: plugin directory */
				esc_html__( 'Your installation of the Everest Forms (Pro) plugin is incomplete. Please run %1$s within the %2$s directory.', 'everest-forms-pro' ),
				'`composer install`',
				'`' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '`'
			)
		);
	}

	/**
	 * Outputs an admin notice if composer install has not been ran.
	 */
	add_action(
		'admin_notices',
		function () {
			?>
			<div class="notice notice-error">
				<p>
					<?php
					printf(
						/* translators: 1: composer command. 2: plugin directory */
						esc_html__( 'Your installation of the Everest Forms (Pro) plugin is incomplete. Please run %1$s within the %2$s directory.', 'everest-forms-pro' ),
						'<code>composer install</code>',
						'<code>' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '</code>'
					);
					?>
				</p>
			</div>
			<?php
		}
	);
	return;
}

\EverestForms\Pro\Service::instance();
\EverestForms\Pro\Capabilities\Integrations::instance();
