<?php
/**
 * Getting Started Help Notic
 **/
function digital_marketing_blog_general_admin_notice(){
       global $pagenow;
       $theme_args      = wp_get_theme();
       $meta            = get_option( 'digital_marketing_blog_help_notice', '' );
       $name            = $theme_args->__get( 'Name' );
       $current_screen  = get_current_screen();
       if( 'themes.php' == $pagenow && !$meta ){
           if( $current_screen->id !== 'dashboard' && $current_screen->id !== 'themes' ){
               return;
           }
           if( is_network_admin() ){
               return;
           }
           if( ! current_user_can( 'manage_options' ) ){
               return;
           } ?>
           <div class="smarterthemes welcome-message notice notice-info">
               <div class="notice-wrapper">
                   <div class="notice-text">
                       <h3>
                           <?php
                           printf(
                               esc_html__( 'Thank you for installing %s Theme.', 'digital-marketing-blog' ),
                               esc_html( $name )
                           );
                           ?>
                       </h3>
                       <p><?php esc_html_e( 'You can configure theme options using the Customizer.', 'digital-marketing-blog' ); ?></p>
                       <p>
                           <a href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>" class="button button-primary" style="text-decoration: none;">
                               <?php esc_html_e( 'Customize Theme', 'digital-marketing-blog' ); ?>
                           </a>
                       </p>
                       <p class="dismiss-link"><strong><a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'digital_marketing_blog_notice_dismissed', '1' ), 'digital_marketing_blog_dismiss_notice', 'digital_marketing_blog_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss','digital-marketing-blog' ); ?></a></strong></p>
                   </div>
               </div>
            </div>
       <?php }
}

if ( isset( $_GET['digital_marketing_blog_notice_dismissed'], $_GET['digital_marketing_blog_notice_nonce'] ) ) {
    $dismissed = sanitize_text_field( wp_unslash( $_GET['digital_marketing_blog_notice_dismissed'] ) );
    $nonce     = sanitize_text_field( wp_unslash( $_GET['digital_marketing_blog_notice_nonce'] ) );
    if ( '1' === $dismissed && wp_verify_nonce( $nonce, 'digital_marketing_blog_dismiss_notice' ) && current_user_can( 'manage_options' ) ) {
        // Set notice value false.
        update_option( 'digital_marketing_blog_help_notice', 'notice_digital_marketing_blog_dismissed' );
    }
}

$digital_marketing_blog_help_notice = get_option('digital_marketing_blog_help_notice', '');

if (($digital_marketing_blog_help_notice != 'notice_digital_marketing_blog_dismissed' || $digital_marketing_blog_help_notice === '') ){
    add_action('admin_notices', 'digital_marketing_blog_general_admin_notice');
}
