carhop__dynamiques-theme__P.../template-parts/post-header.php
2025-06-23 16:19:40 +02:00

84 lines
3.3 KiB
PHP

<?php
$currentPostType = get_post_type();
if ($currentPostType === 'revues') {
$currentRevueID = get_the_ID();
}
if ($currentPostType === 'articles') {
$currentRevueID = get_field('related_revue', get_the_ID());
}
if (!$currentRevueID) return;
$revueTitle = get_the_title($currentRevueID);
$issueNumber = get_field('issue_number', $currentRevueID);
$post_type = get_post_type();
$hasThumbnail = has_post_thumbnail();
$citeReference = get_field('cite_reference', $currentRevueID);
?>
<section class="post-header post-header--<?php echo $post_type; ?> ">
<div class="post-header__inner post-header__inner--<?php echo $hasThumbnail ? 'has-thumbnail' : 'no-thumbnail'; ?> ">
<?php if ($hasThumbnail) : ?>
<div class="thumbnail-wrapper">
<?php the_post_thumbnail('full', ['class' => 'thumbnail']); ?>
</div>
<?php endif; ?>
<div class="content">
<div class="content-meta">
<?php if ($post_type === 'revues') : ?>
<span class="content-meta__type content-meta__type--revue">Revue</span>
<?php elseif ($post_type === 'articles') : ?>
<span class="content-meta__type content-meta__type--article">Article</span>
<?php endif; ?>
<p class="content-meta__revue-issue">
<span class="revue-issue-number revue-meta__label sr-only">Numéro</span>
<span class="revue-issue-number revue-meta__value"><?php echo $issueNumber; ?></span>
</p>
</div>
<?php if ($post_type === 'revues') : ?>
<h1 class="post-header__title"> <?php echo $revueTitle; ?></h1>
<?php elseif ($post_type === 'articles') : ?>
<h2 class="post-header__title"> <?php echo get_the_title(); ?></h2>
<?php endif; ?>
<div class="post-details">
<?php if ($post_type === 'revues') : ?>
<div class="revue-meta">
<div class="revue-date-info">
<p class="post-details__label">Parution</p>
<time class="post-details__value" datetime="<?php echo get_the_date('Y-m-d', $currentRevueID); ?>"><?php echo get_the_date('d F Y', $currentRevueID); ?></time>
</div>
</div>
<?php elseif ($post_type === 'articles') : ?>
<div class="article-meta">
<div class="article-meta__related-revue">
<p class="post-details__label">Revue</p>
<a href="<?php echo get_the_permalink($currentRevueID); ?>" class="article-meta__value"><?php echo $revueTitle; ?></a>
</div>
</div>
<?php endif; ?>
<div class="socials-buttons">
<button class="socials-buttons__button socials-buttons__button--cite" disabled="<?php echo empty($citeReference) ? 'true' : 'false'; ?>" title="<?php echo empty($citeReference) ? 'Citation non disponible' : 'Copier la citation'; ?>">
<img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-citer-article.svg" alt="">
Citer
</button>
<button class="socials-buttons__button socials-buttons__button--like">
<img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-soutenir.svg" alt="">
J'aime
</button>
<button class="socials-buttons__button socials-buttons__button--share">
<img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-partager-social.svg" alt="">
Partager
</button>
</div>
</div>
</div>
</div>
</section>