<?php
/**
 * Adds Theme page
 *
 * @package JetBlack
 */

function weddi_pro_about_admin_style( $hook ) {
	if ( 'appearance_page_weddi-pro-about' === $hook ) {
		wp_enqueue_style( 'weddi-pro-theme-about', get_theme_file_uri( 'css/theme-about.css' ), null, '1.0' );
	}
}
add_action( 'admin_enqueue_scripts', 'weddi_pro_about_admin_style' );

/**
 * Add theme page
 */
function weddi_pro_menu() {
	add_theme_page( esc_html__( 'About Theme', 'weddi-pro' ), esc_html__( 'About Theme', 'weddi-pro' ), 'edit_theme_options', 'weddi-pro-about', 'weddi_pro_about_display' );
}
add_action( 'admin_menu', 'weddi_pro_menu' );

/**
 * Display About page
 */
function weddi_pro_about_display() {
	$theme = wp_get_theme();
	?>
	<div class="wrap about-wrap full-width-layout">
		<h1><?php echo esc_html( $theme ); ?></h1>
		<div class="about-theme">
			<div class="theme-description">
				<p class="about-text">
					<?php
					// Remove last sentence of description.
					$description = explode( '. ', $theme->get( 'Description' ) );

					array_pop( $description );

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

					echo esc_html( $description . '.' );
				?></p>
				<p class="actions">
					<a href="https://netnus.com/product/weddi-pro-wordpress-theme-for-multipurpose/" class="button button-secondary" target="_blank"><?php esc_html_e( 'Info', 'weddi-pro' ); ?></a>

					<a href="https://netnus.com/Documentation/" class="button button-primary" target="_blank"><?php esc_html_e( 'Documentation', 'weddi-pro' ); ?></a>

					<a href="https://netnus.net/weddi/" class="button button-primary green" target="_blank"><?php esc_html_e( 'Demo', 'weddi-pro' ); ?></a>

					<a href="https://netnus.com/contact/" class="button button-secondary" target="_blank"><?php esc_html_e( 'Support', 'weddi-pro' ); ?></a>
				</p>
			</div>

			<div class="theme-screenshot">
				<img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" />
			</div>

		</div>

		<nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu', 'weddi-pro' ); ?>">
			<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'weddi-pro-about' ), 'themes.php' ) ) ); ?>" class="nav-tab<?php echo ( isset( $_GET['page'] ) && 'weddi-pro-about' === $_GET['page'] && ! isset( $_GET['tab'] ) ) ?' nav-tab-active' : ''; ?>"><?php esc_html_e( 'About', 'weddi-pro' ); ?></a>

			<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'weddi-pro-about', 'tab' => 'changelog' ), 'themes.php' ) ) ); ?>" class="nav-tab<?php echo ( isset( $_GET['tab'] ) && 'changelog' === $_GET['tab'] ) ?' nav-tab-active' : ''; ?>"><?php esc_html_e( 'Changelog', 'weddi-pro' ); ?></a>
		</nav>

		<?php weddi_pro_main_screen(); ?>

		<div class="return-to-dashboard">
			<?php if ( current_user_can( 'update_core' ) && isset( $_GET['updated'] ) ) : ?>
				<a href="<?php echo esc_url( self_admin_url( 'update-core.php' ) ); ?>">
					<?php is_multisite() ? esc_html_e( 'Return to Updates', 'weddi-pro' ) : esc_html_e( 'Return to Dashboard &rarr; Updates', 'weddi-pro' ); ?>
				</a> |
			<?php endif; ?>
			<a href="<?php echo esc_url( self_admin_url() ); ?>"><?php is_blog_admin() ? esc_html_e( 'Go to Dashboard &rarr; Home', 'weddi-pro' ) : esc_html_e( 'Go to Dashboard', 'weddi-pro' ); ?></a>
		</div>
	</div>
	<?php
}

/**
 * Output the main about screen.
 */
function weddi_pro_main_screen() {
	if ( isset( $_GET['page'] ) && 'weddi-pro-about' === $_GET['page'] && ! isset( $_GET['tab'] ) ) {
	?>
		<div class="feature-section two-col">
			<div class="col card">
				<h2 class="title"><?php esc_html_e( 'Theme Customizer', 'weddi-pro' ); ?></h2>
				<p><?php esc_html_e( 'All Theme Options are available via Customize screen.', 'weddi-pro' ) ?></p>
				<p><a href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Customize', 'weddi-pro' ); ?></a></p>
			</div>

			<div class="col card">
				<h2 class="title"><?php esc_html_e( 'Got theme support question?', 'weddi-pro' ); ?></h2>
				<p><?php esc_html_e( 'Get genuine support from genuine people. Whether it\'s customization or compatibility, our seasoned developers deliver tailored solutions to your queries.', 'weddi-pro' ) ?></p>
				<p><a href="https://netnus.com/contact/" class="button button-primary"><?php esc_html_e( 'Support Forum', 'weddi-pro' ); ?></a></p>
			</div>
		</div>
	<?php
	}
}
