<?php
/**
 * Nordic Notice Handler
 */

defined( 'ABSPATH' ) || exit;

define('BLUME_BEAUTY_PREMIUM_DOCUMENTATION',__('https://www.nordicwptheme.com/product/blume-pro-wordpress-theme-for-multipurpose/','blume-beauty'));
define('BLUME_BEAUTY_SUPPORT',__('https://wordpress.org/support/theme/blume-beauty/','blume-beauty'));
define('BLUME_BEAUTY_REVIEW',__('https://wordpress.org/support/theme/blume-beauty/reviews/#new-post','blume-beauty'));
define('BLUME_BEAUTY_BUY_NOW',__('https://www.nordicwptheme.com/product/blume-pro-wordpress-theme-for-multipurpose/','blume-beauty'));
define('BLUME_BEAUTY_DOC_URL',__('https://www.nordicwptheme.com/Documentation/','blume-beauty'));
define('BLUME_BEAUTY_LIVE_DEMO',__('https://nordicwptheme.se/blume/','blume-beauty'));
define('BLUME_BEAUTY_BUNDLE',__('https://www.nordicwptheme.com/product/all-premium-wordpress-themes-for-multipurpose/','blume-beauty'));
/**
 * Admin Hook
 */
function blume_beauty_admin_menu_page() {
    $blume_beauty_theme = wp_get_theme( get_template() );

    add_theme_page(
        $blume_beauty_theme->display( 'Name' ),
        $blume_beauty_theme->display( 'Name' ),
        'manage_options',
        'blume-beauty',
        'blume_beauty_do_admin_page'
    );
}
add_action( 'admin_menu', 'blume_beauty_admin_menu_page' );

/**
 * Enqueue getting started styles and scripts
 */
function nordicwp_widgets_backend_enqueue() {
    wp_enqueue_style( 'nordicwp-getting-started', get_template_directory_uri() . '/about-theme/about-theme.css' );
}
add_action( 'admin_enqueue_scripts', 'nordicwp_widgets_backend_enqueue' );

/**
 * Class Nordic_Notice_Handler
 */
class Nordic_Notice_Handler {

    public static $nonce;

    /**
     * Empty Constructor
     */
    public function __construct() {
        // Activation notice
        add_action( 'switch_theme', array( $this, 'flush_dismiss_status' ) );
        add_action( 'admin_init', array( $this, 'getting_started_notice_dismissed' ) );
        add_action( 'admin_notices', array( $this, 'nordicwp_theme_info_welcome_admin_notice' ), 3 );
        add_action( 'wp_ajax_nordicwp_getting_started', array( $this, 'nordicwp_getting_started' ) );
    }

    /**
     * Display an admin notice linking to the about page
     */
    public function nordicwp_theme_info_welcome_admin_notice() {

    $current_screen = get_current_screen();

    $blume_beauty_theme = wp_get_theme();
    if ( is_admin() && ! get_user_meta( get_current_user_id(), 'gs_notice_dismissed' ) && $current_screen->base != 'appearance_page_blume-beauty' ) {
        echo '<div class="updated notice notice-success is-dismissible getting-started">';
        echo '<p><strong>' . sprintf( esc_html__( 'Welcome! Thank you for choosing %1$s.', 'blume-beauty' ), esc_html( $blume_beauty_theme->get( 'Name' ) ) ) . '</strong></p>';
        echo '<p class="plugin-notice">' . esc_html__( 'By clicking "Get Started," you can access our theme features.', 'blume-beauty' ) . '</p>';
        echo '<div class="nordicwp-buttons">';
        echo '<p><a href="' . esc_url( BLUME_BEAUTY_BUY_NOW ) . '" class="button button-secondary" target="_blank">' . esc_html__( 'GO FOR PREMIUM', 'blume-beauty' ) . '</a></p>';
        echo '<p><a href="' . esc_url( BLUME_BEAUTY_BUNDLE ) . '" class="button button-secondary" target="_blank">' . esc_html__( 'All Themes for Just 89€! ', 'blume-beauty' ) . '</a></p>';
        echo '<p><a href="' . esc_url(admin_url('themes.php?page=blume-beauty')) . '" class="nordicwp-install-plugins button button-primary">' . sprintf( esc_html__( 'Get started with %s', 'blume-beauty' ), esc_html( $blume_beauty_theme->get( 'Name' ) ) ) . '</a></p>';

        echo '</div>';
        echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( 'gs-notice-dismissed', 'dismiss_admin_notices' ) ) ) . '" class="getting-started-notice-dismiss">Dismiss</a>';
        echo '</div>';
    }
}

    /**
     * Register dismissal of the getting started notification.
     * Acts on the dismiss link.
     * If clicked, the admin notice disappears and will no longer be visible to this user.
     */
    public function getting_started_notice_dismissed() {
        if ( isset( $_GET['gs-notice-dismissed'] ) ) {
            add_user_meta( get_current_user_id(), 'gs_notice_dismissed', 'true' );
        }
    }

    /**
     * Deletes the getting started notice's dismiss status upon theme switch.
     */
    public function flush_dismiss_status() {
        delete_user_meta( get_current_user_id(), 'gs_notice_dismissed' );
    }
}
new Nordic_Notice_Handler();

/**
 * Render admin page.
 *
 * @since 1.0.0
 */
function blume_beauty_do_admin_page() { 
    $blume_beauty_theme = wp_get_theme(); ?>
    <div class="blume-beauty-themeinfo-page--wrapper">
        <div class="free&pro">
            <div id="blume-beauty-admin-about-page-1">
                <div class="theme-detail">
                   <div class="blume-beauty-admin-card-header-1">
                    <div class="blume-beauty-header-left">
                        <h2>
                            <?php echo esc_html( $blume_beauty_theme->Name ); ?> <span><?php echo esc_html($blume_beauty_theme['Version']);?></span>
                        </h2>
                        <p>
                            <?php
                            echo wp_kses_post( apply_filters( 'nordicwp_theme_description', esc_html( $blume_beauty_theme->get( 'Description' ) ) ) );
                        ?>
                        </p>
                    </div>
                    <div class="blume-beauty-header-right">
                        <div class="blume-beauty-pro-button">
                            <a href="<?php echo esc_url( BLUME_BEAUTY_BUY_NOW ); ?>" class="blume-beauty-button button-primary" target="_blank" rel="noreferrer">
                                <?php esc_html_e( 'UPGRADE TO PREMIUM', 'blume-beauty' ); ?>
                            </a>
                        </div>
                    </div>
                </div>   
                </div>   
                <div class="blume-beauty-features">
                    <div class="blume-beauty-features-box">
                        <h3><?php esc_html_e( 'PREMIUM DEMONSTRATION', 'blume-beauty' ); ?></h3>
                        <p><?php esc_html_e( 'Effortlessly create and customize your website by arranging text, images, and other elements using the Gutenberg editor, making web design easy and accessible for all skill levels.', 'blume-beauty' ); ?></p>
                        <a href="<?php echo esc_url( BLUME_BEAUTY_LIVE_DEMO ); ?>" class="blume-beauty-button button-secondary-1" target="_blank" rel="noreferrer">
                                <?php esc_html_e( 'DEMONSTRATION', 'blume-beauty' ); ?>
                            </a>
                    </div>
                    <div class="blume-beauty-features-box">
                        <h3><?php esc_html_e( 'REVIEWS', 'blume-beauty' ); ?></h3>
                        <p><?php esc_html_e( 'We would be happy to hear your thoughts and value your evaluation.', 'blume-beauty' ); ?></p>
                        <a href="<?php echo esc_url( BLUME_BEAUTY_REVIEW ); ?>" class="blume-beauty-button button-secondary-1" target="_blank" rel="noreferrer">
                                <?php esc_html_e( 'REVIEWS', 'blume-beauty' ); ?>
                            </a>
                    </div>
                    <div class="blume-beauty-features-box">
                        <h3><?php esc_html_e( '24/7 SUPPORT', 'blume-beauty' ); ?></h3>
                        <p><?php esc_html_e( 'Please do not hesitate to contact us at support if you need help installing our lite theme. We are prepared to assist you!', 'blume-beauty' ); ?></p>
                        <a href="<?php echo esc_url( BLUME_BEAUTY_SUPPORT ); ?>" class="blume-beauty-button button-secondary-1" target="_blank" rel="noreferrer">
                            <?php esc_html_e( 'SUPPORT', 'blume-beauty' ); ?>
                        </a>
                    </div>
                    <div class="blume-beauty-features-box">
                        <h3><?php esc_html_e( 'THEME INSTRUCTION', 'blume-beauty' ); ?></h3>
                        <p><?php esc_html_e( 'If you need assistance configuring and setting up the theme, our tutorial is available. A fast and simple method for setting up the theme.', 'blume-beauty' ); ?></p>
                        <a href="<?php echo esc_url( BLUME_BEAUTY_DOC_URL ); ?>" class="blume-beauty-button button-secondary-1" target="_blank" rel="noreferrer">
                                <?php esc_html_e( 'DOCUMENTATION', 'blume-beauty' ); ?>
                            </a>
                    </div>
                </div>   
            </div>
            <div id="blume-beauty-admin-about-page-2">
                <div class="theme-detail">
                   <div class="blume-beauty-admin-card-header-1">
                        <div class="blume-beauty-header-left-pro"> 
                            <h2><?php esc_html_e( 'Upgrade to the premium version to unlock advanced features and enhanced functionality.', 'blume-beauty' ); ?></h2>
                        </div>
                        <div class="blume-beauty-header-right-2">
                            <div class="blume-beauty-pro-button">
                                <a href="<?php echo esc_url( BLUME_BEAUTY_BUY_NOW ); ?>" class="blume-beauty-button button-primary-1 buy-now" target="_blank" rel="noreferrer">
                                    <?php esc_html_e( 'GO TO PREMIUM', 'blume-beauty' ); ?>
                                </a>
                            </div>
                            <div class="blume-beauty-pro-button">
                                <a href="<?php echo esc_url( BLUME_BEAUTY_LIVE_DEMO ); ?>" class="blume-beauty-button button-primary-1 pro-demo" target="_blank" rel="noreferrer">
                                    <?php esc_html_e( 'PREMIUM DEMO', 'blume-beauty' ); ?>
                                </a>
                            </div>
                            <div class="blume-beauty-pro-button">
                                <a href="<?php echo esc_url( BLUME_BEAUTY_PREMIUM_DOCUMENTATION ); ?>" class="blume-beauty-button button-primary-1 buy-now" target="_blank" rel="noreferrer">
                                    <?php esc_html_e( 'PRO DOCUMENTATION', 'blume-beauty' ); ?>
                                </a>
                            </div>  
                        </div>
                    </div>
                    <div class="blume-beauty-admin-card-header-2">
                        <img class="img_responsive" style="width: 100%;" src="<?php echo esc_url( $blume_beauty_theme->get_screenshot() ); ?>" />
                    </div> 
                </div>    
            </div>
        </div>
    </div>
<?php } ?>