<?php
/**
 * Getting Started Page.
 *
 * @package dark_fitness
 */


if( ! function_exists( 'dark_fitness_getting_started_menu' ) ) :
/**
 * Adding Getting Started Page in admin menu
 */
function dark_fitness_getting_started_menu(){	
	add_theme_page(
		__( 'Getting Started', 'dark-fitness' ),
		__( 'Getting Started', 'dark-fitness' ),
		'manage_options',
		'dark-fitness-getting-started',
		'dark_fitness_getting_started_page'
	);
}
endif;
add_action( 'admin_menu', 'dark_fitness_getting_started_menu' );

if( ! function_exists( 'dark_fitness_getting_started_admin_scripts' ) ) :
/**
 * Load Getting Started styles in the admin
 */
function dark_fitness_getting_started_admin_scripts( $hook ){
	// Load styles only on our page
	if( 'appearance_page_dark-fitness-getting-started' != $hook ) return;

    wp_enqueue_style( 'dark-fitness-getting-started', get_template_directory_uri() . '/assets/css/getting-started.css', false, DARK_FITNESS_THEME_VERSION );

    wp_enqueue_script( 'dark-fitness-getting-started', get_template_directory_uri() . '/assets/js/getting-started.js', array( 'jquery' ), DARK_FITNESS_THEME_VERSION, true );
}
endif;
add_action( 'admin_enqueue_scripts', 'dark_fitness_getting_started_admin_scripts' );

if( ! function_exists( 'dark_fitness_getting_started_page' ) ) :
/**
 * Callback function for admin page.
*/
function dark_fitness_getting_started_page(){ 
	$dark_fitness_theme = wp_get_theme();?>
	<div class="wrap getting-started container">
		<div class="getting-info">
			<div class="theme-intro">
				<div class="intro-wrap">
					<div class="intro cointaner">
						<div class="intro-content">
							<h3><?php echo esc_html( 'Welcome to', 'dark-fitness' );?> <span class="theme-name"><?php echo esc_html( DARK_FITNESS_THEME_NAME ); ?></span></h3>
							<p class="about-text">
								<?php
								// Remove last sentence of description.
								$dark_fitness_description = explode( '. ', $dark_fitness_theme->get( 'Description' ) );

								$dark_fitness_description = implode( '. ', $dark_fitness_description );

								echo esc_html( $dark_fitness_description . '' );
							?></p>
							<div class="btns-getstart">
								<a href="<?php echo esc_url( DARK_FITNESS_PREMIUM_PAGE ); ?>" target="_blank" class="button button-primary"><?php esc_html_e( 'Get Premium', 'dark-fitness' ); ?></a>
								<a href="<?php echo esc_url( DARK_FITNESS_PRO_DEMO ); ?>" target="_blank" class="button button-primary"><?php esc_html_e( 'Live Demo', 'dark-fitness' ); ?></a>
								<a href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>" target="_blank" class="button button-primary"><?php esc_html_e( 'Customize Theme', 'dark-fitness' ); ?></a>
							</div>
							<div class="btns-wizard">
								<?php if ( ! get_option( 'is-demo-imported' ) ) : ?>

									<?php
									$dark_fitness_theme_name = wp_get_theme()->get( 'Name' );
									$dark_fitness_demo_importer_url = '';

									if ( $dark_fitness_theme_name === 'Dark Fitness' ) {
										$dark_fitness_demo_importer_url = admin_url( 'themes.php?page=darkfitness-wizard' );
									} elseif ( $dark_fitness_theme_name === 'Aster Gym Trainer' ) {
										$dark_fitness_demo_importer_url = admin_url( 'themes.php?page=astergymtrainer-wizard' );
									}
									?>

									<?php if ( ! empty( $dark_fitness_demo_importer_url ) ) : ?>
										<a href="<?php echo esc_url( $dark_fitness_demo_importer_url ); ?>"
										class="button button-primary wizard">
											<?php esc_html_e( 'Import Theme Demo', 'dark-fitness' ); ?>
										</a>
									<?php endif; ?>

								<?php else : ?>
									<a target="_blank"
									href="<?php echo esc_url( home_url( '/' ) ); ?>"
									class="button button-primary view-site">
										<?php esc_html_e( 'Visit Your Website', 'dark-fitness' ); ?>
									</a>
								<?php endif; ?>
							</div>

						</div>
						<div class="intro-img">
							<img src="<?php echo esc_url(get_template_directory_uri()) .'/theme-library/getting-started/images/bundle.png'; ?>" />										
							<br>
							<h4 class="bundle-text"><?php esc_html_e( 'WP Theme Bundle', 'dark-fitness' ); ?></h4>
							<p class="about-text"><?php esc_html_e('Get access to a collection of premium WordPress themes in one bundle. Enjoy effortless website building, full customization, and dedicated customer support for a smooth, professional web experience.', 'dark-fitness'); ?></p>
							<a class="button button-primary" href="<?php echo esc_url( DARK_FITNESS_BUNDLE_PAGE ); ?>" title="<?php esc_attr_e( 'Go Pro', 'dark-fitness' ); ?>" target="_blank">
								<?php esc_html_e( 'Exclusive Theme Bundle - $79', 'dark-fitness' ); ?>
							</a>
						</div>
					</div>
				</div>
				<div class="cointaner panels">
					<ul class="inline-list">
						<li class="current">
							<a id="help" href="javascript:void(0);">
								<?php esc_html_e( 'Getting Started', 'dark-fitness' ); ?>
							</a>
						</li>
						<li>
							<a id="free-pro-panel" href="javascript:void(0);">
								<?php esc_html_e( 'Free Vs Pro', 'dark-fitness' ); ?>
							</a>
						</li>
					</ul>
					<div id="panel" class="panel">
						<?php require get_template_directory() . '/theme-library/getting-started/tabs/help-panel.php'; ?>
						<?php require get_template_directory() . '/theme-library/getting-started/tabs/free-vs-pro-panel.php'; ?>
						<?php require get_template_directory() . '/theme-library/getting-started/tabs/link-panel.php'; ?>
					</div>
				</div>
			</div>
			<div class="icons-info">
				<div class="icon-img">									
					<a href="<?php echo esc_url( DARK_FITNESS_REVIEW ); ?>" title="<?php esc_attr_e( 'Review Theme', 'dark-fitness' ); ?>" target="_blank">
						<img src="<?php echo esc_url(get_template_directory_uri()) .'/theme-library/getting-started/images/icon1.png'; ?>" />	
						<?php esc_html_e( 'Review Theme', 'dark-fitness' ); ?>
					</a>
				</div>
				<div class="icon-img">									
					<a href="<?php echo esc_url( DARK_FITNESS_SUPPORT ); ?>" title="<?php esc_attr_e( 'Contact Support', 'dark-fitness' ); ?>" target="_blank">
						<img src="<?php echo esc_url(get_template_directory_uri()) .'/theme-library/getting-started/images/icon2.png'; ?>" />	
						<?php esc_html_e( 'Contact Support', 'dark-fitness' ); ?>
					</a>
				</div>
				<div class="icon-img">									
					<a href="<?php echo esc_url( DARK_FITNESS_THEME_DOCUMENTATION ); ?>" title="<?php esc_attr_e( 'Free Theme Documentation', 'dark-fitness' ); ?>" target="_blank">
						<img src="<?php echo esc_url(get_template_directory_uri()) .'/theme-library/getting-started/images/icon3.png'; ?>" />	
						<?php esc_html_e( 'Free Theme Documentation', 'dark-fitness' ); ?>
					</a>
				</div>
			</div>	
		</div>	
	</div>
	<?php
}
endif;