FEATURE Introducing default post components to be reused
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2026-02-24 17:19:53 +01:00
parent 46151d30c7
commit 01a6145310
5 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,19 @@
<?php
?>
<div id="post-authors" class="post-authors">
<?php get_template_part('template-parts/authors/authors-list', null, array(
'postId' => get_the_ID()
)); ?>
<?php
// get_template_part('template-parts/authors/authors-last-publications', null, array(
// 'postId' => get_the_ID()
// ));
?>
</div>

View File

@ -0,0 +1,19 @@
<?php
$articleID = $args['ID'];
$articleContent = get_the_content($articleID);
$articleTitle = get_the_title($articleID);
$citeReference = get_field('cite_reference', $articleID);
?>
<article class="post-content entry-content">
<?php the_content(); ?>
<?php if ($citeReference) : ?>
<p id="cite-reference">
<?php echo $citeReference; ?>
</p>
<?php endif; ?>
</article>

View File

@ -0,0 +1,103 @@
<?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>

View File

@ -0,0 +1,19 @@
<?php
$postID = get_the_ID();
$etiquettes = get_the_terms($postID, 'etiquettes');
if (empty($etiquettes)) return;
?>
<div id="post-tags" class="post-tags">
<div class="tags">
<h3 class="tags__title">Tags</h3>
<ul class="tags-list">
<?php foreach ($etiquettes as $etiquette) : ?>
<li class="post-tag">
<a href="<?php echo get_term_link($etiquette); ?>"><?php echo $etiquette->name; ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>

View File

@ -0,0 +1,50 @@
<?php
$id = get_the_ID();
$reference = get_field('references', $id);
$hasReferences = isset($reference) && is_array($reference) && count($reference) > 0;
$authors = get_field('authors', $id);
$hasAuthors = isset($authors) && is_array($authors) && count($authors) > 0;
$pdf_version = get_field('pdf_version', $id);
$pdf_url = isset($pdf_version) && !empty($pdf_version['url']) ? $pdf_version['url'] : null;
?>
<div id="post-toolbar" class="post-toolbar">
<div role="tablist" aria-labelledby="tablist-1" class="tablist">
<button id="tab-1" type="button" role="tab" aria-selected="true" aria-controls="tabpanel-1" data-tab="post">
<img class="icon" src="<?php echo get_stylesheet_directory_uri(); ?>/resources/img/icons/carhop-document.svg" alt="">
<span>Résumé</span>
</button>
<?php if ($hasAuthors) : ?>
<button id="tab-2" type="button" role="tab" aria-selected="false" aria-controls="tabpanel-2" tabindex="-1" data-tab="authors">
<img class="icon" src="<?php echo get_stylesheet_directory_uri(); ?>/resources/img/icons/carhop-plume.svg" alt="">
<span>Auteur·e·s</span>
</button>
<?php endif; ?>
<button id="tab-3" type="button" role="tab" aria-selected="false" aria-controls="tabpanel-5" tabindex="-1" data-tab="informations">
<img class="icon" src="<?php echo get_stylesheet_directory_uri(); ?>/resources/img/icons/carhop-note-biographique.svg" alt="">
<span>Informations</span>
</button>
<div class="toolbar-actions">
<?php if ($pdf_url) : ?>
<a href="<?php echo $pdf_url; ?>" target="_blank" class="cta cta--classic cta--has-icon cta--rounded cta--download-pdf ">
<img class="icon" src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-fleche-telecharger.svg" alt="">
PDF
</a>
<?php endif; ?>
<button id="listen-article" type="button" data-reading-status="stopped" title="Lancer la lecture vocale de l'article">
<img id="play-reading" class="icon" src="<?php echo get_stylesheet_directory_uri(); ?>/resources/img/icons/carhop-ecouter.svg" alt="Lecture vocale de l'article">
<img id="pause-reading" class="icon" src="<?php echo get_stylesheet_directory_uri(); ?>/resources/img/icons/carhop-pause.svg" alt="Arrêter la lecture vocale de l'article">
</button>
<button id="stop-reading" type="button" title="Arrêter la lecture vocale de l'article">
<img class="icon" src="<?php echo get_stylesheet_directory_uri(); ?>/resources/img/icons/carhop-stop-reading.svg" alt="Arrêter la lecture vocale de l'article">
</button>
</div>
</div>
</div>