Compare commits

..

3 Commits

Author SHA1 Message Date
Nonimart
5c9476cb61 FEATURE optimizing behaviour
All checks were successful
continuous-integration/drone/push Build is passing
2025-10-21 11:44:27 +02:00
Nonimart
746363d81a REFACTOR Removing unecessary lineskips 2025-10-21 10:44:24 +02:00
Nonimart
0fabe129da FIX Handling subscribe newsletter link 2025-10-21 10:44:04 +02:00
4 changed files with 37 additions and 18 deletions

View File

@ -1,12 +1,16 @@
<?php <?php
// Apply the filter to multiple hooks to ensure choices are available during render, validation, and submission
add_filter('gform_pre_render', 'populate_taxonomy_terms'); add_filter('gform_pre_render', 'populate_taxonomy_terms');
add_filter('gform_pre_validation', 'populate_taxonomy_terms');
add_filter('gform_pre_submission_filter', 'populate_taxonomy_terms');
add_filter('gform_admin_pre_render', 'populate_taxonomy_terms');
function populate_taxonomy_terms($form) function populate_taxonomy_terms($form)
{ {
// Specify the form ID and the ID of the select field // Specify the form ID and the ID of the select field
$form_id = 2; $form_id = 2;
$field_id = 15; $field_id = 16;
// Check if the current form matches the specified form ID // Check if the current form matches the specified form ID
if ($form['id'] == $form_id) { if ($form['id'] == $form_id) {
@ -16,20 +20,39 @@ function populate_taxonomy_terms($form)
'hide_empty' => false, // Include empty terms 'hide_empty' => false, // Include empty terms
)); ));
// Prepare choices array for the select field // Find the checkbox field by ID
foreach ($form['fields'] as &$field) {
if ($field->id == $field_id) {
// Prepare choices and inputs array for checkboxes
$choices = array(); $choices = array();
$inputs = array();
$index = 1;
foreach ($terms as $term) { foreach ($terms as $term) {
$choices[] = array( $choices[] = array(
'text' => $term->name, 'text' => $term->name,
'value' => $term->term_id, 'value' => $term->name, // Use term name as value for display
'isSelected' => false,
); );
// For checkboxes, each choice needs a corresponding input
$inputs[] = array(
'id' => $field->id . '.' . $index,
'label' => $term->name,
'name' => '',
);
$index++;
} }
// Find the select field by ID // Update choices and inputs for the checkbox field
foreach ($form['fields'] as &$field) {
if ($field->id == $field_id) {
// Update choices for the select field
$field->choices = $choices; $field->choices = $choices;
$field->inputs = $inputs;
// Ensure the field is not marked as administrative only
$field->adminOnly = false;
break; break;
} }
} }

View File

@ -41,9 +41,7 @@ $revueID = get_field('related_revue', get_the_ID());
<?php get_template_part('template-parts/articles/article-content', null, array( <?php get_template_part('template-parts/articles/article-content', null, array(
'ID' => get_the_ID() 'ID' => get_the_ID()
)); ?> )); ?>
</div> </div>
</div> </div>
<!-- #### RECOMMANDATIONS #### --> <!-- #### RECOMMANDATIONS #### -->

View File

@ -15,8 +15,6 @@ $articlesAmount = get_author_articles_amount($author_id);
<?php if (have_posts()) : ?> <?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?> <?php while (have_posts()) : the_post(); ?>
<div class="page--single-auteurs__header"> <div class="page--single-auteurs__header">
<div class="inner container"> <div class="inner container">

View File

@ -24,9 +24,9 @@
<img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-rechercher.svg" alt="Rechercher"> <img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-rechercher.svg" alt="Rechercher">
</button> </button>
<button class="subscribe-button"> <a class="subscribe-button" href="<?php echo home_url(); ?>/infolettre">
<img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-abonner.svg" alt="Sabonner"> <img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-abonner.svg" alt="Sabonner">
</button> </a>
</div> </div>
</div> </div>
</div> </div>