<?php

/**
 * Provide a admin area view for the plugin
 *
 * This file is used to markup the admin-facing aspects of the plugin.
 *
 * @link       https://wedima.de
 * @since      1.0.0
 *
 * @package    Wedima_Site
 * @subpackage Wedima_Site/admin/partials
 */
?>
<?php $tab = isset($_GET['tab']) ? $_GET['tab'] : null; ?>
<div class="wrap">
	<h1><?php echo esc_html(get_admin_page_title()); ?></h1>

	<!-- TABS -->
	<nav class="nav-tab-wrapper">
		<a href="?page=wedima-site" class="nav-tab <?= ($tab === null) ? 'nav-tab-active' : '' ?>">
			<?= __('Site Options', 'wedima-site') ?>
		</a>
		<a href="?page=wedima-site&tab=maintenance" class="nav-tab <?= ($tab === 'maintenance') ? 'nav-tab-active' : '' ?>">
			<?= __('Maintenance', 'wedima-site') ?>
		</a>
		<a href="?page=wedima-site&tab=plugin-settings" class="nav-tab <?= ($tab === 'plugin-settings') ? 'nav-tab-active' : '' ?>">
			<?= __('Plugin Settings', 'wedima-site') ?>
		</a>
	</nav>

	<!-- TAB CONTENT -->
	<div class="tab-content">
		<?php
		switch ($tab):
			case 'maintenance':
		?>
				<h3>Maintenance</h3>
				<form method="post" action="options.php">
					<?php settings_fields('wedima_site_maintenance_options_group'); ?>
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row">
									<label for="wedima_site_maintenance_mode">
										<?php _e('Maintenance Mode', 'wedima-site'); ?>
									</label>
								</th>
								<td>
									<select name="wedima_site_maintenance_mode" id="wedima_site_maintenance_mode" aria-describedby="wedima_site_maintenance_mode-description">
										<option value="0" <?php selected(0, get_option('wedima_site_maintenance_mode')) ?>>
											<?= __('None', 'wedima-site') ?>
										</option>
										<option value="1" <?php selected(1, get_option('wedima_site_maintenance_mode')) ?>>
											<?= __('Coming Soon', 'wedima-site') ?>
										</option>
										<option value="2" <?php selected(2, get_option('wedima_site_maintenance_mode')) ?>>
											<?= __('Under Maintenance', 'wedima-site') ?>
										</option>
									</select>
									<p class="description" id="wedima_site_maintenance_mode-description">
										<?php _e('Displays the under construction template for the entire website. The normal site is shown on "None".', 'wedima-site'); ?>
									</p>
								</td>
							</tr>
						</tbody>
					</table>
					<?php submit_button(); ?>
				</form>
			<?php
				break;
			case 'plugin-settings':
			?>
				<h3>Settings</h3>
				<form method="post" action="options.php">
					<?php settings_fields('wedima_site_options_group'); ?>
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row">
									<label for="wedima_site_purge_on_uninstall">
										<?php _e('Purge all on uninstall', 'wedima-site'); ?>
									</label>
								</th>
								<td>
									<input name="wedima_site_purge_on_uninstall" id="wedima_site_purge_on_uninstall" aria-describedby="wedima_site_purge_on_uninstall-description" type="checkbox" value="1" <?php checked(1, get_option('wedima_site_purge_on_uninstall')); ?> />
									<p class="description" id="wedima_site_purge_on_uninstall-description">
										<?php _e('Deletes all data of the plugin on uninstall.', 'wedima-site'); ?>
									</p>
								</td>
							</tr>
						</tbody>
					</table>
					<?php submit_button(); ?>
				</form>
			<?php
				break;
			case 'site-options':
			default:
			?>
				<h3>Site Options</h3>
				<form method="post" action="options.php">
					<?php settings_fields('wedima_site_site_options_options_group'); ?>
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row">
									<label for="wedima_site_client_name">
										<?php _e('Client Name', 'wedima-site'); ?>
									</label>
								</th>
								<td>
									<input name="wedima_site_client_name" id="wedima_site_client_name" class="regular-text ltr" aria-describedby="wedima_site_client_name-description" type="text" value="<?php echo get_option('wedima_site_client_name'); ?>">
									<p class="description" id="wedima_site_client_name-description">
										<?php _e('The name of the client this is used in the footer credits and mail credits. When empty its "Wedima" by default.', 'wedima-site'); ?>
									</p>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<label for="wedima_site_enable_login_language_switcher">
										<?php _e('Enable Login Language Switcher', 'wedima-site'); ?>
									</label>
								</th>
								<td>
									<input name="wedima_site_enable_login_language_switcher" id="wedima_site_enable_login_language_switcher" aria-describedby="wedima_site_enable_login_language_switcher-description" type="checkbox" value="1" <?php checked(1, get_option('wedima_site_enable_login_language_switcher')); ?> />
									<p class="description" id="wedima_site_enable_login_language_switcher-description">
										<?php _e('Enables the Language Switcher introduced in WP 5.9 on the Login Page.', 'wedima-site'); ?>
									</p>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<label for="wedima_site_disable_mail_templates">
										<?php _e('Disable Mail Templates', 'wedima-site'); ?>
									</label>
								</th>
								<td>
									<input name="wedima_site_disable_mail_templates" id="wedima_site_disable_mail_templates" aria-describedby="wedima_site_disable_mail_templates-description" type="checkbox" value="1" <?php checked(1, get_option('wedima_site_disable_mail_templates')); ?> />
									<p class="description" id="wedima_site_disable_mail_templates-description">
										<?php _e('Disables redesigning the default WordPress Mails.', 'wedima-site'); ?>
									</p>
								</td>
							</tr>
						</tbody>
					</table>
					<?php submit_button(); ?>
				</form>
		<?php
				break;
		endswitch;
		?>
	</div>
</div>