<?php

/*
 * Plugin Name: Shois Chat Button
 * Description: Multi-platform animated chat button with visual template builder. Supports WhatsApp, Telegram, Messenger, Instagram and 9 more platforms.
 * Version:     1.0.1
 * Requires at least: 5.8
 * Requires PHP: 7.4
 * Author:      Shois WP
 * Author URI:  https://profiles.wordpress.org/shoiswp/
 * License:     GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: shois-chat-button
 * Domain Path: /languages
 */
// Prevent direct access.
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
/**
 * Freemius auto-deactivation mechanism.
 *
 * When a user activates the Premium version, Freemius automatically
 * deactivates the Free version. This if/else structure is REQUIRED
 * for that mechanism to work properly.
 *
 * @see https://freemius.com/help/documentation/wordpress-sdk/auto-deactivation/
 */
if ( function_exists( 'scb_fs' ) ) {
    // If Freemius is already loaded (e.g. Premium version active),
    // tell it the basename of this (free) file so it can deactivate it.
    scb_fs()->set_basename( false, __FILE__ );
} else {
    /**
     * DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE
     * `function_exists` CALL ABOVE TO PROPERLY WORK.
     */
    if ( !function_exists( 'scb_fs' ) ) {
        /**
         * Create a helper function for easy SDK access.
         *
         * @return \Freemius
         */
        function scb_fs() {
            global $scb_fs;
            if ( !isset( $scb_fs ) ) {
                // Include Freemius SDK.
                require_once dirname( __FILE__ ) . '/freemius/start.php';
                $scb_fs = fs_dynamic_init( array(
                    'id'               => '29326',
                    'slug'             => 'shois-chat-button',
                    'type'             => 'plugin',
                    'public_key'       => 'pk_85e6d492e9c39ff1344c751c92b3c',
                    'is_premium'       => false,
                    'premium_suffix'   => 'Premium',
                    'has_addons'       => false,
                    'has_paid_plans'   => true,
                    'is_org_compliant' => true,
                    'trial'            => array(
                        'days'               => 7,
                        'is_require_payment' => true,
                    ),
                    'menu'             => array(
                        'slug'    => 'shois-chat-button',
                        'support' => false,
                    ),
                    'is_live'          => true,
                ) );
            }
            return $scb_fs;
        }

        // Init Freemius.
        scb_fs();
        // Signal that SDK was initiated.
        do_action( 'scb_fs_loaded' );
        // Freemius Uninstall Hook.
        // Runs after Freemius reports the uninstall event to its servers.
        scb_fs()->add_action( 'after_uninstall', array('SHCB_Activator', 'uninstall') );
    }
    /**
     * Plugin constants.
     */
    define( 'SHCB_VERSION', '1.0.1' );
    define( 'SHCB_PLUGIN_FILE', __FILE__ );
    define( 'SHCB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    define( 'SHCB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    define( 'SHCB_SCHEMA_VERSION', 1 );
    define( 'SHCB_REST_NAMESPACE', 'shois-chat/v1' );
    /**
     * Include required files.
     */
    require_once SHCB_PLUGIN_DIR . 'includes/class-shcb-activator.php';
    require_once SHCB_PLUGIN_DIR . 'includes/class-shcb-template-cpt.php';
    require_once SHCB_PLUGIN_DIR . 'includes/class-shcb-platform-handler.php';
    require_once SHCB_PLUGIN_DIR . 'includes/class-shcb-rest-api.php';
    require_once SHCB_PLUGIN_DIR . 'includes/class-shcb-widget-renderer.php';
    require_once SHCB_PLUGIN_DIR . 'includes/class-shcb-plugin.php';
    /**
     * Activation hook.
     */
    function shcb_activate_plugin() {
        SHCB_Activator::activate();
    }

    register_activation_hook( __FILE__, 'shcb_activate_plugin' );
    /**
     * Deactivation hook.
     */
    function shcb_deactivate_plugin() {
        SHCB_Activator::deactivate();
    }

    register_deactivation_hook( __FILE__, 'shcb_deactivate_plugin' );
    /**
     * Initialize the plugin on plugins_loaded.
     */
    function shcb_init_plugin() {
        SHCB_Plugin::get_instance();
    }

    add_action( 'plugins_loaded', 'shcb_init_plugin' );
}
// end else