181 lines
3.8 KiB
PHP
181 lines
3.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
FORMS FIELDS
|
|
|
|
0: "engagement"
|
|
1: "fichier"
|
|
2: "liste_des_depenses"
|
|
3: "montant_demande"
|
|
4: "recettes_prevues"
|
|
5: "depenses_prevues"
|
|
6: "participation"
|
|
7: "plan_de_communication"
|
|
8: "composition_autres"
|
|
9: "composition_4"
|
|
10: "composition_3"
|
|
11: "composition_2"
|
|
12: "composition_1"
|
|
13: "composition"
|
|
14: "resultats_attendus"
|
|
15: "public_vise"
|
|
16: "activite_concerne"
|
|
17: "description_longue"
|
|
18: "description_courte"
|
|
--- 19: "categorie"
|
|
20: "se_connecter"
|
|
21: "lien_internet"
|
|
22: "adresse_courriel_de_contact"
|
|
--- 23: "heure_de_fin"
|
|
--- 24: "heure_de_debut"
|
|
--- 25: "date"
|
|
26: "map"
|
|
--- 27: "pays"
|
|
--- 28: "ville"
|
|
--- 29: "adresse"
|
|
30: "mode"
|
|
31: "fonction"
|
|
32: "institution"
|
|
33: "telephone"
|
|
34: "adresse_courriel"
|
|
--- 35: "prenom"
|
|
--- 36: "nom"
|
|
|
|
ADDED BY THIS PLUGIN
|
|
|
|
--- 37: "coordinates"
|
|
--- 38: "coordinates_valid"
|
|
*/
|
|
|
|
/*
|
|
GET POST EXEMPLE :
|
|
|
|
ID: 29693
|
|
comment_count: "0"
|
|
comment_status: "closed"
|
|
filter: "raw"
|
|
guid: "https://local_lejourduprof.com/?p=29693"
|
|
menu_order: 0
|
|
ping_status: "closed"
|
|
pinged: ""
|
|
post_author: "1"
|
|
post_content: ""
|
|
post_content_filtered: ""
|
|
post_date: "2022-11-04 18:05:49"
|
|
post_date_gmt: "2022-11-04 17:05:49"
|
|
post_excerpt: "Les enseignants vont présenter les projets développés dans leurs classes et partager leurs pratiques et expériences."
|
|
post_mime_type: ""
|
|
post_modified: "2022-11-05 09:39:46"
|
|
post_modified_gmt: "2022-11-05 08:39:46"
|
|
post_name: "construisons-ensemble-lavenir"
|
|
post_parent: 0
|
|
post_password: ""
|
|
post_status: "draft"
|
|
post_title: "Construisons ensemble l'avenir"
|
|
post_type: "post"
|
|
to_ping: ""
|
|
*/
|
|
|
|
// FUNCTION TO RETRIEVE FORMS FIELDS
|
|
// not used anymore
|
|
//
|
|
//function mp_get_form_fields() {
|
|
// $get_form_args = array(
|
|
// 'numberposts' => -1,
|
|
// 'post_status' => 'publish',
|
|
// 'post_type' => 'acf-field',
|
|
// );
|
|
// $forms = get_posts($get_form_args);
|
|
// $fields = [];
|
|
// foreach ($forms as $form) {
|
|
// $field = $form->post_excerpt;
|
|
// array_push($fields, $field);
|
|
// }
|
|
// return $fields;
|
|
//}
|
|
|
|
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) {
|
|
// //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,
|
|
'post_status' => 'publish',
|
|
//'post_status' => 'draft',
|
|
'post_type' => 'post',
|
|
);
|
|
$posts_published = get_posts($get_posts_args);
|
|
|
|
return $posts_published;
|
|
}
|
|
|
|
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
|
|
$fields = array(
|
|
"heure_de_debut",
|
|
"heure_de_fin",
|
|
"categorie",
|
|
"date",
|
|
"pays",
|
|
"ville",
|
|
"adresse",
|
|
"prenom",
|
|
"nom",
|
|
"coordinates",
|
|
"coordinates_valid",
|
|
);
|
|
$event = (object)[];
|
|
foreach($fields as $field) {
|
|
$event->$field = get_field($field, $id);
|
|
}
|
|
|
|
// add mode irl or online (irl: true | false)
|
|
$presentiel = get_field("mode", $id);
|
|
$event->irl = false;
|
|
if ($presentiel[0] === "En présentiel")
|
|
$event->irl = true;
|
|
|
|
return $event;
|
|
}
|
|
|
|
function mp_get_published_events() {
|
|
$posts_list = mp_get_published_posts();
|
|
$events = [];
|
|
foreach ($posts_list as $post) {
|
|
$event->id = $post->ID;
|
|
$event->title = $post->post_title;
|
|
$event = mp_fill_fields_value($post->ID);
|
|
array_push($events, $event);
|
|
}
|
|
return $events;
|
|
}
|
|
|
|
?>
|