<?php

/**
 * Plugin Name: Payment Plugins for Stripe Elementor - by Pay Addons
 * Description: Easily drag and drop to build any type of powerful Stripe payment form with Elementor's builder. Create one-time payments, recurring subscriptions, donations, event tickets, product sales, and custom payment forms in minutes. No coding required - built 100% for Elementor. Just design, configure, and collect payments.
 * Version:     2.7.4
 * Author:    	Payment Addons, support@payaddons.com 
 * Author URI:	https://payaddons.com
 * Text Domain: pay-addons-for-elementor
 * License:     GPL v2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Requires Plugins: elementor
 * Elementor tested up to: 4.1.4
 * Elementor Pro tested up to: 4.1.0
 * 
  */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
/**
 * Defining plugin constants.
 *
 * @since 1.0.0
 */
define('EPA_PLUGIN_NAME', 'Elementor Pay Addons');
define('EPA_PLUGIN_SLUG', 'elementor-pay-addons');
define('EPA_PLUGIN_VERSION', '2.7.4');
define('EPA_PLUGIN_URL', 'https://payaddons.com/');
define('EPA_PLUGIN_TEMPLATE_URL', 'https://api.payaddons.com/elementor');
define('EPA_ADDONS_REST_API', 'epa/v1/');
define('EPA_ADDONS_FILE', __FILE__);
define('EPA_ADDONS_BASENAME', plugin_basename(__FILE__));
define('EPA_ADDONS_PATH', trailingslashit(plugin_dir_path(__FILE__)));
define('EPA_ADDONS_ASSET_PATH', EPA_ADDONS_PATH . '/assets/');
define('EPA_ADDONS_EMAILS_TEMPLATE_PATH', EPA_ADDONS_PATH . '/includes/templates/emails/');
define('EPA_ADDONS_URL', trailingslashit(plugins_url('/', __FILE__)));
define('EPA_ADDONS_ASSET_URL', EPA_ADDONS_URL . '/assets/');
define('EPA_ADDONS_LOG_FOLDER', plugin_dir_path(__FILE__) . 'logs');

require_once('freemius-config.php');
require_once EPA_ADDONS_PATH . '/autoload.php';
require_once EPA_ADDONS_PATH . '/vendor/autoload.php';
require_once EPA_ADDONS_PATH . '/bootstrap.php';
require_once EPA_ADDONS_PATH . '/includes/functions.php';

/**
 * Run plugin after all others plugins
 *
 * @since 1.0.0
 */
add_action( 'plugins_loaded', function() {
	\Elementor_Pay_Addons\Bootstrap::instance();
} );

/**
 * Activation hook
 *
 * @since v1.0.0
 */
register_activation_hook(__FILE__, function () {
});

/**
 * Deactivation hook
 *
 * @since v1.0.0
 */
register_deactivation_hook(__FILE__, function () {
});

// Hook your uninstall function to Freemius after_uninstall action
epa_fs()->add_action('after_uninstall', 'epa_plugin_cleanup');

if (! function_exists('epa_plugin_cleanup')) {
	function epa_plugin_cleanup()
	{
		$sys_settings = get_option('epa_sys_settings', []);
		$keep_data = $sys_settings['enable_keep_data'];
		if (!$keep_data) {
			// Delete options.
			delete_option('epa_stripe_settings');
			delete_option('epa_sys_settings');
			delete_option('epa_db_version');
			require_once __DIR__ . '/includes/database/transaction-query.php';
			\Elementor_Pay_Addons\Database\Transaction_Query::remove_table();
		}
	}
}