<?php
add_action('admin_enqueue_scripts', 'faith_blog_scripts_for_admin_notice');
function faith_blog_scripts_for_admin_notice(){
    wp_enqueue_style( 'faith-blogadmin-notice-style', get_theme_file_uri('assets/css/admin.css') );
}
/**
 * Getting Started Help Notic
 **/
function faith_blog_general_admin_notice(){
?>
<div data-dismissible="disable-done-notice-forever" class="notice notice-info faith-blog-welcome-notice">
    <div class="faith-blog-notice-wrapper">
        <div class="faith-blog-notice-inner">
            <div class="notice-thumbnail-col">
              <img src="<?php echo esc_url(get_theme_file_uri('screenshot.png'));?>" alt="<?php esc_attr_e('Faith Blog Theme', 'faith-blog');?>">
            </div>
            <div class="notice-content-col">
              <h3>
               <?php esc_html_e('Thank you for installing the Faith Blog WordPress Theme.', 'faith-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.', 'faith-blog'); ?>
              </p>
              <p>
              <a class="faith-blog-btn-get-started button button-primary faith-blog-button-padding" href="#" data-name="" data-slug="">
              <?php esc_html_e( 'Install Starter Website Templates', 'faith-blog' );?></a>
              <a target="_blank" href="<?php echo esc_url('https://rswpthemes.com/rs-wp-book-showcase-wordpress-plugin/');?>" class="button button-highlight btn-doc button-primary" style="color:#fff;"><span style="margin-top:4px;margin-right:5px;"></span>
              <?php esc_html_e( ' Get RS WP Book Showcase', 'faith-blog' );?></a>
              <a target="_blank" href="<?php echo esc_url(faith_blog_utm_url('welcome_notice'));?>" class="button button-highlight upgrade-to-pro button-primary"><?php esc_html_e( 'Upgrade To Pro', 'faith-blog' );?></a>
              <a href="?faith_blog_notice_dismissed" style="text-decoration: none; float: right;">
              <?php esc_html_e( 'Dismiss Notice', 'faith-blog' );?></a>
              </p>
            </div>
        </div>
    </div>
</div>
<?php
}

if ( isset( $_GET['faith_blog_notice_dismissed'] ) ){
   update_option('faith_blog_help_notice', 'notice_faith_blog_dismissed');
   set_transient('faith_blog_welcome_notice_dismissed_time', time(), 24 * 60 * 60);
}

add_action('admin_init', function(){
    $faith_blog_help_notice = get_option('faith_blog_help_notice', '');
    if('faith_blog_notice_dismissed' === $faith_blog_help_notice) {
        $dismissed_time = get_transient('faith_blog_welcome_notice_dismissed_time');
        if (false === $dismissed_time && time() > $dismissed_time + ( 24 * 60 * 60 )) {
            delete_option('faith_blog_notice_dismissed');
            delete_transient('faith_blog_welcome_notice_dismissed_time');
            add_action('admin_notices', 'faith_blog_general_admin_notice');
        }
    }
});

$faith_blog_help_notice = get_option('faith_blog_help_notice', '');
if (($faith_blog_help_notice != 'notice_faith_blog_dismissed' || $faith_blog_help_notice === '') ){
   add_action('admin_notices', 'faith_blog_general_admin_notice');
}