<?php

if ( !defined( 'ABSPATH' ) ) {
    exit;
}
if ( !class_exists( 'silica' ) ) {
    class Silica {
        public static function init() {
            add_action(
                'elementor/element/container/section_layout/after_section_end',
                [__CLASS__, 'register_elementor_controls'],
                10,
                2
            );
            add_action( 'wp_enqueue_scripts', [__CLASS__, 'enqueue_assets'] );
        }

        public static function register_elementor_controls( $element, $args ) {
            $element->start_controls_section( 'silica_section', [
                'label' => __( 'Silica Glass', 'silica' ),
                'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
            ] );
            $element->add_control( 'silica_glass', [
                'label'        => __( 'Enable', 'silica' ),
                'type'         => \Elementor\Controls_Manager::SWITCHER,
                'default'      => '',
                'prefix_class' => 'silicaGlass-',
            ] );
            $element->add_control( 'silica_tip', [
                'type'        => \Elementor\Controls_Manager::NOTICE,
                'notice_type' => 'info',
                'dismissible' => true,
                'heading'     => esc_html__( 'Welcome to Silica!', 'silica' ),
                'content'     => esc_html__( 'Use native Elementor background colour, border radius and other styling options to customize your Silica Glass effect.', 'silica' ),
                'condition'   => [
                    'silica_glass' => 'yes',
                ],
            ] );
            do_action( 'silica/after_base_controls', $element, $args );
            $element->end_controls_section();
        }

        public static function enqueue_assets() {
            wp_enqueue_style(
                'silica-css',
                plugin_dir_url( __FILE__ ) . '../assets/css/silica.css',
                [],
                '2.0.0'
            );
            wp_enqueue_script(
                'silica-js',
                plugin_dir_url( __FILE__ ) . '../assets/js/silica.js',
                ['jquery'],
                '2.0.0',
                true
            );
        }

    }

}