<?php

/**
 * Prime Slider widget filters
 * @since 3.0.0
 */

use PrimeSlider\Admin\ModuleService;


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

// Settings Filters
if (!function_exists('ps_is_dashboard_enabled')) {
    // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- established function name relied on by the Pro plugin / feedback SDK; renaming would break integration.
    function ps_is_dashboard_enabled() {
        return apply_filters('PrimeSlider/settings/dashboard', true);
    }
}

if (!function_exists('prime_slider_is_widget_enabled')) {
    function prime_slider_is_widget_enabled($widget_id, $options = []) {

        if(!$options){
            $options = get_option('prime_slider_active_modules', []);
        }

        if( ModuleService::is_module_active($widget_id, $options)){
            $widget_id = str_replace('-','_', $widget_id);
            return apply_filters("PrimeSlider/widget/{$widget_id}", true);
        }
    }
}

if (!function_exists('prime_slider_is_extend_enabled')) {
    function prime_slider_is_extend_enabled($widget_id, $options = []) {

        if(!$options){
            $options = get_option('prime_slider_elementor_extend', []);
        }

        if( ModuleService::is_module_active($widget_id, $options)){
            $widget_id = str_replace('-','_', $widget_id);
            return apply_filters("PrimeSlider/extend/{$widget_id}", true);
        }
    }
}

if (!function_exists('prime_slider_is_third_party_enabled')) {
    function prime_slider_is_third_party_enabled($widget_id, $options = []) {

        if(!$options){
            $options = get_option('prime_slider_third_party_widget', []);
        }

        if( ModuleService::is_module_active($widget_id, $options)){
            $widget_id = str_replace('-','_', $widget_id);
            return apply_filters("PrimeSlider/widget/{$widget_id}", true);
        }
    }
}

if ( ! function_exists( 'prime_slider_is_conditional_assets_enabled' ) ) {
	function prime_slider_is_conditional_assets_enabled() {
		return apply_filters( 'PrimeSlider/optimization/conditional_assets', true );
	}
}


