<?php
/**
 * Theme help
 *
 * Adds a simple Theme help page to the Appearance section of the WordPress Dashboard.
 *
 * @package Cordero
 */

// Add Theme help page to admin menu.
add_action( 'admin_menu', 'cordero_add_theme_help_page' );

function cordero_add_theme_help_page() {

	// Get Theme Details from style.css
	$theme = wp_get_theme();

	/* translators: %s: theme name. */
	add_theme_page(
		esc_html( $theme->get( 'Name' ) ) . ' ' .  esc_html( $theme->get( 'Version' ) ), sprintf( esc_html__( '%s Theme', 'cordero' ), $theme->get( 'Name' ) ), 'edit_theme_options', 'cordero', 'cordero_display_theme_help_page'
	);

}

// Display Theme help page.
function cordero_display_theme_help_page() {

	// Get Theme Details from style.css.
	$theme = wp_get_theme();
	?>

	<div class="wrap theme-help-wrap">

		<h1><?php echo esc_html( $theme->get( 'Name' ) ) . ' <span class="theme-version">' .  esc_html( $theme->get( 'Version' ) ); ?></span></h1>

		<div class="theme-description"><?php echo esc_html( $theme->get( 'Description' ) ); ?></div>

		<div id="getting-started">

			<h3><?php
				/* translators: %s: theme name. */
				printf( esc_html__( 'Getting Started with %s', 'cordero' ), $theme->get( 'Name' ) ); ?>
			</h3>

			<h4><strong><?php esc_html_e( 'Block Patterns', 'cordero' ); ?></strong></h4>

			<p class="about">
				<?php esc_html_e( 'Cordero has a variety of patterns to help you get started, including a full width hero, featured services and pricing table.', 'cordero' ); ?>
			</p>
			<p class="about">
				<?php esc_html_e( 'To begin, add or edit a page, click the "Add Block" button and then the "Patterns" tab.', 'cordero' ); ?>
			</p>
			<p class="about">
				<?php esc_html_e( 'Find a pattern you like, and click it to add the pattern to your page.', 'cordero' ); ?>
			</p>
			<p class="about">
				<?php esc_html_e( 'Thats it! You can now edit the text or images of the pattern to really make it your own!', 'cordero' ); ?>
			</p>

			<p class="about">
				<?php esc_html_e( 'Add or edit a page now to try it out.', 'cordero' ); ?>
			</p>
			<p>
				<a href="<?php echo esc_url( get_admin_url() . 'post-new.php?post_type=page' ); ?>" class="button button-primary">
					<?php esc_html_e( 'Add New Page', 'cordero' ); ?>
				</a>
			</p>

			<img src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/help-block-pattern-inserted.jpg" class="pattern-img" />

			<div class="columns-wrapper clearfix">

				<div class="column column-half clearfix">

					<div class="section">
						<h4><?php esc_html_e( 'Options', 'cordero' ); ?></h4>

						<p class="about">
							<?php
							/* translators: %s: theme name. */
							printf( esc_html__( '%s makes use of the Customizer for the theme settings.', 'cordero' ), $theme->get( 'Name' ) ); ?>
						</p>
						<p>
							<a href="<?php echo esc_url( wp_customize_url() ); ?>" class="button button-primary">
								<?php esc_html_e( 'Customize', 'cordero' ); ?>
							</a>
						</p>
					</div>

					<div class="section">
						<h4><?php esc_html_e( 'Support', 'cordero' ); ?></h4>

						<p class="about">
							<?php esc_html_e( 'Any questions?', 'cordero' ); ?>
						</p>
						<p>
							<a href="<?php echo esc_url( 'https://wordpress.org/support/theme/cordero/' ); ?>" target="_blank" class="button button-secondary">
								<?php esc_html_e( 'Get Support', 'cordero' ); ?>
							</a>
						</p>
					</div>


					<div class="section">
						<h4><?php esc_html_e( 'Upgrade', 'cordero' ); ?></h4>

						<p class="about">
							<?php esc_html_e( 'Upgrade to Cordero Pro for even more cool features and customization options.', 'cordero' ) ; ?>
						</p>
						<p>
							<a href="<?php echo esc_url( 'https://uxlthemes.com/theme/cordero-pro/' ); ?>" target="_blank" class="button button-pro">
								<?php esc_html_e( 'GO PRO', 'cordero' ); ?>
							</a>
						</p>
					</div>

				</div>

				<div class="column column-half clearfix">

					<div class="screenshot">
						<a href="<?php echo esc_url( 'https://uxlthemes.com/theme/cordero/' ); ?>" target="_blank">
							<img src="<?php echo esc_url( get_template_directory_uri() ); ?>/screenshot.png" />
						</a>
						<a href="<?php echo esc_url( 'https://uxlthemes.com/theme/cordero/' ); ?>" target="_blank" class="button button-primary">
							<?php esc_html_e( 'Theme Details', 'cordero' ); ?>
						</a>
					</div>

				</div>

			</div>

		</div>

		<hr>

		<div id="theme-author">

			<p>
				<?php /* translators: %1$s: theme name, %2$s: theme author, %3$s: link to theme review page. */
				printf( esc_html__( '%1$s is proudly brought to you by %2$s. If you like this theme, %3$s :)', 'cordero' ),  $theme->get( 'Name' ) , '<a target="_blank" href="https://uxlthemes.com/">' . $theme->get( 'Author' ) . '</a>', '<a target="_blank" href="https://wordpress.org/support/theme/cordero/reviews/?filter=5">' . __( 'rate it', 'cordero' ) . '</a>' ); ?>
			</p>

		</div>

	</div>

	<?php
}

// Add CSS for Theme help Panel.
add_action( 'admin_enqueue_scripts', 'cordero_theme_help_page_css' );

function cordero_theme_help_page_css( $hook ) {

	// Load styles and scripts only on theme help page.
	if ( 'appearance_page_cordero' != $hook ) {
		return;
	}

	// Embed theme help css style.
	wp_enqueue_style( 'cordero-theme-help-css', get_template_directory_uri() . '/css/theme-help.css' );
}
