<?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( 'minimalista_base_admin_notice' ) ) {

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

			if ( 
				!get_option( 'minimalista-base-dismissed-membership-notice') &&
				version_compare( PHP_VERSION, MINIMALISTA_BASE_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 ( 'minimalista-base-notice', $file_dir.'css/notice.css' );

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

			if ( isset( $_GET['minimalista-base-dismiss'] ) && check_admin_referer( 'minimalista-base-dismiss-action' ) ) {
		
				update_option( 'minimalista-base-dismissed-membership-notice', intval($_GET['minimalista-base-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 Minimalista theme', 'minimalista-base' );  ?>

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

					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '600+ Google Fonts', 'minimalista-base' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Custom colors', 'minimalista-base' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Portfolio section', 'minimalista-base' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Custom shortcodes', 'minimalista-base' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Remove theme credits from the footer', 'minimalista-base' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Unlimited widget areas', 'minimalista-base' ); ?><br/>
                
                </p>

				<p>

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

					<a target="_blank" href="<?php echo esc_url( 'https://www.themeinprogress.com/minimalista-sleek-and-minimalist-wordpress-theme/?ref=2&campaign=minimalista-base-notice' ); ?>" class="button button-primary"><?php esc_html_e( 'Buy now', 'minimalista-base' ); ?></a>

					<span class="notice-arrow" style="">&#x2938;</span>

            	</p>

            	<p>

                    <?php

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

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

	}

}

new minimalista_base_admin_notice();

?>