<?php
/**
 * Class RPGAL_Guide
 *
 * This file contains the guide page for the "Responsive Portfolio Image Gallery" plugin
 * in the admin panel. The guide page provides YouTube video instructions, and
 * assistance to administrators on how to use shortcode of the plugin.
 *
 * @package Responsive Portfolio Image Gallery 1.3 - 10 July, 2025
 * @link https://www.realwebcare.com/
 */

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

if (!class_exists('RPGAL_Guide')) {
	class RPGAL_Guide
	{

		/**
		 * Render the guide page.
		 */
		public function render_rpgal_guide_page()
		{ ?>
			<div class="rpgal_settings_area">
				<div class="wrap rpgal_settings">
					<h1 class="main-header">
						<?php esc_html_e('Responsive Portfolio Image Gallery Guide', 'responsive-portfolio-image-gallery'); ?>
					</h1>
					<?php $this->render_rpgal_guide_content(); ?>
					<?php $this->render_rpgal_dashboard_guide(); ?>
				</div>
				<?php $this->render_sidebar(); ?>
			</div>
			<?php
		}

		/**
		 * Render YouTube Video and Documentation
		 */
		public function render_rpgal_guide_content()
		{
			?>
			<div class="rpgal-guide-info">
				<p class="get-instructed">
					<?php
					printf(
						esc_html__(
							'Watch the Tutorial Video:',
							'responsive-portfolio-image-gallery'
						)
					);
					?>
				</p>
				<p>
					<?php
					printf(
						/* translators: 1: Opening strong tag, 2: Closing strong tag */
						esc_html__('To help you get started with the %1$sResponsive Portfolio Image Gallery%2$s plugin, we\'ve prepared a detailed tutorial video. This video is %1$s12 minutes and 10 seconds%2$s long and covers everything you need to know about how the plugin works, including setup, configuration, and advanced features.', 'responsive-portfolio-image-gallery'),
						'<strong>',
						'</strong>'
					); ?>
				</p>
				<p><?php esc_html_e('We highly recommend watching this video to make the most out of the Responsive Portfolio Image Gallery plugin. If you have any questions after watching, feel free to reach out to our support team. (We\'ll update the video soon to guide you with the latest update.)', 'responsive-portfolio-image-gallery'); ?></p>
				<div class="getting-started_video">
					<p><iframe width="620" height="350" src="https://www.youtube-nocookie.com/embed/4B1bbiBdtJg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
				</div>
			</div>
			<?php
		}

		/**
		 * Render instructions for creating a new user front-end dashboard.
		 */
		public function render_rpgal_dashboard_guide()
		{
			?>
			<div class="rpgal-guide-info">
				<h3 class="get-instructed">
					<?php
					printf(
						esc_html__(
							'Code Usage Instruction in the Theme',
							'responsive-portfolio-image-gallery'
						)
					);
					?>
				</h3>
				<ol class="rpgal-guide-instructions">
					<li>
						<?php
						printf(
							/* translators: 1: Opening strong tag, 2: Closing strong tag */
							esc_html__('To display a portfolio gallery shortcode in a WordPress theme file, you can use the %1$sdo_shortcode%2$s function:', 'responsive-portfolio-image-gallery'),
							'<strong>',
							'</strong>'
						);
						?>
					</li>
					<li>
						<?php
						printf(
							/* translators: %s: Example of do_shortcode usage in a PHP code block */
							esc_html__('Example of shortcode usage in PHP: %s', 'responsive-portfolio-image-gallery'),
							'<pre><code><span>&lt;?php</span> <span class="rpgal-keyword">echo</span> <span class="rpgal-function">do_shortcode</span>(<span class="rpgal-string">\'[rpgal-gallery]\'</span>); <span>?&gt;</span></code></pre>'
						);
						?>
					</li>
					<li>
						<?php
						printf(
							esc_html__('You can place this code anywhere in your theme file where you want the portfolio gallery to appear. For example, you could place it in the template file for a specific page of your site.', 'responsive-portfolio-image-gallery')
						);
						?>
					</li>
					<li>
						<?php
						printf(
							/* translators: 1: Opening strong tag, 2: Closing strong tag */
							esc_html__('Keep in mind that if you are making changes directly to your theme files, those changes will be overwritten if you update the theme. To avoid this, you can create a child theme and make your changes there instead.', 'responsive-portfolio-image-gallery'),
							'<strong>',
							'</strong>'
						);
						?>
					</li>
				</ol>
			</div>
			<div class="rpgal-guide-info">
				<h3 class="get-instructed">
					<?php
					printf(
						esc_html__(
							'Important Key Changes in Version 1.3',
							'responsive-portfolio-image-gallery'
						)
					);
					?>
				</h3>
				<ol class="rpgal-guide-instructions">
					<li>
						<?php
						printf(
							// translators: 1: opening <strong> tag, 2: closing </strong> tag
							esc_html__(
								'The plugin has transitioned from %1$srcpig%2$s to %1$srpgal%2$s for all key components. This affects custom post types, taxonomies, settings, and meta keys.',
								'responsive-portfolio-image-gallery'
							),
							'<strong>',
							'</strong>'
						);
						?>
					</li>
					<li>
						<?php
						printf(
							// translators: 1: opening <strong> tag, 2: closing </strong> tag
							esc_html__(
								'Custom post type %1$srcpig%2$s is now %1$srpgal%2$s, and taxonomy %1$srcpig-category%2$s is now %1$srpgal-category%2$s.',
								'responsive-portfolio-image-gallery'
							),
							'<strong>',
							'</strong>'
						);
						?>
					</li>
					<li>
						<?php
						printf(
							// translators: 1: opening <strong> tag, 2: closing </strong> tag
							esc_html__(
								'Settings option groups have changed from %1$s"rcpig_general", "rcpig_advanced", "rcpig_style"%2$s to %1$s"rpgal_general", "rpgal_advanced", "rpgal_style"%2$s.',
								'responsive-portfolio-image-gallery'
							),
							'<strong>',
							'</strong>'
						);
						?>
					</li>
					<li>
						<?php
						printf(
							// translators: 1: opening <strong> tag, 2: closing </strong> tag
							esc_html__(
								'Button meta keys have changed. Old keys like %1$s"_first_button_text", "_first_button_link", "_first_button_tab"%2$s are now %1$s"_button_text", "_button_link", "_button_ntab"%2$s.',
								'responsive-portfolio-image-gallery'
							),
							'<strong>',
							'</strong>'
						);
						?>
					</li>
					<li>
						<?php
						printf(
							// translators: 1: opening <code> tag, 2: closing </code> tag
							esc_html__(
								'Shortcode has changed from %1$s[rcpig-gallery]%2$s to %1$s[rpgal-gallery]%2$s.',
								'responsive-portfolio-image-gallery'
							),
							'<code>',
							'</code>'
						);
						?>
					</li>
					<li>
						<?php
						printf(
							esc_html__(
								'You must update your existing pages or posts where the old shortcode was used.',
								'responsive-portfolio-image-gallery'
							)
						);
						?>
					</li>
					<li>
						<?php
						printf(
							// translators: 1: opening <strong> tag, 2: closing </strong> tag
							esc_html__(
								'All changes are automatically migrated using the internal version-check method %1$s"rpgal_check_version"%2$s. However, if you experience any issues, please update the settings manually and save them again.',
								'responsive-portfolio-image-gallery'
							),
							'<strong>',
							'</strong>'
						);
						?>
					</li>
				</ol>
			</div>
			<?php
		}

		/**
		 * Render the sidebar.
		 */
		private function render_sidebar()
		{
			if (class_exists('RPGAL_Sidebar')) {
				$rpgal_sidebar = RPGAL_Sidebar::get_instances();

				if (method_exists($rpgal_sidebar, 'rpgal_sidebar')) {
					// Render sidebar content
					$sidebar_content = $rpgal_sidebar->rpgal_sidebar(true, false, true);

					if ($sidebar_content !== null) {
						echo wp_kses_post($sidebar_content);
					} else {
						// Fallback for null content
						echo ''; // or provide alternative content if needed
					}
				}
			}
		}
	}
}