<?php
/**
 * Plugin Name:     Sifency Addons
 * Plugin URI:      https://sifency-addons.sifency.com
 * Description:     A collection of powerful and beautiful widgets for Elementor.
 * Author:          Sifency
 * Author URI:      https://sifency.com
 * Text Domain:     sifency-addons
 * Domain Path: 	/languages
 * Version:         1.0.4
 * Requires at least: 6.2
 * Requires PHP:      7.4
 * Elementor tested up to: 3.32.5
 * Elementor Pro tested up to: 3.32.5
 * License: GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 *
 * @package         Sifency_Addons
 * @version         1.0.4
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// Define plugin constants.
define( 'SIFENCY_ADDONS_VERSION', '1.0.4' );
define( 'SIFENCY_ADDONS_FILE', __FILE__ );
define( 'SIFENCY_ADDONS_DIR', plugin_dir_path( __FILE__ ) );
define( 'SIFENCY_ADDONS_URL', plugin_dir_url( __FILE__ ) );
define( 'SIFENCY_ADDONS_MIN_PHP_VERSION', '7.4.0' );
define( 'SIFENCY_ADDONS_MIN_WP_VERSION', '6.7' );
define( 'SIFENCY_MIN_ELEMENTOR_VERSION', '3.5.0' );

// Include the main plugin class.
require_once SIFENCY_ADDONS_DIR . 'includes/notice.php';
require_once SIFENCY_ADDONS_DIR . 'base/sifency-class.php';

/**
 * Track plugin version updates for rollback functionality
 */
function sifency_addons_track_version() {
    $stored_version = get_option( 'sifency_addons_stored_version' );
    
    if ( $stored_version !== SIFENCY_ADDONS_VERSION ) {
        // Version changed, record it
        if ( class_exists( 'Sifency_Addons_Admin_Options' ) ) {
            $options = Sifency_Addons_Admin_Options::instance();
            $options->track_version_update( SIFENCY_ADDONS_VERSION );
        }
        
        update_option( 'sifency_addons_stored_version', SIFENCY_ADDONS_VERSION );
    }
}
add_action( 'plugins_loaded', 'sifency_addons_track_version' );

/**
 * Main instance of Sifency_Addons.
 *
 * Returns the main instance of Sifency_Addons to prevent the need to use globals.
 *
 * @return Sifency_Addons
 */
function sifency_addons() {
	return Sifency_Addons::instance();
}

// Start the plugin.
sifency_addons();

// Register activation hook.
register_activation_hook( __FILE__, [ 'Sifency_Addons', 'activate' ] );