<?php
/**
 * Getting Started Help Notic
 **/
function fitness_blog_general_admin_notice(){
?>
<div data-dismissible="disable-done-notice-forever" class="notice notice-info fitness-blog-welcome-notice">
    <div class="fitness-blog-notice-wrapper">
        <div class="fitness-blog-notice-inner">
            <div class="notice-thumbnail-col">
              <img src="<?php echo esc_url(get_theme_file_uri('assets/img/shofy.webp'));?>" alt="<?php esc_attr_e('Shofy', 'fitness-blog');?>">
            </div>
            <div class="notice-content-col">
              <h3>
               <?php esc_html_e('Thank you for installing the Fitness Blog WordPress Theme.', 'fitness-blog'); ?>
              </h3>
              <p class="notice-desc">
              <?php esc_html_e('Ready to create a stunning website? Click the Install Starter Website Templates button, and you\'ll be redirected to our demo page to get started.', 'fitness-blog'); ?>
              </p>
              <p>
              <a class="fitness-blog-btn-get-started button button-primary fitness-blog-button-padding" href="#" data-name="" data-slug="">
              <?php esc_html_e( 'Install Starter Website Templates', 'fitness-blog' );?></a>
              <a href="<?php echo esc_url('https://rswpthemes.com/rs-wp-books-showcase-wordpress-plugin/');?>" class="button button-highlight btn-doc button-primary" style="color:#fff;">
              <?php esc_html_e( 'Get Book Gallery Plugin', 'fitness-blog' );?></a>
              <a target="_blank" href="<?php echo esc_url(fitness_blog_utm_url('welcome_notice'));?>" class="button button-highlight upgrade-to-pro button-primary"><?php esc_html_e( 'Upgrade To Pro', 'fitness-blog' );?></a>
              <a href="?fitness_blog_notice_dismissed" style="text-decoration: none; float: right;">
              <?php esc_html_e( 'Dismiss Notice', 'fitness-blog' );?></a>
              </p>
            </div>
        </div>
    </div>
</div>
<?php
}

if ( isset( $_GET['fitness_blog_notice_dismissed'] ) ){
   update_option('fitness_blog_help_notice', 'notice_fitness_blog_dismissed');
   set_transient('fitness_blog_welcome_notice_dismissed_time', time(), 24 * 60 * 60);
}

add_action('admin_init', function(){
    $fitness_blog_help_notice = get_option('fitness_blog_help_notice', '');
    if('fitness_blog_notice_dismissed' === $fitness_blog_help_notice) {
        $dismissed_time = get_transient('fitness_blog_welcome_notice_dismissed_time');
        if (false === $dismissed_time && time() > $dismissed_time + ( 24 * 60 * 60 )) {
            delete_option('fitness_blog_help_notice');
            delete_transient('fitness_blog_welcome_notice_dismissed_time');
            add_action('admin_notices', 'fitness_blog_general_admin_notice');
        }
    }
});

$fitness_blog_help_notice = get_option('fitness_blog_help_notice', '');
if (($fitness_blog_help_notice != 'notice_fitness_blog_dismissed' || $fitness_blog_help_notice === '') ){
   add_action('admin_notices', 'fitness_blog_general_admin_notice');
}