FEATURE Refactor social buttons into a separate component for improved modularity and maintainability
This commit is contained in:
parent
5351753763
commit
993514c0c4
|
|
@ -19,6 +19,10 @@ $has_thumbnail_overlay = $args['has_thumbnail_overlay'] ?? false;
|
|||
|
||||
$likes_count = get_post_likes_count($post_id);
|
||||
$citeReference = get_field('cite_reference', $post_id);
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<?php if ($hasNumerotation) : ?>
|
||||
|
|
@ -94,44 +98,8 @@ $citeReference = get_field('cite_reference', $post_id);
|
|||
<time class="post-details__value" datetime="<?php echo get_the_date('Y-m-d', $post_id); ?>"><?php echo get_the_date('d F Y', $post_id); ?></time>
|
||||
</div>
|
||||
</div>
|
||||
<?php get_template_part('template-parts/components/posts/social-buttons', null, array()); ?>
|
||||
|
||||
<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>
|
||||
|
||||
|
|
|
|||
43
template-parts/components/posts/social-buttons.php
Normal file
43
template-parts/components/posts/social-buttons.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
$currentPostType = get_post_type();
|
||||
$shareUrls = build_share_urls();
|
||||
$handleCitation = post_type_supports($currentPostType, 'carhop-citations') ?? false;
|
||||
?>
|
||||
|
||||
|
||||
<div class="socials-buttons">
|
||||
<?php if ($handleCitation) : ?>
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
<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>
|
||||
Loading…
Reference in New Issue
Block a user