File: /home/storage/162/3480162/user/htdocs/wp-content/themes/infinity-mag/classes/admin-notice.php
<?php
if ( !class_exists('Infinity_Mag_Dashboard_Notice') ):
class Infinity_Mag_Dashboard_Notice
{
function __construct()
{
global $pagenow;
if( $this->infinity_mag_show_hide_notice() ){
if( is_multisite() ){
add_action( 'network_admin_notices',array( $this,'infinity_mag_admin_notiece' ) );
} else {
add_action( 'admin_notices',array( $this,'infinity_mag_admin_notiece' ) );
}
}
add_action( 'wp_ajax_infinity_mag_notice_dismiss', array( $this, 'infinity_mag_notice_dismiss' ) );
add_action( 'switch_theme', array( $this, 'infinity_mag_notice_clear_cache' ) );
add_action('admin_init', array( $this, 'infinity_mag_notice_remove' ),100);
}
function infinity_mag_notice_remove(){
if( isset( $_GET['page'] ) && $_GET['page'] == get_template().'-about' ){
remove_all_actions('admin_notices');
remove_all_actions('all_admin_notices');
}
}
public static function infinity_mag_show_hide_notice( $status = false ){
if( $status ){
if( (class_exists( 'Booster_Extension_Class' ) ) || get_option('twp_infinity_mag_admin_notice') ){
return false;
}else{
return true;
}
}
// Check If current Page
if ( isset( $_GET['page'] ) && $_GET['page'] == 'infinity-mag-about' ) {
return false;
}
// Hide if dismiss notice
if( get_option('twp_infinity_mag_admin_notice') ){
return false;
}
// Hide if all plugin active
if ( class_exists( 'Booster_Extension_Class' ) ) {
return false;
}
// Hide On TGMPA pages
if ( ! empty( $_GET['tgmpa-nonce'] ) ) {
return false;
}
// Hide if user can't access
if ( current_user_can( 'manage_options' ) ) {
return true;
}
}
// Define Global Value
public static function infinity_mag_admin_notiece(){ ?>
<div class="updated notice is-dismissible welcome-panel twp-infinity-mag-notice">
<h3><?php esc_html_e('Quick Setup','infinity-mag'); ?></h3>
<p><strong><?php esc_html_e('Infinity Mag is now installed and ready to use. Are you looking for a better experience to set up your site?','infinity-mag'); ?></strong></p>
<small><?php esc_html_e("We've prepared a unique onboarding process through our",'infinity-mag'); ?> <a href="<?php echo esc_url( admin_url().'themes.php?page='.get_template().'-about') ?>"><?php esc_html_e('Getting started','infinity-mag'); ?></a> <?php esc_html_e("page. It helps you get started and configure your upcoming website with ease. Let's make it shine!",'infinity-mag'); ?></small>
<p>
<a class="button button-primary twp-install-active" href="javascript:void(0)"><?php esc_html_e('Install and activate recommended plugins','infinity-mag'); ?></a>
<span class="quick-loader-wrapper"><span class="quick-loader"></span></span>
<a target="_blank" class="button button-primary" href="<?php echo esc_url( 'https://demo.themeinwp.com/infinity-mag/' ); ?>"><?php esc_html_e('View Demo','infinity-mag'); ?></a>
<a target="_blank" class="button button-primary" href="<?php echo esc_url( 'https://www.themeinwp.com/theme/infinity-mag-pro/' ); ?>"><?php esc_html_e('Upgrade to Pro','infinity-mag'); ?></a>
<a class="btn-dismiss twp-custom-setup" href="javascript:void(0)"><?php esc_html_e('Dismiss this notice.','infinity-mag'); ?></a>
</p>
</div>
<?php
}
public function infinity_mag_notice_dismiss(){
if ( isset( $_POST[ '_wpnonce' ] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ '_wpnonce' ] ) ), 'infinity_mag_ajax_nonce' ) ) {
update_option('twp_infinity_mag_admin_notice','hide');
}
die();
}
public function infinity_mag_notice_clear_cache(){
update_option('twp_infinity_mag_admin_notice','');
}
}
new Infinity_Mag_Dashboard_Notice();
endif;