<?php
if (!is_user_logged_in() || !current_user_can('administrator')) {
	wp_redirect(home_url());
	exit();
}


get_header();
$args = array(
	'post_type' => 'brochures',
	'posts_per_page' => -1,
	'post_status' => 'publish',

);
$brochures = new WP_Query($args);

?>
<div class="max-w-screen-lg mx-auto mb-16">
	<h2 class="font-bold text-4xl pt-10 pb-4 text-secondary">BROCHURES FR</h2>

	<ul>
		<?php if ($brochures->have_posts()) : while ($brochures->have_posts()) : $brochures->the_post(); ?>
				<?php
				global $post;

				?>
				<li class="pb-6">
					<h2 class="font-bold text-2xl "><?php the_title() ?></h2>
					<p>slug: <span class="font-bold text-secondary "><?php echo $post->post_name ?></span></p>
					<a href="<?php echo get_permalink(get_the_id()) ?>" class="underline text-blue-500 font-semibold"> <?php echo get_permalink(get_the_id()) ?></a>
					<p class="font-bold text-gray-dark mt-2 mb-4">
						<?php edit_post_link(__('⟶ Éditer la page')); ?>
					</p>
				</li>
			<?php endwhile ?>
		<?php endif; ?>
	</ul>
</div>

<?php
do_action('wpml_switch_language', "nl");
$args = array(
	'post_type' => 'brochures',
	'posts_per_page' => -1,
	'post_status' => 'publish',

);

$brochuresNL = new WP_Query($args);

?>

<div class="max-w-screen-lg mx-auto">
	<h2 class="font-bold text-4xl pt-10 pb-4 text-secondary">BROCHURES NL</h2>

	<ul>
		<?php if ($brochuresNL->have_posts()) : while ($brochuresNL->have_posts()) : $brochuresNL->the_post(); ?>
				<?php
				global $post;

				?>
				<li class="pb-6">
					<h2 class="font-bold text-2xl "><?php the_title() ?></h2>
					<p>slug: <span class="font-bold text-secondary "><?php echo $post->post_name ?></span></p>
					<a href="<?php echo get_permalink(get_the_id()) ?>" class="underline text-blue-500 font-semibold"> <?php echo get_permalink(get_the_id()) ?></a>
					<p class="font-bold text-gray-dark mt-2 mb-4">
						<?php edit_post_link(__('⟶ Éditer la page')); ?>
					</p>

				</li>
			<?php endwhile ?>
		<?php endif; ?>
	</ul>
</div>

<?php
do_action('wpml_switch_language', "fr");
$args = array(
	'post_type' => 'fiches-infos',
	'posts_per_page' => -1,
	'post_status' => 'publish',

);

$fichesinfosFR = new WP_Query($args);

?>

<div class="max-w-screen-lg mx-auto">
	<h2 class="font-bold text-4xl pt-10 pb-4 text-secondary">FICHES INFOS FR</h2>

	<ul>
		<?php if ($fichesinfosFR->have_posts()) : while ($fichesinfosFR->have_posts()) : $fichesinfosFR->the_post(); ?>
				<?php
				global $post;

				?>
				<li class="pb-6">
					<h2 class="font-bold text-2xl "><?php the_title() ?></h2>
					<p>slug: <span class="font-bold text-secondary "><?php echo $post->post_name ?></span></p>
					<a href="<?php echo get_permalink(get_the_id()) ?>" class="underline text-blue-500 font-semibold"> <?php echo get_permalink(get_the_id()) ?></a>
					<p class="font-bold text-gray-dark mt-2 mb-4">
						<?php edit_post_link(__('⟶ Éditer la page')); ?>
					</p>

				</li>
			<?php endwhile ?>
		<?php endif; ?>
	</ul>
</div>
<?php
do_action('wpml_switch_language', "nl");
$args = array(
	'post_type' => 'fiches-infos',
	'posts_per_page' => -1,
	'post_status' => 'publish',

);

$fichesinfosNL = new WP_Query($args);

?>

<div class="max-w-screen-lg mx-auto">
	<h2 class="font-bold text-4xl pt-10 pb-4 text-secondary">FICHES INFOS NL</h2>

	<ul>
		<?php if ($fichesinfosNL->have_posts()) : while ($fichesinfosNL->have_posts()) : $fichesinfosNL->the_post(); ?>
				<?php
				global $post;

				?>
				<li class="pb-6">
					<h2 class="font-bold text-2xl "><?php the_title() ?></h2>
					<p>slug: <span class="font-bold text-secondary "><?php echo $post->post_name ?></span></p>
					<a href="<?php echo get_permalink(get_the_id()) ?>" class="underline text-blue-500 font-semibold"> <?php echo get_permalink(get_the_id()) ?></a>
					<p class="font-bold text-gray-dark mt-2 mb-4">
						<?php edit_post_link(__('⟶ Éditer la page')); ?>
					</p>

				</li>
			<?php endwhile ?>
		<?php endif; ?>
	</ul>
</div>