FEATURE Handling the collective access button redirection

This commit is contained in:
Antoine M 2026-05-13 11:55:30 +02:00
parent f6111ab21b
commit 14fe284679
4 changed files with 43 additions and 2 deletions

View File

@ -8,6 +8,7 @@ $current_post_type = get_post_type();
<main id="content" class="site-content flex-grow"> <main id="content" class="site-content flex-grow">
<?php get_template_part('template-parts/post-types/fonds-archives/archive-header'); ?> <?php get_template_part('template-parts/post-types/fonds-archives/archive-header'); ?>
<?php get_template_part('template-parts/components/collective-acess-button'); ?>
<!-- #### ARCHIVE POST GRID #### --> <!-- #### ARCHIVE POST GRID #### -->

View File

@ -442,3 +442,25 @@ function get_current_post_numerotation($post_id)
return null; return null;
} }
function is_a_collections_page()
{
$collection_parent_page_id = 83;
$current_page_id = (int) get_queried_object_id();
if ($collection_parent_page_id === $current_page_id || $is_fond_archive_fonds_archives) {
return true;
}
if ($current_page_id) {
$ancestors = get_post_ancestors($current_page_id, 'page');
if (in_array($collection_parent_page_id, array_map('intval', $ancestors), true)) {
return true;
}
}
return false;
}

View File

@ -6,6 +6,9 @@
while (have_posts()) : while (have_posts()) :
the_post(); the_post();
the_content(); the_content();
if (is_a_collections_page()) {
get_template_part('template-parts/components/collective-acess-button');
}
?> ?>

View File

@ -0,0 +1,15 @@
<?php
/**
* Collective Access Button
*
* @package Carhop
* @subpackage Components
* @since 1.0.0
*/
?>
<a href="https://collectiveaccess.org" class="collective-access-button" target="_blank">
<span class="collective-access-button-text">
Collective Access
</span>
</a>