<?php

/**
 * Plugin Name: Silica
 * Plugin URI:      https://silicaplugin.com
 * Description:     Bring stunning Glassmorphism to your Elementor designs with Silica.
 * Requires Plugins: elementor
 * Tested up to: 6.9
 * License:         GPLv3
 * License URI:     https://www.gnu.org/licenses/gpl-3.0.en.html
 * Version:         2.0.0
 * Author:          Silica Team
 * Text Domain:     silica
 *
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
define( 'SILICA_VERSION', '2.0.0' );
define( 'SILICA_FILE', __FILE__ );
if ( !function_exists( 'sil_fs' ) ) {
    // Create a helper function for easy SDK access.
    function sil_fs() {
        global $sil_fs;
        if ( !isset( $sil_fs ) ) {
            // Include Freemius SDK.
            require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
            $sil_fs = fs_dynamic_init( array(
                'id'               => '20227',
                'slug'             => 'silica',
                'premium_slug'     => 'silica-pro',
                'type'             => 'plugin',
                'public_key'       => 'pk_8bfe52971973356ba63c42d13e0a8',
                'is_premium'       => false,
                'premium_suffix'   => 'Pro',
                'has_addons'       => false,
                'has_paid_plans'   => true,
                'is_org_compliant' => true,
                'trial'            => array(
                    'days'               => 7,
                    'is_require_payment' => false,
                ),
                'menu'             => array(
                    'slug'    => 'silica-demo',
                    'support' => false,
                ),
                'is_live'          => true,
            ) );
        }
        return $sil_fs;
    }

    // Init Freemius.
    sil_fs();
    // Signal that SDK was initiated.
    do_action( 'sil_fs_loaded' );
}
if ( !function_exists( 'sil_fs_custom_icon' ) ) {
    function sil_fs_custom_icon() {
        return dirname( __FILE__ ) . '/assets/images/icon-256x256.png';
    }

    sil_fs()->add_filter( 'plugin_icon', 'sil_fs_custom_icon' );
}
if ( !function_exists( 'sil_fs_custom_connect_message' ) ) {
    function sil_fs_custom_connect_message(  $message  ) {
        return __( 'You may optionally Connect your account. This is required only for activating your free trial or purchasing a license; it is not a marketing opt-in.', 'silica' );
    }

    sil_fs()->add_filter( 'connect_message', 'sil_fs_custom_connect_message' );
}
if ( !function_exists( 'silica_handle_plugin_update' ) ) {
    function silica_handle_plugin_update() {
        $saved_version = get_option( 'silica_version', '0.0.0' );
        if ( version_compare( $saved_version, SILICA_VERSION, '<' ) && $saved_version !== '0.0.0' ) {
            add_action( 'init', function () {
                if ( did_action( 'elementor/loaded' ) ) {
                    \Elementor\Plugin::$instance->files_manager->clear_cache();
                }
            }, 999 );
        }
        if ( $saved_version !== SILICA_VERSION ) {
            update_option( 'silica_version', SILICA_VERSION );
        }
    }

    add_action( 'plugins_loaded', 'silica_handle_plugin_update', 1 );
}
require_once plugin_dir_path( __FILE__ ) . 'includes/bootstrap.php';