handle current language publication sorting with load more and filter

This commit is contained in:
Antoine M 2023-11-29 09:57:48 +01:00
parent 772c481cce
commit 867a565e5a
2 changed files with 10 additions and 8 deletions

View File

@ -56,12 +56,6 @@ add_action('rest_api_init', function () {
'methods' => 'GET', 'methods' => 'GET',
'callback' => 'build_brochure_archive_rows', 'callback' => 'build_brochure_archive_rows',
'permission_callback' => '__return_true', 'permission_callback' => '__return_true',
'args' => array(
'excluded_ids' => array(
'sanitize_callback' => 'sanitize_text_field',
),
),
)); ));
// * BUILD FICHE INFOS ARCHIVE ROWS // * BUILD FICHE INFOS ARCHIVE ROWS
register_rest_route('homegrade-datas/v1/build', '/fiche-info-archive-rows', array( register_rest_route('homegrade-datas/v1/build', '/fiche-info-archive-rows', array(
@ -274,8 +268,12 @@ function build_brochure_archive_rows(WP_REST_Request $request)
return $response; return $response;
} }
function build_fiches_info_archive_rows() function build_fiches_info_archive_rows(WP_REST_Request $request)
{ {
$currentLanguage = $request->get_param('current-page-language') ?? 'fr';
do_action('wpml_switch_language', $currentLanguage);
$args = array( $args = array(
'post_type' => 'fiches-infos', 'post_type' => 'fiches-infos',
'posts_per_page' => -1, 'posts_per_page' => -1,

View File

@ -87,7 +87,11 @@ async function hydrateBrochureArchiveGrid() {
} }
async function hydrateFicheInfoArchiveGrid() { async function hydrateFicheInfoArchiveGrid() {
const response = await fetch(`/wp-json/homegrade-datas/v1/build/fiche-info-archive-rows`); const currentLanguage = document.querySelector('body').getAttribute('current-language');
const response = await fetch(
`/wp-json/homegrade-datas/v1/build/fiche-info-archive-rows?current-page-language=${currentLanguage}`
);
ficheInfosDatas = await response.json(); ficheInfosDatas = await response.json();
const ficheInfoRows = document.querySelector('.fiches-infos-archives #fiche-infos-rows'); const ficheInfoRows = document.querySelector('.fiches-infos-archives #fiche-infos-rows');