<?php
/**
 * Getting Started Help Notic
 **/
function author_personal_blog_general_admin_notice(){
    $screen = get_current_screen();

    if ( $screen->id === 'appearance_page_advanced-import' || $screen->id === 'appearance_page_author-personal-blog-getting-started' ) {
        return;
    }
?>
<div data-dismissible="disable-done-notice-forever" class="author-personal-blog notice notice-success notice-info author-personal-blog-notice author-personal-blog-welcome-notice">
    <div class="author-personal-blog-notice-wrapper">
        <div class="author-personal-blog-notice-inner">
            <div class="notice-content-col">
                <h3 class="author-personal-blog-notice__title"><?php esc_html_e('Craft Your Author Website with Ease!', 'author-personal-blog'); ?></h3>
                <p class="author-personal-blog-notice__content notice-desc">
                    <?php
                    printf(
                        esc_html__('Ready to bring your author presence online? Click %s to instantly install a beautifully designed starter website, complete with sample books, blog posts, and author-specific templates—perfectly tailored for writers. This seamless process takes just a few minutes and sets up all the tools you need to showcase your work.', 'author-personal-blog'),
                        '<strong>"Setup Author Website Templates"</strong>'
                    );
                    ?>
                </p>
                <p class="author-personal-blog-notice__action">
                    <button id="setup-demo-import" class="button button-primary author-personal-blog-notice__button"><?php esc_html_e('Setup Author Website Templates', 'author-personal-blog'); ?></button>
                     <a target="_blank" href="<?php echo esc_url('https://rswpthemes.com/demo-page/?demo=author-portfolio-demo-selector');?>" class="button button-highlight upgrade-to-pro button-primary"><?php esc_html_e( 'Live Demoes', 'author-personal-blog' );?></a>

                      <a href="<?php echo esc_url(admin_url('themes.php?page=author-personal-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 Videos', 'author-personal-blog' );?></a>

                      <a target="_blank" href="<?php echo esc_url(author_personal_blog_utm_url('welcome_notice'));?>" class="button button-highlight upgrade-to-pro button-primary"><?php esc_html_e( 'Upgrade To Pro', 'author-personal-blog' );?></a>

                      <a href="?author_personal_blog_notice_dismissed" style="text-decoration: none; float: right;">
                      <?php esc_html_e( 'Dismiss Notice', 'author-personal-blog' );?></a>
                </p>
            </div>
            <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 Personal Blog Pro', 'author-personal-blog'); ?>">
            </div>
        </div>
    </div>
</div>
<?php
}

if ( isset( $_GET['author_personal_blog_notice_dismissed'] ) ){
   update_option('author_personal_blog_help_notice', 'notice_author_personal_blog_dismissed');
   set_transient('welcome_notice_dismissed_time', time(), 24 * 60 * 60);
}

add_action('admin_init', function(){
    $author_personal_blog_help_notice = get_option('author_personal_blog_help_notice', '');
    if('author_personal_blog_notice_dismissed' === $author_personal_blog_help_notice) {
        $dismissed_time = get_transient('welcome_notice_dismissed_time');
        if (false === $dismissed_time && time() > $dismissed_time + ( 24 * 60 * 60 )) {
            delete_option('author_personal_blog_notice_dismissed');
            delete_transient('welcome_notice_dismissed_time');
            add_action('admin_notices', 'author_personal_blog_general_admin_notice');
        }
    }
});

$author_personal_blog_help_notice = get_option('author_personal_blog_help_notice', '');
if (($author_personal_blog_help_notice != 'notice_author_personal_blog_dismissed' || $author_personal_blog_help_notice === '') ){
   add_action('admin_notices', 'author_personal_blog_general_admin_notice');
}
