ccreation of filter country sorted and unique

This commit is contained in:
lenovo
2022-11-09 22:09:23 +01:00
parent 7af3572eaa
commit 4e7fa55234
2 changed files with 23 additions and 20 deletions

View File

@@ -99,20 +99,20 @@ function mp_get_published_posts() {
// FOR TESTS // FOR TESTS
// script to publish or unpublish posts // script to publish or unpublish posts
// //
$post_args = array( // $post_args = array(
'numberposts' => -1, // 'numberposts' => -1,
'post_status' => 'draft', // 'post_status' => 'draft',
//'post_status' => 'publish', // //'post_status' => 'publish',
'post_type' => 'post', // 'post_type' => 'post',
); // );
$post_list = get_posts($post_args); // $post_list = get_posts($post_args);
foreach ($post_list as $post) { // foreach ($post_list as $post) {
wp_update_post(array( // wp_update_post(array(
'ID' => $post->ID, // 'ID' => $post->ID,
//'post_status' => 'draft', // //'post_status' => 'draft',
'post_status' => 'publish', // 'post_status' => 'publish',
)); // ));
}; // };
$get_posts_args = array( $get_posts_args = array(
'numberposts' => -1, 'numberposts' => -1,

View File

@@ -8,18 +8,21 @@ function mp_add_filters(&$filter, $value) {
if (strlen($value) == 0) if (strlen($value) == 0)
return; return;
$value = trim($value, " "); $value = trim($value, " ");
//mp_filter_insert_sort($filter, $value);
array_push($filter, $value); array_push($filter, $value);
$filter = array_unique($filter);
sort($filter);
} }
function mp_get_filters($locations, $filters_fields) { function mp_get_filters($locations) {
$filters = (object)[]; $filters = (object)[];
$filters->pays = []; $filters->country = [];
$filters->ville = []; $filters->city = [];
$filters->categorie = []; $filters->category = [];
foreach ($locations as $loc) { foreach ($locations as $loc) {
$location = $loc->events[0]->location; $country = $loc->events[0]->location->country;
mp_add_filters($filters->$field, $event->$field); mp_add_filters($filters->country, $country);
} }
mp_console_log("filters:"); mp_console_log("filters:");