<?php

/**
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
} // Exit if accessed directly

if( !class_exists( 'urbamag_admin_notice' ) ) {

	class urbamag_admin_notice {
	
		/**
		 * Constructor
		 */
		 
		public function __construct( $fields = array() ) {

			if ( 
				!get_option( 'urbamag-dismissed-admin-notice') &&
				version_compare( PHP_VERSION, URBAMAG_MIN_PHP_VERSION, '>=' )
			) {

				add_action( 'admin_notices', array(&$this, 'admin_notice') );
				add_action( 'admin_head', array( $this, 'dismiss' ) );
				add_action( 'admin_init', array(&$this, 'add_script') ,11);

            }

		}
        
		 /**
		 * Loads the notice style
		 */

		public function add_script() {

			global $wp_version;

			$file_dir = get_template_directory_uri() . '/core/admin/assets/';
			wp_enqueue_style ( 'urbamag-notice', $file_dir.'css/notice.css' );

		}
        
        
        /**
		 * Dismiss notice.
		 */
		
		public function dismiss() {

			if ( isset( $_GET['urbamag-dismiss'] ) && check_admin_referer( 'urbamag-dismiss-action' ) ) {
		
				update_option( 'urbamag-dismissed-admin-notice', intval($_GET['urbamag-dismiss']) );
				remove_action( 'admin_notices', array(&$this, 'admin_notice') );
				
			} 
		
		}

		/**
		 * Admin notice.
		 */
		 
		public function admin_notice() {
			
		?>
			
            <div class="notice notice-warning is-dismissible">
                
            	<p>
            
            		<strong>

						<?php esc_html_e( 'Unlock all premium features of Urbamag theme like...', 'urbamag' );  ?>

                    </strong>
                
                </p>
                
                <p class="notice-coupon-message">

					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '600+ Google Fonts', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Custom colors', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '15 additional social sharing icons (such as WhatsApp, Twitch, Yelp, email, Skype, or LinkedIn)', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '6 additional social buttons', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Unlimited widget areas', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Portfolio section', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Global layout option', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Global widget area option', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '"PostBlocks" widget', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Additional widget area above the "postBlocks" section on homepage', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '6 additional "postBlocks" modules', 'urbamag' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '2 additional "postBlocks" layouts', 'urbamag' ); ?><br/>
                
                </p>

            	<p>
					<strong>
						<?php esc_html_e( 'Get the premium version of Urbamag or choose the Plus plan to use Urbamag as a starter theme for your website', 'urbamag' ); ?>
					</strong><br/>
					<strong><?php esc_html_e( 'You can also select a bundle of 19 WordPress themes', 'urbamag' ); ?></strong>
                </p>

				<p>

					<a href="<?php echo esc_url(admin_url( 'themes.php?page=urbamag-welcome-page&section=free_pro' )); ?>" class="button"><?php esc_html_e( 'Free vs Pro', 'urbamag' ); ?></a>

					<a target="_blank" href="<?php echo esc_url( 'https://www.themeinprogress.com/urbamag-news-magazine-wordpress-theme/?ref=2&campaign=urbamag-notice' ); ?>" class="button button-primary"><?php esc_html_e( 'Urbamag Pro', 'urbamag' ); ?></a>
					
					<a target="_blank" href="<?php echo esc_url( 'https://www.themeinprogress.com/wordpress-themes-bundle/?ref=2&campaign=urbamag-notice' ); ?>" class="button button-primary"><?php esc_html_e( 'Bundle of 19 WordPress themes', 'urbamag' ); ?></a>
					
					<span class="notice-arrow" style="">&#x2938;</span>

            	</p>

            	<p>

                    <?php

                        printf( 
                            '<a href="%1$s" class="dismiss-notice">' . esc_html__( 'Dismiss this notice', 'urbamag' ) . '</a>', 
                            esc_url( wp_nonce_url( add_query_arg( 'urbamag-dismiss', '1' ), 'urbamag-dismiss-action'))
                        );

                    ?>
                    
            	</p>
                    
            </div>
		
		<?php
		
		}

	}

}

new urbamag_admin_notice();

?>