<?php
/**
	Back compat functionality
	Prevents the theme from running on WordPress versions prior to 5.3, since this theme is not meant to be backward compatible beyond that and relies on many newer functions and markup changes introduced in 5.3.
	@package WordPress
	@subpackage Uikit Starter
	@since 1.0.1
*/

/**
	Special thanks to Twenty Twenty-One WordPress Theme.
	@link https://wordpress.org/themes/twentytwentyone/
	@author WordPress team
	@license http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
*/
	

/* Prepare
______________________________
*/

	// If this file is called directly,abort.
	if(!defined('WPINC')){die;}


/* Exec
______________________________
*/

	add_action('after_switch_theme','__hook_switch_theme');
	/**
		@since 1.0.1
			Display upgrade notice on theme switch.
		@return (void)
	*/
	if(function_exists('__hook_switch_theme') === FALSE) :
	function __hook_switch_theme()
	{
		add_action('admin_notices','__hook_admin_notices');

	}// Method
	endif;


	/**
		@since 1.0.1
			Adds a message for unsuccessful theme switch.
			Prints an update nag after an unsuccessful attempt to switch to the theme on WordPress versions prior to 5.3.
		@global (string) $wp_version
			WordPress version.
		@return (void)
	*/
	if(function_exists('__hook_admin_notices') === FALSE) :
	function __hook_admin_notices()
	{
		echo '<div class="error"><p>';
		printf(
			/* translators: %s: WordPress Version. */
			esc_html__('This theme requires WordPress 5.3 or newer. You are running version %s. Please upgrade.','uikit-starter'),
			esc_html($GLOBALS['wp_version'])
		);
		echo '</p></div>';

	}// Method
	endif;


	add_action('load-customize.php','__hook_load_customize');
	/**
		@since 1.0.1
			Prevents the Customizer from being loaded on WordPress versions prior to 5.3.
		@global (string) $wp_version
			WordPress version.
		@return (void)
	*/
	if(function_exists('__hook_load_customize') === FALSE) :
	function __hook_load_customize()
	{
		wp_die(sprintf(
			/* translators: %s: WordPress Version. */
			esc_html__('This theme requires WordPress 5.3 or newer. You are running version %s. Please upgrade.','uikit-starter'),
			esc_html($GLOBALS['wp_version'])
		),'',array(
			'back_link' => TRUE,
		));

	}// Method
	endif;


	add_action('template_redirect','__hook_template_redirect');
	/**
		@since 1.0.1
			Prevents the Theme Preview from being loaded on WordPress versions prior to 5.3.
		@global (string) $wp_version
			WordPress version.
		@return (void)
	*/
	if(function_exists('__hook_template_redirect') === FALSE) :
	function __hook_template_redirect()
	{
		if(isset($_GET['preview'])){
			// phpcs:ignore WordPress.Security.NonceVerification
			wp_die(sprintf(
				/* translators: %s: WordPress Version. */
				esc_html__('This theme requires WordPress 5.3 or newer. You are running version %s. Please upgrade.','uikit-starter'),
				esc_html($GLOBALS['wp_version'])
			));
		}// endif

	}// Method
	endif;
