Compare commits
No commits in common. "48489aa9fa75ca0275f92bf34ff7c66d41dd99c6" and "46fc8ed033922af44bea3c865f074868e42160e9" have entirely different histories.
48489aa9fa
...
46fc8ed033
|
|
@ -96,7 +96,6 @@ function build_posts($request)
|
||||||
while ($posts_query->have_posts()) : $posts_query->the_post();
|
while ($posts_query->have_posts()) : $posts_query->the_post();
|
||||||
get_template_part('template-parts/components/cards/post-card', null, array(
|
get_template_part('template-parts/components/cards/post-card', null, array(
|
||||||
'ID' => get_the_ID(),
|
'ID' => get_the_ID(),
|
||||||
'current_post_type' => $post_type
|
|
||||||
));
|
));
|
||||||
endwhile;
|
endwhile;
|
||||||
else :
|
else :
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,17 @@ function calculate_reading_time($content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
$tags = get_terms(array(
|
||||||
|
'taxonomy' => 'etiquettes',
|
||||||
|
'hide_empty' => false,
|
||||||
|
));
|
||||||
|
|
||||||
|
return $tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_archive_page_icon_html($post_type)
|
function get_archive_page_icon_html($post_type)
|
||||||
{
|
{
|
||||||
switch ($post_type) {
|
switch ($post_type) {
|
||||||
|
|
@ -439,7 +450,7 @@ function is_a_collections_page()
|
||||||
$current_page_id = (int) get_queried_object_id();
|
$current_page_id = (int) get_queried_object_id();
|
||||||
|
|
||||||
|
|
||||||
if ($collection_parent_page_id === $current_page_id) {
|
if ($collection_parent_page_id === $current_page_id || $is_fond_archive_fonds_archives) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -453,90 +464,3 @@ function is_a_collections_page()
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function carhop_get_post_card_link_according_to_post_datas($post_id, $card_args = [])
|
|
||||||
{
|
|
||||||
|
|
||||||
$post_id = (int) $post_id;
|
|
||||||
|
|
||||||
|
|
||||||
$has_external_link = $card_args['has_external_link'] ?? false;
|
|
||||||
$external_link = $card_args['external_link'] ?? false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($has_external_link && $external_link !== '') {
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'link' => $external_link,
|
|
||||||
'target' => '_blank',
|
|
||||||
'text' => $card_args['external_link_text'] ?? null,
|
|
||||||
'is_external' => true,
|
|
||||||
'has_valid_link' => true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$post_type = get_post_type($post_id);
|
|
||||||
$link = get_the_permalink($post_id);
|
|
||||||
$target = '_self';
|
|
||||||
$text = null;
|
|
||||||
$is_external = false;
|
|
||||||
|
|
||||||
|
|
||||||
switch ($post_type) {
|
|
||||||
case 'analyses-etudes':
|
|
||||||
$type_analyse_etude = get_the_terms($post_id, 'type-analyse-etude')[0] ?? null;
|
|
||||||
|
|
||||||
if ($type_analyse_etude->slug === 'analyse') {
|
|
||||||
write_log("######");
|
|
||||||
$link_type = get_field('link_type', $post_id);
|
|
||||||
|
|
||||||
switch ($link_type) {
|
|
||||||
case 'pdf':
|
|
||||||
$pdf = get_field('pdf', $post_id);
|
|
||||||
if (is_array($pdf) && ! empty($pdf['url'])) {
|
|
||||||
$link = $pdf['url'];
|
|
||||||
$target = '_blank';
|
|
||||||
$is_external = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'link':
|
|
||||||
$link_field = get_field('link', $post_id);
|
|
||||||
if (is_array($link_field) && ! empty($link_field['url'])) {
|
|
||||||
$link = $link_field['url'];
|
|
||||||
$target = '_blank';
|
|
||||||
$is_external = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$link = get_the_permalink($post_id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'dbmob':
|
|
||||||
$maitron_url = get_field('maitron_url', $post_id);
|
|
||||||
write_log($maitron_url);
|
|
||||||
$link = $maitron_url ?? get_the_permalink($post_id);
|
|
||||||
$target = '_blank';
|
|
||||||
$text = 'Voir la notice';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$link = get_permalink($post_id) ?: '';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'link' => $link,
|
|
||||||
'target' => $target,
|
|
||||||
'text' => $text,
|
|
||||||
'is_external' => $is_external,
|
|
||||||
'has_valid_link' => ($link !== ''),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
overflow-x: clip;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
max-width: 100vw;
|
max-width: 100vw;
|
||||||
overflow-x: clip;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,14 @@
|
||||||
<span><?php echo __('Rechercher', 'homegrade-theme__texte-fonctionnel') ?></span>
|
<span><?php echo __('Rechercher', 'homegrade-theme__texte-fonctionnel') ?></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
$lastRevue = $recent_posts = wp_get_recent_posts(array(
|
||||||
|
'numberposts' => 1,
|
||||||
|
'post_type' => 'revues',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
));
|
||||||
|
$lastRevueUrl = get_permalink($lastRevue[0]['ID']);
|
||||||
|
?>
|
||||||
<ul class="search-module__suggestions">
|
<ul class="search-module__suggestions">
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,14 @@ $showExcerpt = $args['show_excerpt'] ?? false;
|
||||||
|
|
||||||
$showTags = $args['showTags'] ?? true;
|
$showTags = $args['showTags'] ?? true;
|
||||||
|
|
||||||
|
$has_external_link = $args['has_external_link'] ?? false;
|
||||||
|
$external_link = $args['external_link'] ?? null;
|
||||||
|
$external_link_text = $args['external_link_text'] ?? null;
|
||||||
|
|
||||||
|
$target = $has_external_link && ! empty($external_link) ? '_blank' : '_self';
|
||||||
|
|
||||||
$excerpt = get_the_excerpt($ID);
|
$excerpt = get_the_excerpt($ID);
|
||||||
|
$link = ($has_external_link && ! empty($external_link)) ? $external_link : get_the_permalink($ID);
|
||||||
|
|
||||||
$has_post_thumbnail = has_post_thumbnail($ID);
|
$has_post_thumbnail = has_post_thumbnail($ID);
|
||||||
$thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
|
$thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
|
||||||
|
|
@ -28,96 +35,97 @@ $tags = get_the_terms($ID, 'etiquettes');
|
||||||
$description = get_field('description', $ID);
|
$description = get_field('description', $ID);
|
||||||
$birth_death_date = get_field('birth_death_date', $ID);
|
$birth_death_date = get_field('birth_death_date', $ID);
|
||||||
|
|
||||||
$card_link = carhop_get_post_card_link_according_to_post_datas($ID, $args);
|
|
||||||
$link = $card_link['link'];
|
|
||||||
$target = $card_link['target'];
|
|
||||||
$external_link_text = $card_link['text'];
|
|
||||||
$has_valid_link = $card_link['has_valid_link'];
|
|
||||||
$is_external = $card_link['is_external'];
|
|
||||||
|
|
||||||
$card_classes = 'card post-card post-card--' . sanitize_html_class((string) $current_post_type);
|
if($current_post_type === 'analyses-etudes'){
|
||||||
$card_classes .= $has_post_thumbnail ? ' post-card--has-thumbnail' : '';
|
$type_analyse_etude = get_the_terms($ID, 'type-analyse-etude')[0] ?? null;
|
||||||
$card_classes .= ! $has_valid_link ? ' post-card--no-link' : '';
|
|
||||||
|
if($type_analyse_etude->slug === 'analyse'){
|
||||||
|
$link_type = get_field('link_type', $ID);
|
||||||
|
$target = '_blank' ;
|
||||||
|
|
||||||
|
switch($link_type){
|
||||||
|
case 'pdf':
|
||||||
|
$link = get_field('pdf', $ID)['url'] ?? '';
|
||||||
|
break;
|
||||||
|
case 'link':
|
||||||
|
$link = get_field('link', $ID)['url'] ?? '';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$link = get_the_permalink($ID);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ($has_valid_link) : ?>
|
<a class="post-card post-card--<?php echo $current_post_type . ' ' . ($has_post_thumbnail ? 'post-card--has-thumbnail' : ''); ?> card" href="<?php echo esc_url($link); ?>" target="<?php echo $target; ?>">
|
||||||
<a class="<?php echo esc_attr(trim($card_classes)); ?>"
|
<?php if ($has_post_thumbnail) : ?>
|
||||||
href="<?php echo esc_url($link); ?>"
|
<div class="post-card__thumbnail">
|
||||||
target="<?php echo esc_attr($target); ?>"
|
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
|
||||||
<?php echo $is_external ? ' rel="noopener noreferrer"' : ''; ?>>
|
<?php if ($has_thumbnail_overlay) : ?>
|
||||||
<?php else : ?>
|
<div class="thumbnail-overlay"></div>
|
||||||
<div class="<?php echo esc_attr(trim($card_classes)); ?>">
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
<?php if ($has_post_thumbnail) : ?>
|
<?php endif; ?>
|
||||||
<div class="post-card__thumbnail">
|
<div class="card__inner">
|
||||||
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
|
<?php get_template_part('template-parts/components/content-meta', null, array(
|
||||||
<?php if ($has_thumbnail_overlay) : ?>
|
'current_post_type' => $current_post_type,
|
||||||
<div class="thumbnail-overlay"></div>
|
'current_post_id' => $ID
|
||||||
<?php endif; ?>
|
)); ?>
|
||||||
</div>
|
<div class="card__content">
|
||||||
<?php endif; ?>
|
<h3 class="card__title"><?php echo $title; ?></h3>
|
||||||
<div class="card__inner">
|
<?php if ($showExcerpt) : ?>
|
||||||
<?php get_template_part('template-parts/components/content-meta', null, array(
|
<div class="card__excerpt"><?php echo $excerpt; ?></div>
|
||||||
'current_post_type' => $current_post_type,
|
<?php endif; ?>
|
||||||
'current_post_id' => $ID
|
<?php if ($birth_death_date) : ?>
|
||||||
)); ?>
|
<div class="card__birth-death-date"><?php echo $birth_death_date; ?></div>
|
||||||
<div class="card__content">
|
<?php endif; ?>
|
||||||
<h3 class="card__title"><?php echo $title; ?></h3>
|
<?php if ($description) : ?>
|
||||||
<?php if ($showExcerpt) : ?>
|
<div class="card__description"><?php echo $description; ?></div>
|
||||||
<div class="card__excerpt"><?php echo $excerpt; ?></div>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
<?php if ($birth_death_date) : ?>
|
<div class="card__details">
|
||||||
<div class="card__birth-death-date"><?php echo $birth_death_date; ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($description) : ?>
|
|
||||||
<div class="card__description"><?php echo $description; ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<div class="card__details">
|
|
||||||
|
|
||||||
<div class="post-card__details-text">
|
<div class="post-card__details-text">
|
||||||
<time datetime="<?php echo $date; ?>" class="card__details-date date"><?php echo $date; ?></time>
|
<time datetime="<?php echo $date; ?>" class="card__details-date date"><?php echo $date; ?></time>
|
||||||
|
|
||||||
<?php if ($authors) : ?>
|
<?php if ($authors) : ?>
|
||||||
<ul class="post-card__authors">
|
<ul class="post-card__authors">
|
||||||
<?php if ($has_main_author && $main_author) : ?>
|
<?php if ($has_main_author && $main_author) : ?>
|
||||||
<li class="main-author"><?php echo $main_author->post_title; ?></li>
|
<li class="main-author"><?php echo $main_author->post_title; ?></li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php foreach ($authors as $author) : ?>
|
<?php foreach ($authors as $author) : ?>
|
||||||
<li class="author"><?php echo $author->post_title; ?></li>
|
<li class="author"><?php echo $author->post_title; ?></li>
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<?php if ($has_publication_direction && $publication_directors) : ?>
|
|
||||||
<?php foreach ($publication_directors as $publication_director) : ?>
|
|
||||||
<li class="publication-director">Sous la direction de <?php echo $publication_director->post_title; ?></li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($editors) : ?>
|
|
||||||
<li class="editor"><?php echo $editors; ?></li>
|
|
||||||
<?php endif; ?>
|
|
||||||
</ul>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<?php if ($current_post_type === 'outils-pedagogiques' && has_post_thumbnail($ID)) : ?>
|
|
||||||
<div class="card__thumbnail">
|
|
||||||
<?php the_post_thumbnail('medium'); ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($showTags && $tags) : ?>
|
|
||||||
<ul class="tag-list">
|
|
||||||
<?php foreach ($tags as $tag) : ?>
|
|
||||||
<li class="tag-list__tag"><?php echo $tag->name; ?></li>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<?php if ($has_publication_direction && $publication_directors) : ?>
|
||||||
|
<?php foreach ($publication_directors as $publication_director) : ?>
|
||||||
|
<li class="publication-director">Sous la direction de <?php echo $publication_director->post_title; ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($editors) : ?>
|
||||||
|
<li class="editor"><?php echo $editors; ?></li>
|
||||||
|
<?php endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if ($current_post_type === 'outils-pedagogiques' && has_post_thumbnail($ID)) : ?>
|
||||||
|
<div class="card__thumbnail">
|
||||||
|
<?php the_post_thumbnail('medium'); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($showTags && $tags) : ?>
|
||||||
|
<ul class="tag-list">
|
||||||
|
<?php foreach ($tags as $tag) : ?>
|
||||||
|
<li class="tag-list__tag"><?php echo $tag->name; ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($has_valid_link) : ?>
|
|
||||||
</a>
|
|
||||||
<?php else : ?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
|
</a>
|
||||||
Loading…
Reference in New Issue
Block a user