<?php
/*
 * Plugin Name:       Floating Awesome Button
 * Plugin URI:        https://artistudio.xyz
 * Description:       Floating Awesome Button (FAB): Elevate engagement with customizable action buttons. Showcase modals,shortcodes, widgets & links effortlessly.
 * Version:           2.21.0
 * Author:            Artistudio
 * Author URI:        https://brain.artistudio.xyz/artistudio/WordPress-floating-awesome-button
 * License:           GPL-3.0
 * License URI:       http://www.gnu.org/licenses/gpl-3.0.txt
 *
 * Text Domain: floating-awesome-button
 * Domain Path: /languages/
 *
  *
 * SOFTWARE LICENSE INFORMATION
 *
 * Copyright 2021 Artistudio, all rights reserved.
 *
 * For detailed information regarding to the licensing of
 * this software, please review the license.txt
*/

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

/** Load Composer Vendor */
if ( ! class_exists( 'Fab\Plugin' ) ) {
    require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
}

// Load plugin files freemius, helper, and referral.
$plugin_files = array(
    'freemius',
    'helper',
    'referral',
);
foreach ( $plugin_files as $file ) {
    if ( file_exists( plugin_dir_path( __FILE__ ) . $file . '.php' ) ) {
        require_once plugin_dir_path( __FILE__ ) . $file . '.php';
    }
}

// Create FAB global function.
if ( ! function_exists( 'FAB' ) ) {
    /**
     * Get the instance of the plugin
     *
     * @return \Fab\Plugin
     */
    function FAB() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
        return \Fab\Plugin::getInstance();
    }
}

/**
 * Load object.
 *
 * @param object $object Object to initiate.
 * @return void
 */
function fab_object_initiate( $object ) {
    // Initiate functions.
    method_exists( $object, 'initialize' ) && $object->initialize();

    // Run functions.
    method_exists( $object, 'run' ) && $object->run();

    // Activation hook.
    method_exists( $object, 'activate' ) && register_activation_hook( __FILE__, array( $object, 'activate' ) );

    // Deactivation hook.
    method_exists( $object, 'deactivate' ) && register_deactivation_hook( __FILE__, array( $object, 'deactivate' ) );

    // Uninstall hook.
    method_exists( $object, 'uninstall' ) && register_uninstall_hook( __FILE__, array( 'Plugin', 'uninstall' ) );
}

// Initiate objects.
fab_object_initiate( \Fab\Plugin\Constants::getInstance() );
fab_object_initiate( \Fab\Plugin\Config::getInstance() );
fab_object_initiate( \Fab\Plugin::getInstance() );

// Load premium plugin.
if ( fab_freemius()->is__premium_only() && \Fab()->Helper->isPremiumPlan() ) {
    // This script is required to load the premium plugin.
    // Because the premium code separation is done via freemius.
    fab_object_initiate( \FabPremium\Plugin::getInstance() );
}
