<?php
/**
 * ZMND Widgets Assets Registration
 */

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

// Примечание: Функция ws_zmnd_enqueue_assets перемещена в файл ws-assets.php
// для предотвращения дублирования и конфликтов

class WS_ZMND_Assets {
    
    /**
     * List of all ZMND widgets
     */
    private static $widgets = [
        'ws_zmnd_hello_world',
        'ws_zmnd_horizontal_tabs',
        'ws_zmnd_moving_gallery',
        'ws_zmnd_animation_button',
        'ws_zmnd_animation_image',
        'ws_zmnd_cta_user',
        'ws_zmnd_icon_box',
        'ws_zmnd_marquebox',
        'ws_zmnd_before_after',
        'ws_zmnd_interactive_hover_image',
        'ws_zmnd_woo_product_grid'
    ];

    /**
     * Register assets
     */
    public static function register() {
        // Ресурсы уже подключены через глобальные хуки
    }

    /**
     * Load assets (styles and scripts)
     * 
     * Note: This method is no longer used as we're loading assets directly
     * through global hooks for better compatibility.
     */
    public static function load_assets() {
        // This method is kept for backward compatibility
    }
    
    /**
     * Check if a specific widget is active
     *
     * @param string $widget_name Widget name
     * @return bool
     */
    public static function is_widget_active($widget_name) {
        // Check Elementor Element Manager settings
        $element_manager_settings = get_option('elementor_disabled_widgets', []);
        
        // If widget is not in the disabled list, it's active
        if (!in_array($widget_name, $element_manager_settings)) {
            return true;
        }
        
        return false;
    }
    
    /**
     * Check if there are any active ZMND widgets
     *
     * @return bool
     */
    public static function has_active_widgets() {
        foreach (self::$widgets as $widget) {
            if (self::is_widget_active($widget)) {
                return true;
            }
        }
        
        return false;
    }
}

// Initialize assets
WS_ZMND_Assets::register();
