From c00be423a83c7942d834f415a3f6f6a106815a1f Mon Sep 17 00:00:00 2001 From: Antoine M Date: Fri, 27 Oct 2023 17:08:59 +0200 Subject: [PATCH] debug fixing using debug log --- includes/api.php | 9 +++ includes/utilities.php | 6 +- page.php | 6 ++ .../css/components/post-infos-capsule.css | 50 ---------------- single-conseils.php | 57 ++++++++++--------- taxonomy-thematiques.php | 16 ++---- template-archive-questions.php | 4 +- .../home/latest-news/latest-news.php | 2 +- .../questions-frequentes.php | 10 ++-- template-components/cards/card-thematique.php | 6 +- .../post-conseils/chapter-header.php | 19 +++++-- .../posts-components/chapter-header.php | 4 +- 12 files changed, 80 insertions(+), 109 deletions(-) delete mode 100644 resources/css/components/post-infos-capsule.css diff --git a/includes/api.php b/includes/api.php index 282ffff..de6efc0 100644 --- a/includes/api.php +++ b/includes/api.php @@ -11,6 +11,7 @@ add_action('rest_api_init', function () { register_rest_route('homegrade-datas/v1', '/questions-thematiques/(?P\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\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\d+)', array( 'methods' => 'GET', 'callback' => 'build_news_posts_feed_per_type_id', + 'permission_callback' => '__return_true', + )); }); diff --git a/includes/utilities.php b/includes/utilities.php index cdde375..e131c46 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -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; } diff --git a/page.php b/page.php index 1318bf8..1ced569 100644 --- a/page.php +++ b/page.php @@ -1,4 +1,10 @@ +slug; + +?>
"> diff --git a/resources/css/components/post-infos-capsule.css b/resources/css/components/post-infos-capsule.css deleted file mode 100644 index c626abe..0000000 --- a/resources/css/components/post-infos-capsule.css +++ /dev/null @@ -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'); - } - } - } -} diff --git a/single-conseils.php b/single-conseils.php index d0c8a6b..2ffdc12 100644 --- a/single-conseils.php +++ b/single-conseils.php @@ -1,35 +1,36 @@ $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; } ?> - post_content); $chapterBlockIndex = build_chapter_index($blocks); ?> - get_the_ID(), + get_the_ID(), )); ?>
diff --git a/template-archive-questions.php b/template-archive-questions.php index f5f6d88..3d5e7b5 100644 --- a/template-archive-questions.php +++ b/template-archive-questions.php @@ -37,7 +37,9 @@ $thematiquesTerms = get_terms(array(
  • - + + +

    Question name ?>

  • diff --git a/template-blocks/home/latest-news/latest-news.php b/template-blocks/home/latest-news/latest-news.php index 7dd9551..693c86e 100644 --- a/template-blocks/home/latest-news/latest-news.php +++ b/template-blocks/home/latest-news/latest-news.php @@ -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( diff --git a/template-blocks/home/questions-frequentes/questions-frequentes.php b/template-blocks/home/questions-frequentes/questions-frequentes.php index a7a7e3c..bb13db6 100644 --- a/template-blocks/home/questions-frequentes/questions-frequentes.php +++ b/template-blocks/home/questions-frequentes/questions-frequentes.php @@ -18,20 +18,18 @@ $block_titling = get_field('block_titling_description_datas'); 'parent' => 0 )); - // echo '
    ';
    -		// print_r($thematique_terms);
    -		// echo '
    '; - // $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, diff --git a/template-components/cards/card-thematique.php b/template-components/cards/card-thematique.php index 34c24c1..1351ca7 100644 --- a/template-components/cards/card-thematique.php +++ b/template-components/cards/card-thematique.php @@ -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); ?>
    - + + +

    name ?>

    description ?>

    diff --git a/template-components/post-conseils/chapter-header.php b/template-components/post-conseils/chapter-header.php index 837bd9d..9ccd97b 100644 --- a/template-components/post-conseils/chapter-header.php +++ b/template-components/post-conseils/chapter-header.php @@ -1,6 +1,7 @@ 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 -

    +

    - Télécharger la brochure post_title ?> + '; + // print_r($relatedBrochure); + // echo ''; + ?> + + $args['ID'], + "postID" => $args['postID'], "modified" => $lastUpdate )); ?> diff --git a/template-components/posts-components/chapter-header.php b/template-components/posts-components/chapter-header.php index 8bcb234..7da7116 100644 --- a/template-components/posts-components/chapter-header.php +++ b/template-components/posts-components/chapter-header.php @@ -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 '
    ';
    -print_r($questions->posts);
    -echo '
    '; + ?>