From a50612cd58c05676569f08101994834ef48d2488 Mon Sep 17 00:00:00 2001 From: Nonimart Date: Fri, 13 Jun 2025 16:04:32 +0200 Subject: [PATCH] REFACTOR Renaming and deleting unused lines --- includes/api.php | 49 +++++------------------------------------------- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/includes/api.php b/includes/api.php index b869b83..dbfb535 100644 --- a/includes/api.php +++ b/includes/api.php @@ -7,18 +7,13 @@ add_action('rest_api_init', function () { -----------------*/ // ################ BUILD ARTISANS SEARCH RESULTS ################ - - // * BUILD MORE NEWS CARDS register_rest_route('metiers-patrimoine-datas/v1/build', '/artisans', array( 'methods' => 'GET', 'callback' => 'build_search_artisan_posts_cards', 'permission_callback' => '__return_true', )); -}); -// ################ ARTISANS ################ - function build_search_artisan_posts_cards($request) { @@ -66,10 +61,10 @@ function build_search_artisan_posts_cards($request) "meta_query" => $metaQuery, 's' => $search_value, ); - $newsPostsDatas = new WP_Query($args); + $searchArtisans = new WP_Query($args); ob_start(); - foreach ($newsPostsDatas->posts as $key => $post) { + foreach ($searchArtisans->posts as $key => $post) { // continue en fonction $post_thumbnail = get_the_post_thumbnail($post->ID, 'full', array('class' => 'card-artisans__thumbnail')) ?? null; @@ -94,7 +89,7 @@ function build_search_artisan_posts_cards($request) $html_template = ob_get_clean(); - if ($newsPostsDatas->found_posts === 0) { + if ($searchArtisans->found_posts === 0) { ob_start(); get_template_part( 'template-components/artisans/artisan-search-no-results', @@ -105,49 +100,15 @@ function build_search_artisan_posts_cards($request) } $response_data = array( 'html_template' => $html_template, - 'total_posts_found' => $newsPostsDatas->found_posts, + 'total_posts_found' => $searchArtisans->found_posts, 'active_page' => $activePage, - 'max_num_pages' => $newsPostsDatas->max_num_pages, + 'max_num_pages' => $searchArtisans->max_num_pages, ); $response = new WP_REST_Response($response_data); $response->set_status(200); - // debugQueryTest( ); return $response; } - -function debugQueryTest() -{ - - $args = array( - "post_status" => "publish", - "post_type" => "artisans", - "posts_per_page" => -1, - // "tax_query" => $taxQuery, - // "meta_query" => $metaQuery, - 's' => "Atelier Schrauwen", - ); - $newsPostsDatas = new WP_Query($args); - $filteredPosts = []; - - - - - - do_action('wpml_switch_language', 'nl'); - ob_start(); - get_template_part( - 'template-components/artisans/artisan-search-no-results', - null, - [] - ); - $html_template = ob_get_clean(); - $test = __("Aucun résultat trouvé", "metiers-patrimoine-theme"); - return ($html_template); -} -// debugQueryTest(); - -// add_action('wp_footer', 'debugQueryTest');