<?php

/**
 * Plugin Name:       Price Change Alerts
 * Description:       Get an email notification whenever a WooCommerce product price changes — no matter how it was changed.
 * Version:           1.3.4
 * Author:            Enter2Web
 * Author URI:        https://enter2web.co.il
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       e2w-price-change-alerts
 * Domain Path:       /languages
 * Requires at least: 6.0
 * Requires PHP:      7.4
 * Requires Plugins:  woocommerce
 *
 * @package E2W_Price_Change_Alerts
 */
// Exit if accessed directly.
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
if ( function_exists( 'e2w_price_change_alerts_fs' ) ) {
    // Premium-версия уже активна — free-версия отдаёт ей basename,
    // чтобы Freemius авто-деактивировал free при активации paid.
    e2w_price_change_alerts_fs()->set_basename( false, __FILE__ );
} else {
    /**
     * DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE
     * `function_exists` CALL ABOVE TO PROPERLY WORK.
     */
    if ( !function_exists( 'e2w_price_change_alerts_fs' ) ) {
        define( 'E2W_PRICE_CHANGE_ALERTS_VERSION', '1.3.4' );
        define( 'E2W_PRICE_CHANGE_ALERTS_FILE', __FILE__ );
        define( 'E2W_PRICE_CHANGE_ALERTS_PATH', plugin_dir_path( __FILE__ ) );
        define( 'E2W_PRICE_CHANGE_ALERTS_URL', plugin_dir_url( __FILE__ ) );
        /**
         * Helper for easy SDK access. Уникальный префикс обязателен.
         *
         * Секретный ключ (sk_...) НЕ хранится в коде — только в окружении при локальной разработке.
         *
         * @return Freemius
         */
        function e2w_price_change_alerts_fs() {
            global $e2w_price_change_alerts_fs;
            if ( !isset( $e2w_price_change_alerts_fs ) ) {
                // Include Freemius SDK (git submodule в vendor/freemius).
                require_once E2W_PRICE_CHANGE_ALERTS_PATH . 'vendor/freemius/start.php';
                $e2w_price_change_alerts_fs = fs_dynamic_init( array(
                    'id'               => '35058',
                    'slug'             => 'e2w-price-change-alerts',
                    'premium_slug'     => 'e2w-price-change-alerts-premium',
                    'type'             => 'plugin',
                    'public_key'       => 'pk_3ab885c6f506c0afd652096b50b06',
                    'is_premium'       => false,
                    'premium_suffix'   => 'Premium',
                    'has_addons'       => false,
                    'has_paid_plans'   => true,
                    'is_org_compliant' => true,
                    'anonymous_mode'   => true,
                    'trial'            => array(
                        'days'               => 3,
                        'is_require_payment' => true,
                    ),
                    'menu'             => array(
                        'slug'    => 'e2w-price-change-alerts',
                        'support' => false,
                        'parent'  => array(
                            'slug' => 'options-general.php',
                        ),
                    ),
                    'is_live'          => true,
                ) );
            }
            return $e2w_price_change_alerts_fs;
        }

        // Init Freemius.
        e2w_price_change_alerts_fs();
        // Signal that SDK was initiated.
        do_action( 'e2w_price_change_alerts_fs_loaded' );
    }
    /**
     * Bootstrap плагина.
     */
    require_once E2W_PRICE_CHANGE_ALERTS_PATH . 'includes/core/class-e2w-price-change-alerts-plugin.php';
    require_once E2W_PRICE_CHANGE_ALERTS_PATH . 'uninstall-hook.php';
    /**
     * Точка входа.
     */
    function e2w_price_change_alerts_run() {
        $plugin = new E2W_Price_Change_Alerts_Plugin();
        $plugin->run();
    }

    e2w_price_change_alerts_run();
}