<?php

/**
 * glamer functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Glamer
 */
if ( ! function_exists( 'glamer_fs' ) ) {
    // Create a helper function for easy SDK access.
    function glamer_fs() {
        global $glamer_fs;

        if ( ! isset( $glamer_fs ) ) {
            // Include Freemius SDK.
            require_once dirname(__FILE__) . '/freemius/start.php';

            $glamer_fs = fs_dynamic_init( array(
                'id'                  => '17728',
                'slug'                => 'glamer',
                'type'                => 'theme',
                'public_key'          => 'pk_e0c3ec7052618f5c42c5718413811',
                'is_premium'          => false,
                'has_addons'          => true,
                'has_paid_plans'      => false,
                'menu'                => array(
                    'slug'           => 'glamer-settings',
                    'account'        => true,
                ),
            ) );
        }

        return $glamer_fs;
    }

    // Init Freemius.
    glamer_fs();
    // Signal that SDK was initiated.
    do_action( 'glamer_fs_loaded' );
}
$glamer_theme_data = wp_get_theme();
/*
 * Define theme version
 */
define('GLAMER_VERSION', (WP_DEBUG) ? time() : $glamer_theme_data->get('Version'));

// Inc folder directory
define('GLAMER_INC_DIR', get_template_directory() . '/inc/');

// Link info
define('GLAMER_DOC_URL', 'https://glamer.themeuniver.com/doc');
define('GLAMER_PRO_URL', 'https://themeuniver.com');

// Theme Default Setup
require_once GLAMER_INC_DIR . 'theme-setup.php';

//  Register widget area
require_once GLAMER_INC_DIR . 'widget-area-ini.php';
//  Comments Template
require_once GLAMER_INC_DIR . 'comments-template.php';
/**
 * TGM Plugin
 */
require_once GLAMER_INC_DIR . 'plugins-activation.php';
//  Script and Css Load
require_once GLAMER_INC_DIR . 'css-and-js.php';

/** Implement the Custom Header feature.*/
require_once GLAMER_INC_DIR . 'custom-header.php';

/** Theme Hook Function Load.*/
require_once GLAMER_INC_DIR . 'hook/hook-load.php';


/** Functions which enhance the theme by hooking into WordPress */
require_once GLAMER_INC_DIR . 'template-functions.php';
require_once GLAMER_INC_DIR . 'default-theme-options.php';
require_once GLAMER_INC_DIR . 'nav-menu-walker.php';

/** Customizer additions. */
require_once GLAMER_INC_DIR . 'customizer.php';

/**
 * Load WooCommerce compatibility file.
 */
if (class_exists('WooCommerce')) {
	require get_template_directory() . '/inc/woocommerce.php';
}

function glamer_add_admin_menu() {
    // Add a top-level menu page
    add_menu_page(
        'Glamer Settings',
        'Glamer',
        'manage_options',
        'glamer-settings',
        'glamer_admin_page',
        'dashicons-admin-generic',
        9
    );
}
add_action('admin_menu', 'glamer_add_admin_menu');
function glamer_admin_page() {}

if ( ! class_exists('Glamer_Pro') || ! is_plugin_active('glamer-pro/glamer-pro.php')) {
    function glamer_admin_banner() {
        $current_user = wp_get_current_user();
        // Show only for logged-in users
        if ($current_user->ID == 0) {
            return;
        }
        ?>
        <div class="notice notice-info is-dismissible glamer-admin-banner-box">
            <div class="notice-admin-banenr-wrapper">
                <div class="notice-banner-left">
                    <span class="hello-admin"><?php esc_html_e( 'Hello', 'glamer' ); ?>, <?php echo esc_html($current_user->display_name); ?></span>
                    <h2><?php esc_html_e( 'Welcome To Our Glamer Blog Theme', 'glamer' ); ?></h2>
                    <p><?php esc_html_e( 'Glamer is a flexible and classical blog theme, especially designed for lifestyle, fashion, beauty, creative blogs,personal blogs, and any type of blog site.', 'glamer' ); ?></p>
                    <div class="banner-button">
                        <a href="<?php echo esc_url(trailingslashit(GLAMER_PRO_URL) . 'glamer'); ?>" target="_blank" class="btn"><?php echo esc_html__( 'Live Demo', 'glamer' ); ?></a>
                        <a href="<?php echo esc_url(GLAMER_DOC_URL); ?>" target="_blank" class="btn"><?php echo esc_html__( 'Theme Documentation', 'glamer' ); ?></a>
                        <a href="<?php echo esc_url(trailingslashit(GLAMER_PRO_URL) . 'glamer/#pro-feature'); ?>" target="_blank" class="btn"><?php echo esc_html__( 'Check pro Features', 'glamer' ); ?></a>
                        <a href="<?php echo esc_url(admin_url('admin.php?page=glamer-settings-addons')); ?>" class="btn"><?php echo esc_html__( 'Purchase Pro', 'glamer' ); ?></a>
                    </div>
                </div>
                <div class="notice-banner-right">
                    <a href="<?php echo esc_url(admin_url('admin.php?page=glamer-settings-addons')); ?>">
                    <img src="<?php echo esc_url(get_template_directory_uri() . '/assets/image/admin-banner.png'); ?>">
                    </a>
                </div>
            </div>
        </div>
    
        <?php
    }
    add_action('admin_notices', 'glamer_admin_banner');
}