<?php

/**
 * Wallstreet Theme - Main functions.php
 * Freemius integration - loads free or pro version based on license
 */
if ( !class_exists( 'Wallstreet_Freemius_Mock' ) ) {
    class Wallstreet_Freemius_Mock {
        public function can_use_premium_code() {
            return false;
        }

        public function is_premium() {
            return false;
        }

        public function is_plan( $plan ) {
            return false;
        }

        public function is_free_plan() {
            return true;
        }

    }

}
if ( !function_exists( 'wp_fs' ) ) {
    // Create a helper function for easy SDK access.
    function wp_fs() {
        global $wp_fs;
        if ( !isset( $wp_fs ) ) {
            $wallstreet_theme = wp_get_theme();
            $allowed_themes = array(
                'Wallstreet',
                'Wallstreet child',
                'Wallstreet Child',
                'Wallstreet Pro',
                'Wallstreet Pro child',
                'Wallstreet Pro Child',
                'Wallstreet-Pro',
                'Wallstreet-Pro child',
                'Wallstreet-Pro Child'
            );
            if ( in_array( $wallstreet_theme->get( 'Name' ), $allowed_themes ) ) {
                // Include Freemius SDK.
                if ( file_exists( dirname( __FILE__ ) . '/freemius/start.php' ) ) {
                    require_once dirname( __FILE__ ) . '/freemius/start.php';
                } elseif ( defined( 'WC__PLUGIN_DIR' ) && file_exists( WC__PLUGIN_DIR . 'freemius/start.php' ) ) {
                    require_once WC__PLUGIN_DIR . 'freemius/start.php';
                }
                if ( function_exists( 'fs_dynamic_init' ) ) {
                    $wp_fs = fs_dynamic_init( array(
                        'id'               => '11205',
                        'slug'             => 'wallstreet',
                        'premium_slug'     => 'wallstreet-pro',
                        'name'             => 'Wallstreet Pro Panel',
                        'type'             => 'theme',
                        'public_key'       => 'pk_d137ec37b3cb9ac46b97eba73ac6a',
                        'is_premium'       => false,
                        'premium_suffix'   => 'Pro',
                        'has_addons'       => false,
                        'has_paid_plans'   => true,
                        'is_org_compliant' => true,
                        'menu'             => array(
                            'slug'    => 'wallstreet-welcome',
                            'title'   => 'Wallstreet Pro Panel',
                            'account' => true,
                            'support' => true,
                            'contact' => false,
                        ),
                        'navigation'       => 'menu',
                        'is_live'          => true,
                    ) );
                }
            }
        }
        if ( !isset( $wp_fs ) || !is_object( $wp_fs ) ) {
            $wp_fs = new Wallstreet_Freemius_Mock();
        }
        return $wp_fs;
    }

    // Init Freemius.
    wp_fs();
    // Signal that SDK was initiated.
    do_action( 'wp_fs_loaded' );
}
// Load Pro or Free functions based on Freemius license
if ( wp_fs()->can_use_premium_code() ) {
    require get_template_directory() . '/pro/functions.php';
} else {
    require get_template_directory() . '/free/functions.php';
}