REFACTOR Renaming and deleting unused lines
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5e24ce4c88
commit
a50612cd58
|
|
@ -7,18 +7,13 @@ add_action('rest_api_init', function () {
|
||||||
-----------------*/
|
-----------------*/
|
||||||
|
|
||||||
// ################ BUILD ARTISANS SEARCH RESULTS ################
|
// ################ BUILD ARTISANS SEARCH RESULTS ################
|
||||||
|
|
||||||
// * BUILD MORE NEWS CARDS
|
|
||||||
register_rest_route('metiers-patrimoine-datas/v1/build', '/artisans', array(
|
register_rest_route('metiers-patrimoine-datas/v1/build', '/artisans', array(
|
||||||
'methods' => 'GET',
|
'methods' => 'GET',
|
||||||
'callback' => 'build_search_artisan_posts_cards',
|
'callback' => 'build_search_artisan_posts_cards',
|
||||||
'permission_callback' => '__return_true',
|
'permission_callback' => '__return_true',
|
||||||
));
|
));
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// ################ ARTISANS ################
|
|
||||||
|
|
||||||
|
|
||||||
function build_search_artisan_posts_cards($request)
|
function build_search_artisan_posts_cards($request)
|
||||||
{
|
{
|
||||||
|
|
@ -66,10 +61,10 @@ function build_search_artisan_posts_cards($request)
|
||||||
"meta_query" => $metaQuery,
|
"meta_query" => $metaQuery,
|
||||||
's' => $search_value,
|
's' => $search_value,
|
||||||
);
|
);
|
||||||
$newsPostsDatas = new WP_Query($args);
|
$searchArtisans = new WP_Query($args);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
foreach ($newsPostsDatas->posts as $key => $post) {
|
foreach ($searchArtisans->posts as $key => $post) {
|
||||||
|
|
||||||
// continue en fonction
|
// continue en fonction
|
||||||
$post_thumbnail = get_the_post_thumbnail($post->ID, 'full', array('class' => 'card-artisans__thumbnail')) ?? null;
|
$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();
|
$html_template = ob_get_clean();
|
||||||
|
|
||||||
|
|
||||||
if ($newsPostsDatas->found_posts === 0) {
|
if ($searchArtisans->found_posts === 0) {
|
||||||
ob_start();
|
ob_start();
|
||||||
get_template_part(
|
get_template_part(
|
||||||
'template-components/artisans/artisan-search-no-results',
|
'template-components/artisans/artisan-search-no-results',
|
||||||
|
|
@ -105,49 +100,15 @@ function build_search_artisan_posts_cards($request)
|
||||||
}
|
}
|
||||||
$response_data = array(
|
$response_data = array(
|
||||||
'html_template' => $html_template,
|
'html_template' => $html_template,
|
||||||
'total_posts_found' => $newsPostsDatas->found_posts,
|
'total_posts_found' => $searchArtisans->found_posts,
|
||||||
'active_page' => $activePage,
|
'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 = new WP_REST_Response($response_data);
|
||||||
|
|
||||||
$response->set_status(200);
|
$response->set_status(200);
|
||||||
// debugQueryTest( );
|
|
||||||
return $response;
|
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');
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user