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

	class alhena_lite_admin_notice {

		/**
		 * Constructor
		 */

		public function __construct( $fields = array() ) {

			if (
				!get_option( 'alhena-lite-hide-notice') &&
				version_compare( PHP_VERSION, ALHENA_LITE_MIN_PHP_VERSION, '>=' )
			) {

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

			}

		}

		/**
		 * Dismiss notice.
		 */

		public function dismiss() {

			if ( isset( $_GET['alhena-lite-dismiss'] ) && check_admin_referer( 'alhena-lite-dismiss-action' ) ) {

				update_option( 'alhena-lite-hide-notice', intval($_GET['alhena-lite-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 Alhena theme like...', 'alhena-lite' );  ?>

                    </strong>
                
                </p>

                <p class="notice-coupon-message">
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( '600+ Google Fonts', 'alhena-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Custom colors', 'alhena-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Portfolio section', 'alhena-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Unlimited sidebar areas', 'alhena-lite' ); ?><br/>
					<span class="dashicon dashicons dashicons-yes-alt" size="10"></span><?php esc_html_e( 'Lifetime updates', 'alhena-lite' ); ?><br/>
                </p>

            	<p>
					
					<strong><?php esc_html_e( 'Pay what you want for the premium version of Alhena and receive 10 additional WordPress products as a bonus. (Minimum price allowed: €5)', 'alhena-lite' ); ?></strong>

                </p>

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

                    <a target="_blank" href="<?php echo esc_url( 'https://www.themeinprogress.com/alhena-free-responsive-corporate-wordpress-theme/?ref=2&campaign=alhena-notice' ); ?>" class="button button-primary"><?php esc_html_e( 'Buy now', 'alhena-lite' ); ?></a>

            	</p>

            	<p>

            		<strong>

						<?php

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

                        ?>

                    </strong>

            	</p>

            </div>

		<?php

		}

	}

}

new alhena_lite_admin_notice();

?>
