Compare commits

...

2 Commits

Author SHA1 Message Date
Antoine M
1a2d2708ef REFACTOR Clean up rendering logic in dbmob archives by removing unused variables and improving code structure
All checks were successful
continuous-integration/drone/push Build is passing
2026-05-20 10:54:53 +02:00
Antoine M
e1eb9b428c REFACTOR Simplify target link assignment logic in CTA render files 2026-05-20 10:53:44 +02:00
4 changed files with 14 additions and 28 deletions

View File

@ -3,8 +3,7 @@ $align = isset($attributes['align']) ? $attributes['align'] : '';
$link = isset($attributes['link']) ? $attributes['link'] : [];
$text = isset($attributes['text']) ? $attributes['text'] : '';
$color = isset($attributes['color']) ? $attributes['color'] : '';
$target = isset($link) && $link['opensInNewTab'] ? '_blank' : '_self';
$target = (isset($link['opensInNewTab']) && $link['opensInNewTab']) ? '_blank' : '_self';
$raw_url = isset($link['url']) ? $link['url'] : '';
$is_inner_page_link = is_string($raw_url) && strpos($raw_url, '#') === 0;

View File

@ -37,24 +37,18 @@ $post_count = $query->found_posts;
<?php if ($query->have_posts()) : ?>
<div class="dbmob-grid">
<?php while ($query->have_posts()) : $query->the_post(); ?>
<?php $maitron_url = get_field('maitron_url', get_the_ID()); ?>
<?php get_template_part('template-parts/components/cards/post-card', null, array(
'ID' => get_the_ID(),
'ID' => get_the_ID(),
'current_post_type' => 'dbmob',
'has_external_link' => isset($maitron_url) && !empty($maitron_url),
'external_link' => $maitron_url,
'external_link_text' => 'Voir la notice',
)); ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php if ($post_count > $initialPostDisplayAmount) : ?>
<button class="load-more-button" data-offset="0" data-posts-per-page="-1">Afficher plus</button>
<?php endif; ?>
<?php if ($post_count > $initialPostDisplayAmount) : ?>
<button class="load-more-button" data-offset="0" data-posts-per-page="-1">Afficher plus</button>
<?php endif; ?>

View File

@ -3,8 +3,7 @@ $align = isset($attributes['align']) ? $attributes['align'] : '';
$link = isset($attributes['link']) ? $attributes['link'] : [];
$text = isset($attributes['text']) ? $attributes['text'] : '';
$color = isset($attributes['color']) ? $attributes['color'] : '';
$target = isset($link) && $link['opensInNewTab'] ? '_blank' : '_self';
$target = (isset($link['opensInNewTab']) && $link['opensInNewTab']) ? '_blank' : '_self';
$raw_url = isset($link['url']) ? $link['url'] : '';
$is_inner_page_link = is_string($raw_url) && strpos($raw_url, '#') === 0;

View File

@ -37,24 +37,18 @@ $post_count = $query->found_posts;
<?php if ($query->have_posts()) : ?>
<div class="dbmob-grid">
<?php while ($query->have_posts()) : $query->the_post(); ?>
<?php $maitron_url = get_field('maitron_url', get_the_ID()); ?>
<?php get_template_part('template-parts/components/cards/post-card', null, array(
'ID' => get_the_ID(),
'ID' => get_the_ID(),
'current_post_type' => 'dbmob',
'has_external_link' => isset($maitron_url) && !empty($maitron_url),
'external_link' => $maitron_url,
'external_link_text' => 'Voir la notice',
)); ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php if ($post_count > $initialPostDisplayAmount) : ?>
<button class="load-more-button" data-offset="0" data-posts-per-page="-1">Afficher plus</button>
<?php endif; ?>
<?php if ($post_count > $initialPostDisplayAmount) : ?>
<button class="load-more-button" data-offset="0" data-posts-per-page="-1">Afficher plus</button>
<?php endif; ?>