debug fixing using debug log

This commit is contained in:
Antoine M 2023-10-27 17:08:59 +02:00
parent ecf0cc70af
commit c00be423a8
12 changed files with 80 additions and 109 deletions

View File

@ -11,6 +11,7 @@ add_action('rest_api_init', function () {
register_rest_route('homegrade-datas/v1', '/questions-thematiques/(?P<thematiqueId>\d+)', array( register_rest_route('homegrade-datas/v1', '/questions-thematiques/(?P<thematiqueId>\d+)', array(
'methods' => 'GET', 'methods' => 'GET',
'callback' => 'get_questions_posts_per_thematique_id', 'callback' => 'get_questions_posts_per_thematique_id',
'permission_callback' => '__return_true',
'args' => array( 'args' => array(
'excluded_ids' => array( 'excluded_ids' => array(
'sanitize_callback' => 'sanitize_text_field', 'sanitize_callback' => 'sanitize_text_field',
@ -21,11 +22,15 @@ add_action('rest_api_init', function () {
register_rest_route('homegrade-datas/v1', '/news', array( register_rest_route('homegrade-datas/v1', '/news', array(
'methods' => 'GET', 'methods' => 'GET',
'callback' => 'get_news', 'callback' => 'get_news',
'permission_callback' => '__return_true',
)); ));
// * SHIP NEWS BY TYPE // * SHIP NEWS BY TYPE
register_rest_route('homegrade-datas/v1', '/news/type/(?P<typeId>\d+)', array( register_rest_route('homegrade-datas/v1', '/news/type/(?P<typeId>\d+)', array(
'methods' => 'GET', 'methods' => 'GET',
'callback' => 'get_news_posts_per_type_id', 'callback' => 'get_news_posts_per_type_id',
'permission_callback' => '__return_true',
)); ));
@ -36,11 +41,15 @@ add_action('rest_api_init', function () {
register_rest_route('homegrade-datas/v1/build', '/news', array( register_rest_route('homegrade-datas/v1/build', '/news', array(
'methods' => 'GET', 'methods' => 'GET',
'callback' => 'build_news_posts_feed_all', 'callback' => 'build_news_posts_feed_all',
'permission_callback' => '__return_true',
)); ));
// * BUILD NEWS CARDS BY NEWS TYPE // * BUILD NEWS CARDS BY NEWS TYPE
register_rest_route('homegrade-datas/v1/build', '/news/type/(?P<typeId>\d+)', array( register_rest_route('homegrade-datas/v1/build', '/news/type/(?P<typeId>\d+)', array(
'methods' => 'GET', 'methods' => 'GET',
'callback' => 'build_news_posts_feed_per_type_id', 'callback' => 'build_news_posts_feed_per_type_id',
'permission_callback' => '__return_true',
)); ));
}); });

View File

@ -73,15 +73,15 @@ function getMainThematique($thematique)
// Get automatic post used in BLOCK QUESTIONS FREQUENTES // Get automatic post used in BLOCK QUESTIONS FREQUENTES
function get_automatic_post($post_type) function get_automatic_post($post_thematique)
{ {
$automatic_query_args = array( $automatic_query_args = array(
'post_per_page' => 1, 'post_per_page' => 1,
'post_status' => 'publish', 'post_status' => 'publish',
'post_type' => 'questions', 'post_type' => 'questions',
'thematiques' => $post_type, 'thematiques' => $post_thematique,
); );
return get_posts($automatic_query_args)[0]; return get_posts($automatic_query_args)[0] ?? null;
} }

View File

@ -1,4 +1,10 @@
<?php get_header(); ?> <?php get_header(); ?>
<?php
$currentThematique = get_the_terms(get_the_ID(), 'thematiques')[0];
$mainThematique = getMainThematique($currentThematique);
$thematiqueColorSlug = $mainThematique->slug;
?>
<div class="homegrade-page-container <?php echo $thematiqueColorSlug ? "homegrade-page-container--" . $thematiqueColorSlug : "" ?>"> <div class="homegrade-page-container <?php echo $thematiqueColorSlug ? "homegrade-page-container--" . $thematiqueColorSlug : "" ?>">
<?php if (have_posts()) : ?> <?php if (have_posts()) : ?>

View File

@ -1,50 +0,0 @@
.post-infos-capsule {
@apply flex flex-wrap justify-start gap-x-8 gap-y-5;
&__share,
&__publication-date {
@apply bg-white text-primary
rounded-full
px-4
sm:px-6
py-2
w-fit
h-auto
flex justify-center
items-center
font-medium;
}
&__share {
@apply gap-1 md:gap-2;
.share-button {
@apply bg-primary w-8 h-8 rounded-full p-4 relative;
transition: transform 0.3s ease-in-out;
&:before {
@apply absolute w-3 h-3 bg-contain bg-center bg-no-repeat;
width: 25px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
content: '';
}
&:hover {
transform: scale(1.05);
filter: brightness(1.4);
}
}
.share-button--facebook {
&:before {
background-image: url('../resources/img/graphic-assets/icone-social-facebook.svg');
}
}
.share-button--twitter-x {
&:before {
background-image: url('../resources/img/graphic-assets/icone-social-twitter-x.svg');
}
}
.share-button--linkedin {
&:before {
background-image: url('../resources/img/graphic-assets/icone-social-linkedin.svg');
}
}
}
}

View File

@ -1,5 +1,6 @@
<?php <?php
get_header(); get_header();
if (!function_exists('build_share_urls')) {
function build_chapter_index($blocks) function build_chapter_index($blocks)
{ {
$chapterBlockIndex = []; $chapterBlockIndex = [];
@ -28,8 +29,8 @@ function build_chapter_index($blocks)
} }
return $chapterBlockIndex; return $chapterBlockIndex;
} }
}
?> ?>
<?php if (have_posts()) : ?> <?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?> <?php while (have_posts()) : the_post(); ?>
<?php <?php
@ -80,8 +81,8 @@ function build_chapter_index($blocks)
$blocks = parse_blocks($post->post_content); $blocks = parse_blocks($post->post_content);
$chapterBlockIndex = build_chapter_index($blocks); $chapterBlockIndex = build_chapter_index($blocks);
?> ?>
<?php get_template_part('template-components/post-conseils/chapter-header', array( <?php get_template_part('template-components/post-conseils/chapter-header', null, array(
'ID' => get_the_ID(), 'postID' => get_the_ID(),
)); ?> )); ?>
<div class=" conseils_wrapper"> <div class=" conseils_wrapper">
<aside class="chapter_index"> <aside class="chapter_index">

View File

@ -1,4 +1,4 @@
<?php p<?php
/************/ /************/
/* PAGE FAQ */ /* PAGE FAQ */
@ -114,11 +114,7 @@ $relatedTaxQuestions = new WP_Query($query_args);
<?php endwhile ?> <?php endwhile ?>
<?php endif; ?> <?php endif; ?>
</section> </section>
<?php if ($currentThematiqueIsParent) : ?>
<p><?php echo $currentThematiqueIsParent['title'] ?></p>
<button id="load-more-questions"><?php echo __("Charger plus de questions", "homegrade-theme__texte-fonctionnel") ?></button> <button id="load-more-questions"><?php echo __("Charger plus de questions", "homegrade-theme__texte-fonctionnel") ?></button>
<?php endif; ?>
</div> </div>

View File

@ -37,7 +37,9 @@ $thematiquesTerms = get_terms(array(
<li class="term"> <li class="term">
<a href="<?php echo get_term_link($thematique) ?>"> <a href="<?php echo get_term_link($thematique) ?>">
<?php if ($thematique_icon) : ?>
<img src="<?php echo $thematique_icon['url'] ?>" alt=""> <img src="<?php echo $thematique_icon['url'] ?>" alt="">
<?php endif; ?>
<p class="text-<?php echo $termSlug ?>"><span class="sr-only">Question </span><?php echo $thematique->name ?></p> <p class="text-<?php echo $termSlug ?>"><span class="sr-only">Question </span><?php echo $thematique->name ?></p>
</a> </a>
</li> </li>

View File

@ -18,7 +18,7 @@ $block_titling_datas = get_field('block_titling_datas');
)); ));
foreach ($recent_posts as $key => $post) { foreach ($recent_posts as $key => $post) {
$post_thumbnail = get_the_post_thumbnail($post['ID'], 'full', array('class' => 'card-post__thumbnail')); $post_thumbnail = get_the_post_thumbnail($post['ID'], 'full', array('class' => 'card-news__thumbnail'));
$post_tags = get_the_tags($post['ID']); $post_tags = get_the_tags($post['ID']);
get_template_part( get_template_part(

View File

@ -18,20 +18,18 @@ $block_titling = get_field('block_titling_description_datas');
'parent' => 0 'parent' => 0
)); ));
// echo '<pre>';
// print_r($thematique_terms);
// echo '</pre>';
// $thematiques = ['location', 'acoustique'];
foreach ($thematique_terms as $key => $thematique) { foreach ($thematique_terms as $key => $thematique) {
$thematique_datas = get_term_by('slug', $thematique->slug, 'thematiques'); // $thematique_datas = get_term_by('slug', $thematique->slug, 'thematiques');
$manual_data = get_field($thematique->slug . '_manual_data'); $manual_data = get_field($thematique->slug . '_manual_data');
$post_datas = $manual_data ? $manual_data : get_automatic_post($thematique->slug); $post_datas = $manual_data ? $manual_data : get_automatic_post($thematique->slug);
get_template_part( get_template_part(
'template-components/cards/card-frequent-question', 'template-components/cards/card-frequent-question',
null, null,
array( array(
'thematique' => $thematique_datas, 'thematique' => $thematique,
'post_ID' => $post_datas->ID, 'post_ID' => $post_datas->ID,
'post_title' => $post_datas->post_title, 'post_title' => $post_datas->post_title,
'post_excerpt' => $post_datas->post_excerpt, 'post_excerpt' => $post_datas->post_excerpt,

View File

@ -3,12 +3,14 @@
$thematique = $args['thematique']; $thematique = $args['thematique'];
$taxonomy_picture = get_field('taxonomy_pictures', $thematique); $taxonomy_picture = get_field('taxonomy_pictures', $thematique) ?? null;
$color = getThematiqueFamilySlug($thematique->slug); $color = getThematiqueFamilySlug($thematique->slug);
?> ?>
<div class="card-thematique card-<?php echo $thematique->slug ?>" data-taxonomy="<?php echo $thematique->slug ?>"> <div class="card-thematique card-<?php echo $thematique->slug ?>" data-taxonomy="<?php echo $thematique->slug ?>">
<?php if ($taxonomy_picture && $taxonomy_picture['illustration_s']) : ?>
<img class="card-thematique__thumbnail" src="<?php echo $taxonomy_picture['illustration_s']['sizes']['medium'] ?>" alt=""> <img class="card-thematique__thumbnail" src="<?php echo $taxonomy_picture['illustration_s']['sizes']['medium'] ?>" alt="">
<?php endif; ?>
<h3 class="card-thematique__title text-<?php echo getThematiqueFamilySlug($thematique->slug) ?>"><?php echo $thematique->name ?></h3> <h3 class="card-thematique__title text-<?php echo getThematiqueFamilySlug($thematique->slug) ?>"><?php echo $thematique->name ?></h3>
<p class="card-thematique__description"><?php echo $thematique->description ?></p> <p class="card-thematique__description"><?php echo $thematique->description ?></p>

View File

@ -1,6 +1,7 @@
<?php <?php
$thematique = get_the_terms($args['ID'], 'thematiques')[0] ?? null;
$thematique = get_the_terms($args['postID'], 'thematiques')[0] ?? null;
$thematique_generale = $thematique->parent ? get_term($thematique->parent, 'thematiques') : $thematique; $thematique_generale = $thematique->parent ? get_term($thematique->parent, 'thematiques') : $thematique;
$thematique_generale_id_fr = $thematique_generale_id_fr =
apply_filters('wpml_object_id', $thematique_generale->term_id, 'thematiques', TRUE, 'fr'); apply_filters('wpml_object_id', $thematique_generale->term_id, 'thematiques', TRUE, 'fr');
@ -8,7 +9,7 @@ $thematique_generale_id_fr =
// Récupère la source de l'image par rapport à l'ID FR pour s'assurer de bien synchroniser les images dans les deux langues // Récupère la source de l'image par rapport à l'ID FR pour s'assurer de bien synchroniser les images dans les deux langues
$thematique_picture = get_field('taxonomy_pictures', "thematiques_" . $thematique_generale_id_fr)['illustration_s'] ?? null; $thematique_picture = get_field('taxonomy_pictures', "thematiques_" . $thematique_generale_id_fr)['illustration_s'] ?? null;
$lastUpdate = get_the_modified_date('', $args['ID']); $lastUpdate = get_the_modified_date('', $args['postID']);
$queryArgs = array( $queryArgs = array(
// 'fields' => 'ids', // 'fields' => 'ids',
@ -42,15 +43,23 @@ $relatedBrochure = get_field('brochure_pdf', $relatedBrochuresPosts[0]->ID) ?? n
<?php endif; ?> <?php endif; ?>
<h1 class="post-conseils-chapter-header__page-title"><?php echo get_the_title($args['ID']) ?></h1> <h1 class="post-conseils-chapter-header__page-title"><?php echo get_the_title($args['postID']) ?></h1>
<?php if ($relatedBrochure) : ?> <?php if ($relatedBrochure) : ?>
<a class="cta cta--primary cta--button" href="<?php echo $relatedBrochure['url'] ?>" target="_blank">Télécharger la brochure <?php echo $relatedBrochures[0]->post_title ?></a> <?php
// echo '<pre>';
// print_r($relatedBrochure);
// echo '</pre>';
?>
<a class="cta cta--primary cta--button" href="<?php echo $relatedBrochure['url'] ?>" target="_blank">
<?php
echo __("Télécharger la brochure ", "homegrade-theme__texte-fonctionnel")
?><span class="sr-only"><?php echo $relatedBrochure['title'] ?></span> </a>
<?php endif; ?> <?php endif; ?>
<?php <?php
get_template_part('template-components/post-infos-capsule', null, array( get_template_part('template-components/post-infos-capsule', null, array(
"post_id" => $args['ID'], "postID" => $args['postID'],
"modified" => $lastUpdate "modified" => $lastUpdate
)); ));
?> ?>

View File

@ -12,9 +12,7 @@ $thematique_generale_id_fr = apply_filters('wpml_object_id', $thematique_general
$thematique_picture = get_field('taxonomy_pictures', "thematiques_" . $thematique_generale_id_fr)['illustration_s'] ?? null; $thematique_picture = get_field('taxonomy_pictures', "thematiques_" . $thematique_generale_id_fr)['illustration_s'] ?? null;
$lastUpdate = get_the_modified_date('', get_the_ID()); $lastUpdate = get_the_modified_date('', get_the_ID());
echo '<pre>';
print_r($questions->posts);
echo '</pre>';
?> ?>