From 7d2ed53b442e7857fc654e4f6b7a0ea4aff2708a Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 5 Dec 2024 15:33:33 +0100 Subject: [PATCH] testing translations --- includes/api.php | 71 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/includes/api.php b/includes/api.php index 2190863..f4c15d9 100644 --- a/includes/api.php +++ b/includes/api.php @@ -1,6 +1,5 @@ get_param('current-page-language')) ?? 'fr'; @@ -29,6 +29,9 @@ function build_search_artisan_posts_cards($request) $localisation = esc_html($request->get_param('localisation')) ?? null; $StringifiedTaxonomyIds = esc_html($request->get_param('taxonomy-ids')) ?? null; + do_action('wpml_switch_language', $currentLanguage); + $test = __("Aucun résultat trouvé", "metiers-patrimoine-theme"); + $lang = apply_filters('wpml_current_language', null); $taxonomyIds = explode(',', $StringifiedTaxonomyIds); $taxonomyIds = array_map('intval', $taxonomyIds); $search_value = sanitize_text_field($request->get_param('search')) ?? null; @@ -54,7 +57,7 @@ function build_search_artisan_posts_cards($request) ); } - do_action('wpml_switch_language', $currentLanguage); + $args = array( "status" => "publish", @@ -93,10 +96,19 @@ function build_search_artisan_posts_cards($request) $html_template = ob_get_clean(); + ob_start(); + echo __("test pour gilles", "metiers-patrimoine-theme"); + + get_template_part( + 'template-components/artisans/artisan-search-no-results', + null, + [] + ); + $html_template = ob_get_clean(); + if ($newsPostsDatas->found_posts === 0) { - $html_template = "

" . __("Aucun résultat trouvé", "metiers-patrimoine-theme") . "

" . __("Essayez d'ajouter un filtre supplémentaire pour trouver plus de résultats", "metiers-patrimoine-theme") . "

"; } $response_data = array( 'html_template' => $html_template, @@ -109,13 +121,14 @@ function build_search_artisan_posts_cards($request) $response = new WP_REST_Response($response_data); $response->set_status(200); - + // debugQueryTest( ); return $response; } function debugQueryTest() { + $args = array( "status" => "publish", "post_type" => "artisans", @@ -128,11 +141,55 @@ function debugQueryTest() $filteredPosts = []; foreach ($newsPostsDatas as $post => $value) { - $persons = get_field('company_members', $value->ID); - write_log($persons); + // $persons = get_field('company_members', $value->ID); + // write_log($persons); } - write_log($newsPostsDatas->posts); + // write_log($newsPostsDatas->posts); + + + + 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"); + // write_log($test); + return ($html_template); } // debugQueryTest(); + +add_action('wp_footer', 'debugQueryTest'); + + + + + +add_action('rest_api_init', function () { + register_rest_route('metiers-patrimoine-datas/v1/build', '/test', array( + 'methods' => 'GET', + 'callback' => 'handle_rest_callback_metiers', + )); +}); + +function handle_rest_callback_metiers() +{ + do_action('wpml_switch_language', 'nl'); + + ob_start(); + get_template_part( + 'template-components/artisans/artisan-search-no-results', + null, + [] + ); + $html_template = ob_get_clean(); + + return array( + 'html_template' => $html_template, + ); +}