carhop__carhop-theme__DEV/template-parts/components/posts/post-header.php
Antoine M 01a6145310
All checks were successful
continuous-integration/drone/push Build is passing
FEATURE Introducing default post components to be reused
2026-02-24 17:19:53 +01:00

103 lines
4.4 KiB
PHP

<?php
$currentPostType = get_post_type();
$post_id = get_the_ID();
$postTitle = get_the_title($post_id);
$hasNumerotation = hasPostTypeNumerotation($post_id);
$hasThumbnail = has_post_thumbnail();
$authors = get_field('authors', $ID);
?>
<?php if ($hasNumerotation) : ?>
<?php
$numerotation = get_post_meta($current_post_id, 'post_numerotation', true); ?>
<p class="content-meta__revue-issue content-meta__revue-issue--green">
<span class="revue-issue-number revue-meta__label sr-only">Numéro</span>
<?php echo $numerotation; ?>
</p>
<?php endif; ?>
<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">
<?php get_template_part('template-parts/components/content-meta', null, array(
'current_post_id' => $post_id,
'current_post_type' => $post_type
)); ?>
<h1 class="post-header__title"> <?php echo $postTitle; ?></h1>
<?php if ($authors && is_array($authors) && count($authors) > 0) : ?>
<a class="post-header__main-author" href="<?php echo get_the_permalink($authors[0]->ID); ?>">
<?php echo $authors[0]->post_title; ?>
</a>
<?php endif; ?>
<div class="post-details">
<div class="post-meta">
<div class="post-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>
<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>