modifying api to handle brochure building based on user current language
This commit is contained in:
parent
d3d32cc51d
commit
d67b9c8291
|
|
@ -56,6 +56,11 @@ add_action('rest_api_init', function () {
|
|||
'methods' => 'GET',
|
||||
'callback' => 'build_brochure_archive_rows',
|
||||
'permission_callback' => '__return_true',
|
||||
'args' => array(
|
||||
'excluded_ids' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
),
|
||||
|
||||
));
|
||||
// * BUILD FICHE INFOS ARCHIVE ROWS
|
||||
|
|
@ -228,8 +233,12 @@ function build_news_posts_feed_per_type_id($request)
|
|||
return $response;
|
||||
}
|
||||
|
||||
function build_brochure_archive_rows()
|
||||
function build_brochure_archive_rows(WP_REST_Request $request)
|
||||
{
|
||||
$currentLanguage = $request->get_param('current-page-language') ?? 'fr';
|
||||
|
||||
do_action('wpml_switch_language', $currentLanguage);
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'brochures',
|
||||
'posts_per_page' => -1,
|
||||
|
|
@ -239,7 +248,6 @@ function build_brochure_archive_rows()
|
|||
'meta_key' => 'brochure_pdf',
|
||||
'meta_value' => '',
|
||||
'meta_compare' => '!=',
|
||||
// ICI METAQUERY FOR LE PDF
|
||||
);
|
||||
$brochuresPosts = new WP_Query($args);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user