<?php

/**
 * Rambo Theme - Main functions.php
 * Freemius integration - loads free or pro version based on license
 */
if ( !class_exists( 'Rambo_Freemius_Mock' ) ) {
    class Rambo_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( 'ram_fs' ) ) {
    // Create a helper function for easy SDK access.
    function ram_fs() {
        global $ram_fs;
        if ( !isset( $ram_fs ) ) {
            $rambo_theme = wp_get_theme();
            $allowed_themes = array(
                'Rambo',
                'Rambo child',
                'Rambo Child',
                'Rambo Pro',
                'Rambo Pro child',
                'Rambo Pro Child',
                'Rambo-Pro',
                'Rambo-Pro child',
                'Rambo-Pro Child'
            );
            if ( in_array( $rambo_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' ) ) {
                    $ram_fs = fs_dynamic_init( array(
                        'id'               => '11282',
                        'slug'             => 'rambo',
                        'premium_slug'     => 'rambo-pro',
                        'type'             => 'theme',
                        'public_key'       => 'pk_86382d3a3a35e977b1b4654c728e7',
                        'is_premium'       => false,
                        'premium_suffix'   => 'Pro',
                        'has_addons'       => false,
                        'has_paid_plans'   => true,
                        'menu'             => array(
                            'slug'    => 'rambo-welcome',
                            'account' => true,
                            'support' => true,
                            'contact' => false,
                            'parent'  => array(
                                'slug' => 'themes.php',
                            ),
                        ),
                        'navigation'       => 'menu',
                        'is_live'          => true,
                        'is_org_compliant' => true,
                    ) );
                }
            }
        }
        if ( !isset( $ram_fs ) || !is_object( $ram_fs ) ) {
            $ram_fs = new Rambo_Freemius_Mock();
        }
        return $ram_fs;
    }

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