carhop__dynamiques-theme__P.../template-parts/post-header.php
Nonimart 0618304ddc
All checks were successful
continuous-integration/drone/push Build is passing
FEATURE Handling the share copy link and removing twitter
2025-10-21 10:24:13 +02:00

117 lines
5.1 KiB
PHP

<?php
$currentPostType = get_post_type();
$post_id = get_the_ID();
if ($currentPostType === 'revues') {
$currentRevueID = get_the_ID();
}
if ($currentPostType === 'articles') {
$currentRevueID = get_field('related_revue', $post_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', $post_id);
$likes_count = get_post_likes_count($post_id);
?>
<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
$focal_position = safe_get_thumbnail_focal_point_css();
the_post_thumbnail('full', [
'class' => 'thumbnail',
'style' => 'object-fit: cover; object-position: ' . esc_attr($focal_position) . ';'
]);
?>
<div class="thumbnail-overlay"></div>
</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') : ?>
<h1 class="post-header__title"> <?php echo get_the_title(); ?></h1>
<?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">
<?php
$shareUrls = build_share_urls();
?>
<button class="socials-buttons__button socials-buttons__button--cite" <?php echo empty($citeReference) ? 'disabled' : ''; ?> 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 is-disabled" data-likes-count="<?php echo $likes_count; ?>">
<img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-soutenir.svg" alt="">
<span class="likes-count"><?php echo $likes_count; ?></span>
<span class="button-action-text">J'aime</span>
</button>
<button class="socials-buttons__button socials-buttons__button--share" data-share-url="<?php echo get_the_permalink(); ?>">
<img class="share-icon" src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-partager-social.svg" alt="">
Partager
<ul class="socials-buttons__share-links">
<li class="share-button share-button--facebook">
<a href='<?php echo $shareUrls['Facebook'] ?>' class="share-link" target="_blank" title="<?php echo __("Partager ce contenu sur ", "dynamiques") . "Facebook" ?>">
<img class="social-icon" src="<?php echo get_template_directory_uri() . '/resources/img/icons/carhop-social-facebook.svg' ?>" alt="">
</a>
</li>
<li class="share-button share-button--linkedin">
<a href='<?php echo $shareUrls['Linkedin'] ?>' class="share-link" target="_blank" title="<?php echo __("Partager ce contenu sur ", "dynamiques") . "LinkedIn" ?>">
<img class="social-icon" src="<?php echo get_template_directory_uri() . '/resources/img/icons/carhop-social-linkedin.svg' ?>" alt="">
</a>
</li>
<li class="share-button share-button--copy-link">
<a class="share-link share-link--copy" data-url="<?php echo get_the_permalink(); ?>" title="<?php echo __("Copier le lien", "dynamiques") ?>">
<img class="social-icon" src="<?php echo get_template_directory_uri() . '/resources/img/icons/carhop-social-lien.svg' ?>" alt="">
</a>
</li>
</ul>
</button>
</div>
</div>
</div>
</div>
</section>