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

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

			if ( 
				!get_option( 'avventura-lite-membership-notice') &&
				version_compare( PHP_VERSION, AVVENTURA_LITE_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 ( 'avventura-lite-notice', $file_dir.'css/notice.css' );

		}


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

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

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

						<?php esc_html_e( 'Unlock all premium features of Avventura', 'avventura-lite' );  ?>

                    </strong>
                
                </p>

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

					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '[NEW] Optional table of contents', 'avventura-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '[NEW] Optional reading time', 'avventura-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '[NEW] Optional reading progress bar', 'avventura-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '600+ Google Fonts', 'avventura-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Custom colors', 'avventura-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Unlimited widget areas', 'avventura-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Portfolio section', 'avventura-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '20 additional child themes', 'avventura-lite' ); ?><br/>
                
                </p>

				<p>
					<?php
					printf(
						wp_kses_post(
							__( 'Avventura is now available through the <strong>%s</strong>, with access to all 19 premium WordPress themes via a single, one-time payment.', 'avventura-lite' )
						),
						esc_html__( 'Themes Membership', 'avventura-lite' )
					);
					?>
				</p>

            	<p>
					<a href="<?php echo esc_url(admin_url( 'themes.php?page=avventura-lite-welcome-page&section=free_pro' )); ?>" class="button"><?php esc_html_e( 'Free vs Pro', 'avventura-lite' ); ?></a>
                    	
					<a target="_blank" href="<?php echo esc_url( 'https://www.themeinprogress.com/avventura-elegant-beauty-wordpress-shop-theme/?ref=2&campaign=avventura-notice' ); ?>" class="button button-primary"><?php esc_html_e( 'Get access - from €15.99', 'avventura-lite' ); ?></a>

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

            	</p>

                <p>
                    
                    <?php

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

                    ?>
                    
            	</p>
                    

            </div>
		
		<?php
		
		}

	}

}

new avventura_lite_admin_notice();

?>