new locations array organisation
This commit is contained in:
@@ -40,6 +40,11 @@
|
||||
34: "adresse_courriel"
|
||||
--- 35: "prenom"
|
||||
--- 36: "nom"
|
||||
|
||||
ADDED BY THIS PLUGIN
|
||||
|
||||
--- 37: "coordinates"
|
||||
--- 38: "coordinates_valid"
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -102,12 +107,14 @@ function mp_get_published_posts() {
|
||||
// );
|
||||
// $post_list = get_posts($post_args);
|
||||
// foreach ($post_list as $post) {
|
||||
// wp_update_post(array(
|
||||
// 'ID' => $post->ID,
|
||||
// //'post_status' => 'draft',
|
||||
// 'post_status' => 'publish',
|
||||
// ));
|
||||
// }
|
||||
// //if ( get_field("nom", $post->ID) == "Rakhimov") {
|
||||
// wp_update_post(array(
|
||||
// 'ID' => $post->ID,
|
||||
// //'post_status' => 'draft',
|
||||
// 'post_status' => 'publish',
|
||||
// ));
|
||||
// //};
|
||||
// };
|
||||
|
||||
$get_posts_args = array(
|
||||
'numberposts' => -1,
|
||||
@@ -126,6 +133,8 @@ function mp_fill_fields_value($id) {
|
||||
* get_field is an ACF function
|
||||
* in "pure" worpdress use :
|
||||
* get_post_meta or get_post_custom_values
|
||||
* - https://developer.wordpress.org/reference/functions/get_post_meta/
|
||||
* - https://developer.wordpress.org/reference/functions/get_post_custom_values/
|
||||
*/
|
||||
|
||||
// add fields
|
||||
@@ -140,6 +149,7 @@ function mp_fill_fields_value($id) {
|
||||
"prenom",
|
||||
"nom",
|
||||
"coordinates",
|
||||
"coordinates_valid",
|
||||
);
|
||||
$event = (object)[];
|
||||
foreach($fields as $field) {
|
||||
@@ -162,14 +172,8 @@ function mp_get_published_events() {
|
||||
$event->id = $post->ID;
|
||||
$event->title = $post->post_title;
|
||||
$event = mp_fill_fields_value($post->ID);
|
||||
// only add to array if address is complete
|
||||
if ( isset($event->coordinates) )
|
||||
array_push($events, $event);
|
||||
else
|
||||
mp_console_log("event address incomplete:");
|
||||
mp_console_log($event);
|
||||
array_push($events, $event);
|
||||
}
|
||||
mp_console_log($events);
|
||||
return $events;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user