<?php
/**
 * Freemius SDK integration for Fast Fuzzy Search.
 *
 * @package FastFuzzySearch
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( ! function_exists( 'ffs_fs' ) ) {
    /**
     * Create a helper function for easy SDK access.
     *
     * @return Freemius
     */
    function ffs_fs() {
        global $ffs_fs;

        if ( ! isset( $ffs_fs ) ) {
            // Include Freemius SDK — auto-loaded through Composer.

            $ffs_fs = fs_dynamic_init(
                array(
                    'id'                  => '32809',
                    'slug'                => 'fast-fuzzy-search',
                    'premium_slug'        => 'fast-fuzzy-search',
                    'type'                => 'plugin',
                    'public_key'          => 'pk_4514bd930f02b659c8dd82bf1e5e6',
                    'is_premium'          => false,
                    'premium_suffix'      => 'Pro',
                    'has_premium_version' => true,
                    'has_addons'          => false,
                    'has_paid_plans'      => true,
                    'is_org_compliant'    => true,
                    'menu'                => array(
                        'slug'           => 'fast_fuzzy_search_options',
                        'support'        => false,
                        'pricing'        => true,
                    ),
                )
            );
        }

        return $ffs_fs;
    }

    // Init Freemius.
    ffs_fs();

    // Signal that SDK was initiated.
    do_action( 'ffs_fs_loaded' );
}

if ( ! function_exists( 'ffs_is_premium' ) ) {
    /**
     * Check if the currently running version is the premium (Pro) version
     * with an active premium license.
     *
     * @return bool
     */
    function ffs_is_premium() {
        if ( ! isset( $GLOBALS['ffs_fs'] ) ) {
            return false;
        }

        return ffs_fs()->can_use_premium_code();
    }
}

if ( ! function_exists( 'ffs_is_premium_activated' ) ) {
    /**
     * Check if a premium license is active (paid plan).
     *
     * @return bool
     */
    function ffs_is_premium_activated() {
        if ( ! isset( $GLOBALS['ffs_fs'] ) ) {
            return false;
        }

        return ffs_fs()->can_use_premium_code();
    }
}
