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

	class jass_admin_notice {

		/**
		 * Constructor
		 */

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

			if (
				!get_option( 'jass-hide-notice') &&
				version_compare( PHP_VERSION, JASS_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['jass-dismiss'] ) && check_admin_referer( 'jass-dismiss-action' ) ) {

				update_option( 'jass-hide-notice', intval($_GET['jass-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( 'Pay what you want to get a lifetime subscription for 10 WordPress themes and 1 WordPress plugin on ThemeinProgress.com.', 'jass' ); 

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

                        ?>

                    </strong>

            	</p>

            	<p>

                    <a target="_blank" href="<?php echo esc_url( 'https://www.themeinprogress.com/name-your-price-wordpress-bundle/?ref=2&campaign=jass-notice' ); ?>" class="button button-primary"><?php esc_html_e( 'Buy now', 'jass' ); ?></a>

            	</p>

            </div>

		<?php

		}

	}

}

new jass_admin_notice();

?>
