From 4e7fa552349c5c79fbc0e4b97f358f045ab3a219 Mon Sep 17 00:00:00 2001 From: lenovo Date: Wed, 9 Nov 2022 22:09:23 +0100 Subject: [PATCH] ccreation of filter country sorted and unique --- srcs/plugins/map_prof/mp_get_events.php | 28 ++++++++++++------------ srcs/plugins/map_prof/mp_get_filters.php | 15 ++++++++----- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/srcs/plugins/map_prof/mp_get_events.php b/srcs/plugins/map_prof/mp_get_events.php index 08231d2..4def814 100644 --- a/srcs/plugins/map_prof/mp_get_events.php +++ b/srcs/plugins/map_prof/mp_get_events.php @@ -99,20 +99,20 @@ function mp_get_published_posts() { // FOR TESTS // script to publish or unpublish posts // - $post_args = array( - 'numberposts' => -1, - 'post_status' => 'draft', - //'post_status' => 'publish', - 'post_type' => 'post', - ); - $post_list = get_posts($post_args); - foreach ($post_list as $post) { - wp_update_post(array( - 'ID' => $post->ID, - //'post_status' => 'draft', - 'post_status' => 'publish', - )); - }; +// $post_args = array( +// 'numberposts' => -1, +// 'post_status' => 'draft', +// //'post_status' => 'publish', +// 'post_type' => 'post', +// ); +// $post_list = get_posts($post_args); +// foreach ($post_list as $post) { +// wp_update_post(array( +// 'ID' => $post->ID, +// //'post_status' => 'draft', +// 'post_status' => 'publish', +// )); +// }; $get_posts_args = array( 'numberposts' => -1, diff --git a/srcs/plugins/map_prof/mp_get_filters.php b/srcs/plugins/map_prof/mp_get_filters.php index 3dc21f9..7bb1d25 100644 --- a/srcs/plugins/map_prof/mp_get_filters.php +++ b/srcs/plugins/map_prof/mp_get_filters.php @@ -8,18 +8,21 @@ function mp_add_filters(&$filter, $value) { if (strlen($value) == 0) return; $value = trim($value, " "); + //mp_filter_insert_sort($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->pays = []; - $filters->ville = []; - $filters->categorie = []; + $filters->country = []; + $filters->city = []; + $filters->category = []; foreach ($locations as $loc) { - $location = $loc->events[0]->location; - mp_add_filters($filters->$field, $event->$field); + $country = $loc->events[0]->location->country; + mp_add_filters($filters->country, $country); } mp_console_log("filters:");