<?php
/*
Template Name: Modèle Login
Template Post Type: page
*/
if (is_user_logged_in()) {
	wp_safe_redirect(admin_url());
	exit;
}
get_header();
?>
<!-- /* INTERNAL PAGE HEADER IMG -->
<div class="container-fluid p-0 position-relative pagehead">
	<div class="filterdiv internalpage position-absolute top-0 start-0"></div>
	<?php
	if (has_post_thumbnail()) {
		the_post_thumbnail('full', ['class' => 'img-fluid w-100']); 
	} else {
		echo '<img src="' . get_template_directory_uri() . '/assets/img/actu/fallout-serie-tv.jpg" class="img-fluid w-100" alt="Actu Séries" loading="lazy">';
	}
	?>
</div>
<!-- IMG END -->

<!-- PAGE CONTENT -->
<div class="container mt-5">
	<div class="row">
		<div class="col-6 offset-3 mb-4">
		<h1 class="htitles my-5">Formulaire de connexion</h1>
			<p class="text-center">
				<?php
				if (!is_user_logged_in() && !current_user_can('manage_options')) {
					wp_login_form(array(
						'redirect' => admin_url() // par défaut renvoie vers la page courante mais finalement on renvoie vers l'admin
					));
					echo '<p class="text-end"><a class="text-secondary" href="' . wp_lostpassword_url() . '">Mot de passe perdu ?</p>';
				} else {
					echo '<p><a href="' . wp_logout_url(home_url()) . '">Logout</a></p>';
				}
				?>
			</p>
		</div>
	</div>
</div>
<!-- PAGE CONTENT END -->
<?php
get_template_part('template-parts/content-videobg');
get_template_part('template-parts/content-prefooter');
get_footer();
