<?php
/**
 * Page about
 *
 * @author    Wpayme <hi@wpayme.com>
 * @copyright 2024-2025 Wpayme
 * @license   GPL-3.0-or-later
 * @package   Wpayme\WordPress\Pay
 * @wordpress
 * Version: 5.8.0
 */

use Wpayme\WordPress\Pay\Plugin;

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

?>
<div class="wrap about-wrap">
	<h1><?php esc_html_e( 'Welcome to Wpayme Pay', 'wpayme' ); ?></h1>

	<div class="about-text">
		<?php

		printf(
			/* translators: %s: Plugin version number */
			esc_html__( 'Thanks for installing Wpayme Pay. Version %s is more powerful, stable and secure than ever before. We hope you enjoy using it.', 'wpayme' ),
			esc_html( $this->plugin->get_version() )
		);

		?>
	</div>

	<div class="wp-badge wpayme-pay-badge">
		<?php

		printf(
			/* translators: %s: Plugin version number */
			esc_html__( 'Version: %s', 'wpayme' ),
			esc_html( $this->plugin->get_version() )
		);

		?>
	</div>

	<h2 class="nav-tab-wrapper">
		<?php

		$nav_tabs = [
			'new'             => __( 'What is new?', 'wpayme' ),
			'getting-started' => __( 'Getting started', 'wpayme' ),
		];

		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is not necessary because this parameter does not trigger an action.
		$current_tab = \array_key_exists( 'tab', $_GET ) ? \sanitize_title( \wp_unslash( $_GET['tab'] ) ) : 'new';

		foreach ( $nav_tabs as $tab_id => $tab_title ) {
			$classes = [ 'nav-tab' ];

			if ( $current_tab === $tab_id ) {
				$classes[] = 'nav-tab-active';
			}

			$url = add_query_arg( 'tab', $tab_id );

			printf(
				'<a class="nav-tab %s" href="%s">%s</a>',
				esc_attr( implode( ' ', $classes ) ),
				esc_attr( $url ),
				esc_html( $tab_title )
			);
		}

		?>
	</h2>

	<?php

	$file = __DIR__ . '/tab-' . $current_tab . '.php';

	if ( is_readable( $file ) ) {
		include $file;
	}

	?>
</div>
