<?php
/**
 * Getting Started Help Notic
 **/
function book_author_blog_general_admin_notice(){
?>
<div data-dismissible="disable-done-notice-forever" class="notice notice-info book-author-blog-welcome-notice">
    <div class="book-author-blog-notice-wrapper">
        <div class="book-author-blog-notice-inner">
            <div class="notice-thumbnail-col">
              <img src="<?php echo esc_url(get_theme_file_uri('assets/img/author-portfolio-pro-thumb.png'));?>" alt="<?php esc_attr_e('Author Portfolio Pro', 'book-author-blog');?>">
            </div>
            <div class="notice-content-col">
              <h3>
               <?php esc_html_e('Thank you for installing the Book Author Blog WordPress Theme.', 'book-author-blog'); ?>
              </h3>
              <p class="notice-desc">
              <?php esc_html_e('Ready to create a stunning author website? Click the Install Starter Author Website Templates button, and you\'ll be redirected to our demo page to get started.', 'book-author-blog'); ?>
              </p>
              <p>
              <a class="book-author-blog-btn-get-started button button-primary book-author-blog-button-padding" href="#" data-name="" data-slug="">
              <?php esc_html_e( 'Install Starter Author Website Templates', 'book-author-blog' );?></a>
              <a href="<?php echo esc_url(admin_url( 'themes.php?page=book-author-blog-getting-started' ));?>" class="button button-highlight btn-doc button-primary" style="color:#fff;"><span style="margin-top:4px;margin-right:5px;" class="dashicons dashicons-video-alt3"></span>
              <?php esc_html_e( ' Getting Started Video', 'book-author-blog' );?></a>
              <a target="_blank" href="<?php echo esc_url(book_author_blog_utm_url('welcome_notice'));?>" class="button button-highlight upgrade-to-pro button-primary"><?php esc_html_e( 'Upgrade To Pro', 'book-author-blog' );?></a>
              <a href="?book_author_blog_notice_dismissed" style="text-decoration: none; float: right;">
              <?php esc_html_e( 'Dismiss Notice', 'book-author-blog' );?></a>
              </p>
            </div>
        </div>
    </div>
</div>
<?php
}

if ( isset( $_GET['book_author_blog_notice_dismissed'] ) ){
   update_option('book_author_blog_help_notice', 'notice_book_author_blog_dismissed');
   set_transient('book_author_blog_welcome_notice_dismissed_time', time(), 24 * 60 * 60);
}

add_action('admin_init', function(){
    $book_author_blog_help_notice = get_option('book_author_blog_help_notice', '');
    if('book_author_blog_notice_dismissed' === $book_author_blog_help_notice) {
        $dismissed_time = get_transient('book_author_blog_welcome_notice_dismissed_time');
        if (false === $dismissed_time && time() > $dismissed_time + ( 24 * 60 * 60 )) {
            delete_option('book_author_blog_help_notice');
            delete_transient('book_author_blog_welcome_notice_dismissed_time');
            add_action('admin_notices', 'book_author_blog_general_admin_notice');
        }
    }
});

$book_author_blog_help_notice = get_option('book_author_blog_help_notice', '');
if (($book_author_blog_help_notice != 'notice_book_author_blog_dismissed' || $book_author_blog_help_notice === '')){
   add_action('admin_notices', 'book_author_blog_general_admin_notice');
}