<?php
/**
 * Builds our admin page.
 *
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

if ( ! function_exists( 'gayatri_create_menu' ) ) {
	add_action( 'admin_menu', 'gayatri_create_menu' );
	/**
	 * Adds our "Gayatri" dashboard menu item
	 *
	 */
	function gayatri_create_menu() {
		$theme_name = wp_get_theme();
		$gayatri_page = add_theme_page( esc_html( $theme_name ), esc_html( $theme_name ), apply_filters( 'gayatri_dashboard_page_capability', 'edit_theme_options' ), 'gayatri-options', 'gayatri_settings_page' );
		add_action( "admin_print_styles-$gayatri_page", 'gayatri_options_styles' );
	}
}

if ( ! function_exists( 'gayatri_options_styles' ) ) {
	/**
	 * Adds any necessary scripts to the Gayatri dashboard page
	 *
	 */
	function gayatri_options_styles() {
		wp_enqueue_style( 'gayatri-options', get_template_directory_uri() . '/css/admin/admin-style.css', array(), GAYATRI_VERSION );
	}
}

// Disable admin notices on the specific page
if ( ! function_exists( 'gayatri_disable_admin_notices' ) ) {

	add_action( 'admin_head', 'gayatri_disable_admin_notices' );
	function gayatri_disable_admin_notices() {
		$current_screen = get_current_screen();
		// Check if we are on the Gayatri admin page
		if ( isset( $current_screen->id ) && $current_screen->id === 'appearance_page_gayatri-options' ) {
			remove_all_actions( 'admin_notices' );
        	remove_all_actions( 'all_admin_notices' );
		}
	}
}

if ( ! function_exists( 'gayatri_settings_page_sidebar' ) ) {
	function gayatri_settings_page_sidebar( $gayatri_activator ) {
		
		if ( $gayatri_activator == 'activate' ) {
			do_action( 'gayatri_admin_right_panel' );
		}
		
		if ( ! defined( 'GAYATRI_PREMIUM_VERSION' ) ) :
	?>
<div class="wpkoi-upgrade gayatri-sidebar-element gayatri-sc">
	<h3><?php esc_html_e( 'Need more features?', 'gayatri' ); ?></h3>
	<p><?php esc_html_e( 'Unlock the full potential of your site! Enjoy advanced functionality and design options that elevate your website to the next level.', 'gayatri' ); ?></p>
	<a href="<?php echo esc_url(gayatri_new_theme_uri_link()); ?>" class="wpkoi-admin-button" target="_blank"><?php esc_html_e( 'Upgrade to Premium', 'gayatri' ); ?></a>
</div>
	<?php endif; ?>
<div class="wpkoi-review gayatri-sidebar-element gayatri-sc">
	<h3><?php esc_html_e( 'Support Us with Your Review', 'gayatri' ); ?></h3>
	<p><?php esc_html_e( 'Love the Gayatri theme? Share your experience with the world! Your review helps others discover and enjoy the theme, and we truly appreciate your feedback.', 'gayatri' ); ?></p>
	<a href="<?php echo esc_url(GAYATRI_WORDPRESS_REVIEW); ?>" class="wpkoi-admin-button" target="_blank"><?php esc_html_e( 'Add my review', 'gayatri' ); ?></a>
</div>

<div class="wpkoi-social gayatri-sidebar-element gayatri-sc">
	<h3><?php esc_html_e( 'Stay Updated with WPKoi on Facebook', 'gayatri' ); ?></h3>
	<p><?php esc_html_e( 'Want the latest tips, news, and updates on WPKoi products? Follow us on Facebook for exclusive content and useful insights that help you make the most of your themes.', 'gayatri' ); ?></p>
	<a href="<?php echo esc_url(GAYATRI_WPKOI_SOCIAL_URL); ?>" class="wpkoi-admin-button" target="_blank"><?php esc_html_e( 'Go to Facebook', 'gayatri' ); ?></a>
</div>
	<?php
	}
}

if ( ! function_exists( 'gayatri_settings_page' ) ) {
	// Builds the content of our Gayatri dashboard page
	function gayatri_settings_page() {
		$theme_name = wp_get_theme();
		$premiumclass = '';
		if ( defined( 'GAYATRI_PREMIUM_VERSION' ) ) {
			$premiumclass = ' premium-wrap';
		}
		?>
<div class="wrap<?php echo esc_attr( $premiumclass ); ?>">
	<header id="gayatri-new-header">
		<div class="gayatri-pagelogo"><a href="<?php echo esc_url(gayatri_new_theme_uri_link()); ?>" target="_blank"><h1><?php echo esc_html( $theme_name ); ?><br><span><?php esc_html_e( 'WPKoi Theme', 'gayatri' ); ?></span></h1></a></div>
		<button class="nav-btn" data-target="gayatri-page-features">Features</button>
		<a href="<?php echo esc_url(GAYATRI_DOCUMENTATION); ?>" target="_blank" class="gayatri-new-header-p"><?php esc_html_e( 'Documentation', 'gayatri' ); ?></a>
		<div class="gayatri-page-rm">
			<div class="gayatri-page-social">
				<a target="_blank" href="<?php echo esc_url(GAYATRI_WPKOI_WPORG_URL); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M61.7 169.4l101.5 278C92.2 413 43.3 340.2 43.3 256c0-30.9 6.6-60.1 18.4-86.6zm337.9 75.9c0-26.3-9.4-44.5-17.5-58.7-10.8-17.5-20.9-32.4-20.9-49.9 0-19.6 14.8-37.8 35.7-37.8.9 0 1.8.1 2.8.2-37.9-34.7-88.3-55.9-143.7-55.9-74.3 0-139.7 38.1-177.8 95.9 5 .2 9.7.3 13.7.3 22.2 0 56.7-2.7 56.7-2.7 11.5-.7 12.8 16.2 1.4 17.5 0 0-11.5 1.3-24.3 2l77.5 230.4L249.8 247l-33.1-90.8c-11.5-.7-22.3-2-22.3-2-11.5-.7-10.1-18.2 1.3-17.5 0 0 35.1 2.7 56 2.7 22.2 0 56.7-2.7 56.7-2.7 11.5-.7 12.8 16.2 1.4 17.5 0 0-11.5 1.3-24.3 2l76.9 228.7 21.2-70.9c9-29.4 16-50.5 16-68.7zm-139.9 29.3l-63.8 185.5c19.1 5.6 39.2 8.7 60.1 8.7 24.8 0 48.5-4.3 70.6-12.1-.6-.9-1.1-1.9-1.5-2.9l-65.4-179.2zm183-120.7c.9 6.8 1.4 14 1.4 21.9 0 21.6-4 45.8-16.2 76.2l-65 187.9C426.2 403 468.7 334.5 468.7 256c0-37-9.4-71.8-26-102.1zM504 256c0 136.8-111.3 248-248 248C119.2 504 8 392.7 8 256 8 119.2 119.2 8 256 8c136.7 0 248 111.2 248 248zm-11.4 0c0-130.5-106.2-236.6-236.6-236.6C125.5 19.4 19.4 125.5 19.4 256S125.6 492.6 256 492.6c130.5 0 236.6-106.1 236.6-236.6z"></path></svg></a>
				<a target="_blank" href="<?php echo esc_url(GAYATRI_WPKOI_SOCIAL_URL); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M400 32H48A48 48 0 0 0 0 80v352a48 48 0 0 0 48 48h137.25V327.69h-63V256h63v-54.64c0-62.15 37-96.48 93.67-96.48 27.14 0 55.52 4.84 55.52 4.84v61h-31.27c-30.81 0-40.42 19.12-40.42 38.73V256h68.78l-11 71.69h-57.78V480H400a48 48 0 0 0 48-48V80a48 48 0 0 0-48-48z"></path></svg></a>
				<a target="_blank" href="<?php echo esc_url(GAYATRI_WPKOI_INSTAGRAM_URL); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M224.3 141a115 115 0 1 0 -.6 230 115 115 0 1 0 .6-230zm-.6 40.4a74.6 74.6 0 1 1 .6 149.2 74.6 74.6 0 1 1 -.6-149.2zm93.4-45.1a26.8 26.8 0 1 1 53.6 0 26.8 26.8 0 1 1 -53.6 0zm129.7 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM399 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"/></svg></a>
				<a target="_blank" href="<?php echo esc_url(GAYATRI_WPKOI_YOUTUBE_URL); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M549.7 124.1C543.5 100.4 524.9 81.8 501.4 75.5 458.9 64 288.1 64 288.1 64S117.3 64 74.7 75.5C51.2 81.8 32.7 100.4 26.4 124.1 15 167 15 256.4 15 256.4s0 89.4 11.4 132.3c6.3 23.6 24.8 41.5 48.3 47.8 42.6 11.5 213.4 11.5 213.4 11.5s170.8 0 213.4-11.5c23.5-6.3 42-24.2 48.3-47.8 11.4-42.9 11.4-132.3 11.4-132.3s0-89.4-11.4-132.3zM232.2 337.6l0-162.4 142.7 81.2-142.7 81.2z"/></svg></a>
				<a target="_blank" href="<?php echo esc_url(GAYATRI_WPKOI_TIKTOK_URL); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M448.5 209.9c-44 .1-87-13.6-122.8-39.2l0 178.7c0 33.1-10.1 65.4-29 92.6s-45.6 48-76.6 59.6-64.8 13.5-96.9 5.3-60.9-25.9-82.7-50.8-35.3-56-39-88.9 2.9-66.1 18.6-95.2 40-52.7 69.6-67.7 62.9-20.5 95.7-16l0 89.9c-15-4.7-31.1-4.6-46 .4s-27.9 14.6-37 27.3-14 28.1-13.9 43.9 5.2 31 14.5 43.7 22.4 22.1 37.4 26.9 31.1 4.8 46-.1 28-14.4 37.2-27.1 14.2-28.1 14.2-43.8l0-349.4 88 0c-.1 7.4 .6 14.9 1.9 22.2 3.1 16.3 9.4 31.9 18.7 45.7s21.3 25.6 35.2 34.6c19.9 13.1 43.2 20.1 67 20.1l0 87.4z"/></svg></a>
				<a target="_blank" href="<?php echo esc_url(GAYATRI_WPKOI_DRIBBLE_URL); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 8C119.252 8 8 119.252 8 256s111.252 248 248 248 248-111.252 248-248S392.748 8 256 8zm163.97 114.366c29.503 36.046 47.369 81.957 47.835 131.955-6.984-1.477-77.018-15.682-147.502-6.818-5.752-14.041-11.181-26.393-18.617-41.614 78.321-31.977 113.818-77.482 118.284-83.523zM396.421 97.87c-3.81 5.427-35.697 48.286-111.021 76.519-34.712-63.776-73.185-116.168-79.04-124.008 67.176-16.193 137.966 1.27 190.061 47.489zm-230.48-33.25c5.585 7.659 43.438 60.116 78.537 122.509-99.087 26.313-186.36 25.934-195.834 25.809C62.38 147.205 106.678 92.573 165.941 64.62zM44.17 256.323c0-2.166.043-4.322.108-6.473 9.268.19 111.92 1.513 217.706-30.146 6.064 11.868 11.857 23.915 17.174 35.949-76.599 21.575-146.194 83.527-180.531 142.306C64.794 360.405 44.17 310.73 44.17 256.323zm81.807 167.113c22.127-45.233 82.178-103.622 167.579-132.756 29.74 77.283 42.039 142.053 45.189 160.638-68.112 29.013-150.015 21.053-212.768-27.882zm248.38 8.489c-2.171-12.886-13.446-74.897-41.152-151.033 66.38-10.626 124.7 6.768 131.947 9.055-9.442 58.941-43.273 109.844-90.795 141.978z"></path></svg></a>
				<a target="_blank" href="<?php echo esc_url(GAYATRI_WPKOI_BEHANCE_URL); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M232 237.2c31.8-15.2 48.4-38.2 48.4-74 0-70.6-52.6-87.8-113.3-87.8H0v354.4h171.8c64.4 0 124.9-30.9 124.9-102.9 0-44.5-21.1-77.4-64.7-89.7zM77.9 135.9H151c28.1 0 53.4 7.9 53.4 40.5 0 30.1-19.7 42.2-47.5 42.2h-79v-82.7zm83.3 233.7H77.9V272h84.9c34.3 0 56 14.3 56 50.6 0 35.8-25.9 47-57.6 47zm358.5-240.7H376V94h143.7v34.9zM576 305.2c0-75.9-44.4-139.2-124.9-139.2-78.2 0-131.3 58.8-131.3 135.8 0 79.9 50.3 134.7 131.3 134.7 61.3 0 101-27.6 120.1-86.3H509c-6.7 21.9-34.3 33.5-55.7 33.5-41.3 0-63-24.2-63-65.3h185.1c.3-4.2.6-8.7.6-13.2zM390.4 274c2.3-33.7 24.7-54.8 58.5-54.8 35.4 0 53.2 20.8 56.2 54.8H390.4z"></path></svg></a>
			</div>
			<?php if ( ! defined( 'GAYATRI_PREMIUM_VERSION' ) ) : ?>
			<div class="gayatri-page-more"><a href="<?php echo esc_url(gayatri_new_theme_uri_link()); ?>" target="_blank"><h3><?php esc_html_e( 'Get premium', 'gayatri' ); ?></h3></a></div>
			<?php endif; ?>
		</div>
	</header>
	<?php
	 do_action( 'gayatri_dashboard_after_header' );
	 ?>
	<div id="gayatri-page-body">
		<div id="gayatri-page-features" style="display: block;">
			<div class="gayatri-element-col-flex">
				
				<div class="wpkoi-disable-elements gayatri-element-col-1">
					<div class="gayatri-sidebar-element">
						<div class="gayatri-element-col-50">
							<h3><?php esc_html_e( 'Welcome to Your', 'gayatri' ); ?> <?php echo esc_html( $theme_name ); ?> <?php esc_html_e( 'Dashboard!', 'gayatri' ); ?></h3>
							<p class="gayatri-de-p"><?php esc_html_e( 'Get the most out of your WPKoi theme! Here, you’ll find everything you need to elevate your website—whether you’re using the free version or exploring premium features. Quickly access the customizer, or watch short video tutorials that represents the premium features. Building your dream site has never been easier!', 'gayatri' ); ?></p>
							<div class="customize-button">
								<?php
								printf( '<a id="gayatri_customize_button" class="button button-primary" href="%1$s">%2$s</a>',
									esc_url( admin_url( 'customize.php' ) ),
									esc_html__( 'Customize', 'gayatri' )
								);
								?>
							</div>
						</div>
						
						<?php 
						do_action( 'gayatri_dashboard_inside_container' ); 
						do_action( 'gayatri_new_inside_options_form' );
						?>
						
						<div class="gayatri-qe">
							<h3><?php esc_html_e( 'Quick Access to Customize and Build Your Site', 'gayatri' ); ?></h3>
							<p><?php esc_html_e( 'Navigate your site effortlessly with these handy shortcuts. Edit your site’s identity, tweak colors, and refine your top bar in just a few clicks. Quickly access the widget builders to ensure every part of your site aligns with your vision. Everything you need to customize and build your site is right at your fingertips!', 'gayatri' ); ?></p>
							<?php
							$quicklinks = array(
								'Site Identity' => array( 'url' => admin_url( 'customize.php' ), 'button' => esc_html( 'Customize', 'gayatri' ) ),
								'General' => array( 'url' => admin_url( 'customize.php' ), 'button' => esc_html( 'Customize', 'gayatri' ) ),
								'Widgets' => array( 'url' => admin_url( 'widgets.php' ), 'button' => esc_html( 'Build', 'gayatri' ) ),
							);
							?>
							<div class="gayatri-de-h gayatri-qe-h">	
								<?php foreach( $quicklinks as $quicklink => $info ) { ?>
								<div class="gayatri-de-e">
									<a href="<?php echo $info[ 'url' ] ; ?>" target="_blank" class="gayatri-switch-link">
										<div class="gayatri-de-e-premium-i">
											<p><?php echo esc_html( $quicklink ); ?></p>
											<div class="gayatri-de-d">

												<div class="gayatri-de-di"><h4><?php echo esc_html( $info[ 'button' ] ); ?></h4></div>
											</div>
										</div>
									</a>
								</div>
								<?php } ?>
							</div>
						</div>
						
						<?php if ( ! defined( 'GAYATRI_PREMIUM_VERSION' ) ) : ?>
						<h3><?php esc_html_e( 'Unlock Premium Modules with Gayatri Premium', 'gayatri' ); ?></h3>
						<p><?php esc_html_e( 'Take your website to the next level with these exclusive premium features. From advanced color and typography options to extra Elementor elements, you’ll have the tools to create a truly unique site. Simplify setup with one-click demo imports, customize your footer, and enhance performance by disabling unused elements. With the premium modules, you’re in full control of every detail!', 'gayatri' ); ?> <strong><?php esc_html_e( 'Gayatri Premium works with ', 'gayatri' ); ?> <?php echo esc_html( $theme_name ); ?> <?php esc_html_e( ' WPKoi theme on unlimited websites!', 'gayatri' ); ?></strong></p>
						
						<?php
						$modules = array(
							'Demo Import' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Simplify website setup with one-click, full-demo imports.', 'gayatri' ) ),
							'Colors' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Choose from a spectrum of colors to create a unique and captivating visual identity.', 'gayatri' ) ),
							'Typography' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Choose the perfect fonts for your website to create a unique and professional look.', 'gayatri' ) ),
							'Copyright Footer' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Customize your site&#39;s copyright footer with ease.', 'gayatri' ) ),
							'Elementor Addon' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Enhance your design options with additional Elementor elements for a unique touch.', 'gayatri' ) ),
							'Disable Elements' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Turn off the modules that You don&#39;t use for better performance.', 'gayatri' ) ),
							'Hooks' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Fine-tune your website with code filter inputs for added customization and codes.', 'gayatri' ) ),
							'Spacing' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Easily control the padding and margin of the elements on your website.', 'gayatri' ) ),
							'Button Functions' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Customize the style of Your buttons to make them unique.', 'gayatri' ) ),
							'Fixed Side Content Functions' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Define the size of Your Fixed Side panel for better design.', 'gayatri' ) ),
							'Backgrounds' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Add custom background images to various elements for a personalized design.', 'gayatri' ) ),
							'Blog' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Access advanced blog settings to enhance your site’s blogging functionality.', 'gayatri' ) ),
							'Menu Plus' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Unlock additional settings to further customize your website’s menus.', 'gayatri' ) ),
							'Secondary Nav' => array( 'url' => gayatri_new_theme_uri_link(), 'desc' => esc_html( 'Add and manage an extra menu for improved site navigation.', 'gayatri' ) )
						);
						?>
						
						<div class="gayatri-de-h">	
							<?php foreach( $modules as $module => $info ) { ?>
							<div class="gayatri-de-e gayatri-de-e-premium">
								<a href="<?php echo esc_url( $info[ 'url' ] ); ?>" target="_blank" class="gayatri-switch-link">
									<div class="gayatri-de-e-premium-i">
										<label class="switch">
											<span class="slider"></span>
										</label>
										<p><?php echo esc_html( $module ); ?></p>
										<p class="gayatri-de-desc"><?php echo esc_html( $info[ 'desc' ] ); ?></p>
										<div class="gayatri-de-d">
											<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4C142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32zM144 256a144 144 0 1 1 288 0 144 144 0 1 1 -288 0zm144-64c0 35.3-28.7 64-64 64c-7.1 0-13.9-1.2-20.3-3.3c-5.5-1.8-11.9 1.6-11.7 7.4c.3 6.9 1.3 13.8 3.2 20.7c13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3z"></path></svg>
											<div class="gayatri-de-di"><h4><?php esc_html_e( 'Premium', 'gayatri' ); ?></h4></div>
										</div>
									</div>
								</a>
							</div>
							<?php } ?>
						</div>
							
						<div class="customize-button">
							<?php
							printf( '<a id="gayatri_customize_button" class="button button-primary" href="%1$s" target="_blank">%2$s</a>',
								esc_url( GAYATRI_SHOWCASE ),
								esc_html__( 'Check a premium showcase', 'gayatri' )
							);
							?>
						</div>
						<?php
						endif;
						do_action( 'gayatri_options_items' );
						?>
					</div>
				</div>
				<div class="gayatri-element-col-2 gayatri-activator-col">
					<?php 
					$gayatri_activator = 'activate';
					gayatri_settings_page_sidebar( $gayatri_activator ); 
					?>
				</div>
			</div>
		</div>
	</div>
</div>
		<?php
	}
}