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(
'methods' => 'GET',
'callback' => 'get_questions_posts_per_thematique_id',
'permission_callback' => '__return_true',
'args' => array(
'excluded_ids' => array(
'sanitize_callback' => 'sanitize_text_field',
@ -21,11 +22,15 @@ add_action('rest_api_init', function () {
register_rest_route('homegrade-datas/v1', '/news', array(
'methods' => 'GET',
'callback' => 'get_news',
'permission_callback' => '__return_true',
));
// * SHIP NEWS BY TYPE
register_rest_route('homegrade-datas/v1', '/news/type/(?P<typeId>\d+)', array(
'methods' => 'GET',
'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(
'methods' => 'GET',
'callback' => 'build_news_posts_feed_all',
'permission_callback' => '__return_true',
));
// * BUILD NEWS CARDS BY NEWS TYPE
register_rest_route('homegrade-datas/v1/build', '/news/type/(?P<typeId>\d+)', array(
'methods' => 'GET',
'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
function get_automatic_post($post_type)
function get_automatic_post($post_thematique)
{
$automatic_query_args = array(
'post_per_page' => 1,
'post_status' => 'publish',
'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
$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 : "" ?>">
<?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,35 +1,36 @@
<?php
get_header();
function build_chapter_index($blocks)
{
$chapterBlockIndex = [];
foreach ($blocks as $key => $block) {
if ($block['blockName'] == 'homegrade-content-blocks/questions-container') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => '#questions-container-' . $block['attrs']['relatedPostId'],
'title' => get_the_title($block['attrs']['relatedPostId']),
]);
}
if ($block['blockName'] == 'homegrade-content-blocks/vocabulaire-summary') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => "#vocabulaire-summary",
'title' => "Vocabulaire" . " " . get_the_terms(get_the_ID(), "thematiques")[0]->name,
]);
}
if ($block['blockName'] == 'homegrade-content-blocks/plus-loin') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => "#aller-plus-loin",
'title' => __("Pour aller plus loin", "homegrade-blocks__texte-fonctionnel"),
]);
if (!function_exists('build_share_urls')) {
function build_chapter_index($blocks)
{
$chapterBlockIndex = [];
foreach ($blocks as $key => $block) {
if ($block['blockName'] == 'homegrade-content-blocks/questions-container') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => '#questions-container-' . $block['attrs']['relatedPostId'],
'title' => get_the_title($block['attrs']['relatedPostId']),
]);
}
if ($block['blockName'] == 'homegrade-content-blocks/vocabulaire-summary') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => "#vocabulaire-summary",
'title' => "Vocabulaire" . " " . get_the_terms(get_the_ID(), "thematiques")[0]->name,
]);
}
if ($block['blockName'] == 'homegrade-content-blocks/plus-loin') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => "#aller-plus-loin",
'title' => __("Pour aller plus loin", "homegrade-blocks__texte-fonctionnel"),
]);
}
}
return $chapterBlockIndex;
}
return $chapterBlockIndex;
}
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
@ -80,8 +81,8 @@ function build_chapter_index($blocks)
$blocks = parse_blocks($post->post_content);
$chapterBlockIndex = build_chapter_index($blocks);
?>
<?php get_template_part('template-components/post-conseils/chapter-header', array(
'ID' => get_the_ID(),
<?php get_template_part('template-components/post-conseils/chapter-header', null, array(
'postID' => get_the_ID(),
)); ?>
<div class=" conseils_wrapper">
<aside class="chapter_index">

View File

@ -1,9 +1,9 @@
<?php
p<?php
/************/
/* PAGE FAQ */
/************/
?>
/************/
/* PAGE FAQ */
/************/
?>
<?php get_header(); ?>
@ -114,11 +114,7 @@ $relatedTaxQuestions = new WP_Query($query_args);
<?php endwhile ?>
<?php endif; ?>
</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>
<?php endif; ?>
<button id="load-more-questions"><?php echo __("Charger plus de questions", "homegrade-theme__texte-fonctionnel") ?></button>
</div>

View File

@ -37,7 +37,9 @@ $thematiquesTerms = get_terms(array(
<li class="term">
<a href="<?php echo get_term_link($thematique) ?>">
<img src="<?php echo $thematique_icon['url'] ?>" alt="">
<?php if ($thematique_icon) : ?>
<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>
</a>
</li>

View File

@ -18,7 +18,7 @@ $block_titling_datas = get_field('block_titling_datas');
));
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']);
get_template_part(

View File

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

View File

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

View File

@ -1,6 +1,7 @@
<?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_id_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
$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(
// 'fields' => 'ids',
@ -42,15 +43,23 @@ $relatedBrochure = get_field('brochure_pdf', $relatedBrochuresPosts[0]->ID) ?? n
<?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) : ?>
<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
get_template_part('template-components/post-infos-capsule', null, array(
"post_id" => $args['ID'],
"postID" => $args['postID'],
"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;
$lastUpdate = get_the_modified_date('', get_the_ID());
echo '<pre>';
print_r($questions->posts);
echo '</pre>';
?>