testing translations
This commit is contained in:
parent
fae6da0935
commit
7d2ed53b44
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
add_action('rest_api_init', function () {
|
add_action('rest_api_init', function () {
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
|
|
@ -20,6 +19,7 @@ add_action('rest_api_init', function () {
|
||||||
|
|
||||||
// ################ ARTISANS ################
|
// ################ ARTISANS ################
|
||||||
|
|
||||||
|
|
||||||
function build_search_artisan_posts_cards($request)
|
function build_search_artisan_posts_cards($request)
|
||||||
{
|
{
|
||||||
$currentLanguage = esc_html($request->get_param('current-page-language')) ?? 'fr';
|
$currentLanguage = esc_html($request->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;
|
$localisation = esc_html($request->get_param('localisation')) ?? null;
|
||||||
$StringifiedTaxonomyIds = esc_html($request->get_param('taxonomy-ids')) ?? 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 = explode(',', $StringifiedTaxonomyIds);
|
||||||
$taxonomyIds = array_map('intval', $taxonomyIds);
|
$taxonomyIds = array_map('intval', $taxonomyIds);
|
||||||
$search_value = sanitize_text_field($request->get_param('search')) ?? null;
|
$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(
|
$args = array(
|
||||||
"status" => "publish",
|
"status" => "publish",
|
||||||
|
|
@ -93,10 +96,19 @@ function build_search_artisan_posts_cards($request)
|
||||||
|
|
||||||
$html_template = ob_get_clean();
|
$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) {
|
if ($newsPostsDatas->found_posts === 0) {
|
||||||
$html_template = "<div class='no-results'><img class='no-results__cover' src='" . get_stylesheet_directory_uri() . "/resources/img/illustrations/Homegrade_resultats-filtres-cactus.svg' alt=''/><h3>" . __("Aucun résultat trouvé", "metiers-patrimoine-theme") . "</h3><p>" . __("Essayez d'ajouter un <span class='highlighted-purple'>filtre supplémentaire</span> pour trouver plus de résultats", "metiers-patrimoine-theme") . "</p></div>";
|
|
||||||
}
|
}
|
||||||
$response_data = array(
|
$response_data = array(
|
||||||
'html_template' => $html_template,
|
'html_template' => $html_template,
|
||||||
|
|
@ -109,13 +121,14 @@ function build_search_artisan_posts_cards($request)
|
||||||
$response = new WP_REST_Response($response_data);
|
$response = new WP_REST_Response($response_data);
|
||||||
|
|
||||||
$response->set_status(200);
|
$response->set_status(200);
|
||||||
|
// debugQueryTest( );
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function debugQueryTest()
|
function debugQueryTest()
|
||||||
{
|
{
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
"status" => "publish",
|
"status" => "publish",
|
||||||
"post_type" => "artisans",
|
"post_type" => "artisans",
|
||||||
|
|
@ -128,11 +141,55 @@ function debugQueryTest()
|
||||||
$filteredPosts = [];
|
$filteredPosts = [];
|
||||||
|
|
||||||
foreach ($newsPostsDatas as $post => $value) {
|
foreach ($newsPostsDatas as $post => $value) {
|
||||||
$persons = get_field('company_members', $value->ID);
|
// $persons = get_field('company_members', $value->ID);
|
||||||
write_log($persons);
|
// 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();
|
// 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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user