<?php
/**
 * Getting Started Help Notic
 **/
function author_website_templates_general_admin_notice(){
?>
<div data-dismissible="disable-done-notice-forever" class="notice notice-info author-website-templates-welcome-notice">
    <div class="author-website-templates-notice-wrapper">
        <div class="author-website-templates-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', 'author-website-templates');?>">
            </div>
            <div class="notice-content-col">
              <h3>
               <?php esc_html_e('Thank you for installing the Book Author Template WordPress Theme.', 'author-website-templates'); ?>
              </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.', 'author-website-templates'); ?>
              </p>
              <p>
              <a class="author-website-templates-btn-get-started button button-primary author-website-templates-button-padding" href="#" data-name="" data-slug="">
                <?php esc_html_e( 'Install Starter Author Website Templates', 'author-website-templates' );?>
              </a>
              <a target="_blank" href="<?php echo esc_url('https://rswpthemes.com/documentations/');?>" 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( ' Video Documentation', 'author-website-templates' );?>
            </a>
            <a target="_blank" href="<?php echo esc_url(author_website_templates_utm_url('welcome_notice'));?>" class="button button-highlight upgrade-to-pro button-primary">
                <?php esc_html_e( 'Upgrade To Pro', 'author-website-templates' );?>
            </a>
            <a href="?author_website_templates_notice_dismissed" style="text-decoration: none; float: right;">
              <?php esc_html_e( 'Dismiss Notice', 'author-website-templates' );?>
            </a>
            </p>
            </div>
        </div>
    </div>
</div>
<?php
}

if ( isset( $_GET['author_website_templates_notice_dismissed'] ) ){
   update_option('author_website_templates_help_notice', 'notice_author_website_templates_dismissed');
   set_transient('author_website_templates_welcome_notice_dismissed_time', time(), 2 * 60 * 60);
}

add_action('admin_init', function(){
    $author_website_templates_help_notice = get_option('author_website_templates_help_notice', '');
    if('notice_author_website_templates_dismissed' === $author_website_templates_help_notice) {
        $dismissed_time = get_transient('author_website_templates_welcome_notice_dismissed_time');
        if (false === $dismissed_time || time() > $dismissed_time + ( 2 * 60 * 60 )) {
            delete_option('author_website_templates_notice_dismissed');
            delete_transient('author_website_templates_welcome_notice_dismissed_time');
            add_action('admin_notices', 'author_website_templates_general_admin_notice');
        }
    }
});

$author_website_templates_help_notice = get_option('author_website_templates_help_notice', '');
if (($author_website_templates_help_notice != 'notice_author_website_templates_dismissed' || $author_website_templates_help_notice === '') ){
   add_action('admin_notices', 'author_website_templates_general_admin_notice');
}