<?php

/**
 * Wrapper for functions.php
 */
if ( !class_exists( 'CloudPress_Freemius_Mock' ) ) {
    class CloudPress_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( 'clo_fs' ) ) {
    // Create a helper function for easy SDK access.
    function clo_fs() {
        global $clo_fs;
        if ( !isset( $clo_fs ) ) {
            $cloudpress_theme = wp_get_theme();
            $allowed_themes = array(
                'CloudPress',
                'CloudPress child',
                'CloudPress Child',
                'CloudPress Pro',
                'CloudPress Pro child',
                'CloudPress Pro Child'
            );
            if ( in_array( $cloudpress_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( 'SPICEB_PLUGIN_DIR' ) && file_exists( SPICEB_PLUGIN_DIR . 'inc/freemius/start.php' ) ) {
                    require_once SPICEB_PLUGIN_DIR . 'inc/freemius/start.php';
                }
                if ( function_exists( 'fs_dynamic_init' ) ) {
                    $clo_fs = fs_dynamic_init( array(
                        'id'               => '10311',
                        'slug'             => 'cloudpress',
                        'premium_slug'     => 'cloudpress-pro',
                        'type'             => 'theme',
                        'public_key'       => 'pk_f154c3c98430952e66064cd8fac0e',
                        'is_premium'       => false,
                        'premium_suffix'   => 'Pro',
                        'has_addons'       => false,
                        'has_paid_plans'   => true,
                        'is_org_compliant' => true,
                        'menu'             => array(
                            'slug'    => 'cloudpress-welcome',
                            'account' => true,
                            'support' => true,
                            'contact' => false,
                            'parent'  => array(
                                'slug' => 'themes.php',
                            ),
                        ),
                        'navigation'       => 'menu',
                        'is_live'          => true,
                    ) );
                }
            }
        }
        if ( !isset( $clo_fs ) || !is_object( $clo_fs ) ) {
            $clo_fs = new CloudPress_Freemius_Mock();
        }
        return $clo_fs;
    }

    // Init Freemius.
    clo_fs();
    // Signal that SDK was initiated.
    do_action( 'clo_fs_loaded' );
}
if ( clo_fs()->can_use_premium_code() ) {
    require get_parent_theme_file_path( '/pro/functions.php' );
} else {
    require get_parent_theme_file_path( '/free/functions.php' );
}