mv map_prof plugin inside plugins container
This commit is contained in:
96
plugins/map_prof/srcs/errors/mp_address_errors.php
Normal file
96
plugins/map_prof/srcs/errors/mp_address_errors.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
function mp_is_precise($post, $id, $location) {
|
||||
|
||||
// is presentiel but not complete address ?
|
||||
$presentiel = get_field("mode", $id);
|
||||
if ($presentiel[0] === "En présentiel") {
|
||||
if ($location->approximate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function mp_is_address_complete($post, $id, $location) {
|
||||
|
||||
// is presentiel but not complete address ?
|
||||
$presentiel = get_field("mode", $id);
|
||||
if ($presentiel[0] === "En présentiel") {
|
||||
if (strlen($location->street) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (strlen($location->city) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function mp_is_valid_address($post, $id, $location) {
|
||||
|
||||
// is coordinates ?
|
||||
if ($location->coordinates == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function mp_fill_address_message($post, $id, $location) {
|
||||
|
||||
$message = '<br /><p>article : "'
|
||||
. $post->post_title . '"</p><p>- adresse fournie : "'
|
||||
. get_field('adresse', $id) . ', '
|
||||
. get_field('ville', $id) . ', '
|
||||
. get_field('pays', $id)
|
||||
. '"</p><p>- adresse trouvée : "'
|
||||
. $location->address
|
||||
. '"</p>';
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
function mp_find_address_errors() {
|
||||
|
||||
$errors = "";
|
||||
$incompletes = "";
|
||||
$approximates = "";
|
||||
$count_errors = 0;
|
||||
$count_incompletes = 0;
|
||||
$count_approximates = 0;
|
||||
|
||||
$get_posts_args = array(
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'post',
|
||||
);
|
||||
$posts = get_posts($get_posts_args);
|
||||
foreach ($posts as $post) {
|
||||
$id = $post->ID;
|
||||
$location = get_field('location', $id);
|
||||
if (! mp_is_valid_address($post, $id, $location)) {
|
||||
$count_errors++;
|
||||
$errors .= mp_fill_address_message($post, $id, $location);
|
||||
}
|
||||
// else if (! mp_is_address_complete($post, $id, $location)) {
|
||||
// $count_incompletes++;
|
||||
// $incompletes .= mp_fill_address_message($post, $id, $location);
|
||||
// }
|
||||
else if (! mp_is_precise($post, $id, $location)) {
|
||||
$count_approximates++;
|
||||
$approximates .= mp_fill_address_message($post, $id, $location);
|
||||
}
|
||||
}
|
||||
$message = "<h2>nombre d'erreurs : " . $count_errors . "</h2>";
|
||||
// $message .= "<h2>nombre d'adresses incompletes pour des evenements en presentiels : " . $count_incompletes . "</h2>";
|
||||
$message .= "<h2>nombre d'adresses approximatives pour des evenements en presentiels : " . $count_approximates . "</h2>";
|
||||
$message .= "<br /><h2>erreurs :</h2>" . $errors;
|
||||
// $message .= "<br /><h2>adresses incompletes:</h2>" . $incompletes;
|
||||
$message .= "<br /><h2>approximatives :</h2>" . $approximates;
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
?>
|
||||
34
plugins/map_prof/srcs/map/mp_add_to_scripts.php
Normal file
34
plugins/map_prof/srcs/map/mp_add_to_scripts.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
function mp_php_to_js($php_var, $js_var_name) {
|
||||
$js_var = 'let ' . $js_var_name . ' = ';
|
||||
$js_var .= json_encode($php_var);
|
||||
$js_var .= ';';
|
||||
return $js_var;
|
||||
}
|
||||
|
||||
function mp_add_to_scripts($to_add) {
|
||||
global $mp_icon_size;
|
||||
global $mp_icon_color;
|
||||
global $mp_icon_color_back;
|
||||
global $mp_icon_size_factor;
|
||||
global $mp_zoom;
|
||||
global $mp_coordinates_default;
|
||||
global $mp_icon_stroke_width;
|
||||
global $mp_max_zoom;
|
||||
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_size, 'icon_size'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_color, 'icon_color'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_color_back, 'icon_color_back'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_size_factor, 'icon_size_factor'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_zoom, 'map_zoom'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_coordinates_default, 'coordinates_default'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_stroke_width, 'icon_stroke_width'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_max_zoom, 'max_zoom'), 'before');
|
||||
|
||||
foreach ($to_add as $key => $var) {
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($var, $key), 'before');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
135
plugins/map_prof/srcs/map/mp_create_div.php
Normal file
135
plugins/map_prof/srcs/map/mp_create_div.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
function mp_filter_drop_down($key, &$filter) {
|
||||
/*
|
||||
onfocusin="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
|
||||
onclick="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
|
||||
onfocus="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
|
||||
onclick="filter_show_only_selection(this, '.json_encode(array()).', '."'".$key."'".')"
|
||||
onchange="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
|
||||
|
||||
onchange="filter_show_only_selection(this, '.json_encode(array()).', '."'".$key."'".')"
|
||||
onchange="filter_event(this, this.options[this.selectedIndex], \''.$key.'\')"
|
||||
*/
|
||||
$menu_name_class = 'filter_menu_'.str_replace(" ", "_", $key).'';
|
||||
$id = "filter_"
|
||||
. $key
|
||||
. "_"
|
||||
. $key
|
||||
;
|
||||
$content = '
|
||||
<select
|
||||
form="ljdp_form"
|
||||
class="filter_menu filter_menu_drop"
|
||||
onchange="filter_show_only(this.options[this.selectedIndex], \''.$key.'\')"
|
||||
>
|
||||
<option
|
||||
selected
|
||||
id="'.$id.'"
|
||||
class="filter_menu_item '.$menu_name_class.'"
|
||||
data-menu_index="menu_name"
|
||||
>
|
||||
'.$key.'
|
||||
</option>
|
||||
';
|
||||
foreach ($filter as $key_filter => $value) {
|
||||
$id = "filter_"
|
||||
. $key
|
||||
. "_"
|
||||
. str_replace( " ", "_", $value->_name)
|
||||
;
|
||||
$content .= '
|
||||
<option
|
||||
id="'.$id.'"
|
||||
class="filter_menu_item '.$menu_name_class.'"
|
||||
data-menu_index="'.$key_filter.'"
|
||||
>
|
||||
'.$value->_name.'
|
||||
</option>
|
||||
';
|
||||
}
|
||||
$content .= '
|
||||
</select>
|
||||
';
|
||||
|
||||
return $content;
|
||||
};
|
||||
|
||||
function mp_filter_buttons($key, &$filter) {
|
||||
|
||||
/*
|
||||
onclick="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".', true)"
|
||||
*/
|
||||
$menu_name_class = 'filter_menu_'.str_replace(" ", "_", $key).'';
|
||||
$content = '';
|
||||
foreach ($filter as $key_filter => $value) {
|
||||
$id = "filter_"
|
||||
. $key
|
||||
. "_"
|
||||
. str_replace( " ", "_", $value->_name)
|
||||
;
|
||||
$content .= '
|
||||
<input
|
||||
type="checkbox"
|
||||
form="ljdp_form"
|
||||
id="'.$id.'"
|
||||
class="filter_menu_checkbox filter_menu_item '.$menu_name_class.'"
|
||||
onclick="filter_show_only(this, \''.$key.'\')"
|
||||
style="display:none;"
|
||||
data-menu_index="'.$key_filter.'",
|
||||
>
|
||||
<label
|
||||
for="'.$id.'"
|
||||
class="filter_menu filter_menu_checkbox"
|
||||
>
|
||||
<p>'.$value->_name.'</p>
|
||||
</label>
|
||||
';
|
||||
}
|
||||
|
||||
return $content;
|
||||
};
|
||||
|
||||
function mp_create_div(&$filters) {
|
||||
$mp_map_div = '
|
||||
<div id="ljdp_map_wrapper">
|
||||
<form id="ljdp_form" style="display:none;"></form>
|
||||
<div id="ljdp_map_filters">
|
||||
';
|
||||
|
||||
foreach ($filters as $key => $filter) {
|
||||
|
||||
if ($key == "mode")
|
||||
$mp_map_div .= mp_filter_buttons($key, $filter);
|
||||
else
|
||||
$mp_map_div .= mp_filter_drop_down($key, $filter);
|
||||
};
|
||||
|
||||
$mp_map_div .= '
|
||||
<input
|
||||
type="reset"
|
||||
form="ljdp_form"
|
||||
id="filter_menu_reset"
|
||||
class="filter_menu_button"
|
||||
onclick="filter_show_all()"
|
||||
style="display:none;"
|
||||
>
|
||||
<label
|
||||
for="filter_menu_reset"
|
||||
class="filter_menu filter_menu_reset"
|
||||
>
|
||||
<p>Effacer</p>
|
||||
</label>
|
||||
';
|
||||
|
||||
$mp_map_div .= '
|
||||
</div>
|
||||
<div id="ljdp_map"></div>
|
||||
</div>
|
||||
';
|
||||
|
||||
return $mp_map_div;
|
||||
};
|
||||
|
||||
|
||||
?>
|
||||
196
plugins/map_prof/srcs/map/mp_get_events.php
Normal file
196
plugins/map_prof/srcs/map/mp_get_events.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
GET_POST :
|
||||
|
||||
1 ID: 29693
|
||||
2 comment_count: "0"
|
||||
3 comment_status: "closed"
|
||||
4 filter: "raw"
|
||||
5 guid: "https://local_lejourduprof.com/?p=29693"
|
||||
6 menu_order: 0
|
||||
7 ping_status: "closed"
|
||||
8 pinged: ""
|
||||
9 post_author: "1"
|
||||
10 post_content: ""
|
||||
11 post_content_filtered: ""
|
||||
12 post_date: "2022-11-04 18:05:49"
|
||||
13 post_date_gmt: "2022-11-04 17:05:49"
|
||||
14 post_excerpt: "Les enseignants vont présenter les projets développés dans leurs classes et partager leurs pratiques et expériences."
|
||||
15 post_mime_type: ""
|
||||
16 post_modified: "2022-11-05 09:39:46"
|
||||
17 post_modified_gmt: "2022-11-05 08:39:46"
|
||||
18 post_name: "construisons-ensemble-lavenir"
|
||||
19 post_parent: 0
|
||||
20 post_password: ""
|
||||
21 post_status: "draft"
|
||||
22 post_title: "Construisons ensemble l'avenir"
|
||||
23 post_type: "post"
|
||||
24 to_ping: ""
|
||||
*/
|
||||
|
||||
/*
|
||||
GET_POST_CUSTOM :
|
||||
|
||||
activite_concerne : "les enseignants de français langue étrangère ou français langue seconde"
|
||||
adresse : "Institut français du Liban, Beirut, Lebanon"
|
||||
adresse_courriel : "ihoteit@hotmail.com"
|
||||
adresse_courriel_de_contact : "ihoteit@hotmail.com"
|
||||
categorie : "Rencontre/Témoignage"
|
||||
composition : [ "Association de professeurs de français membre du réseau FIPF", "Ambassade de France/Institut français", "Bureau ou représentation de l'OIF" ]
|
||||
composition_1 : "Association Libanaise des Enseignants de Français, ALEF"
|
||||
composition_2 : "Institut français au Liban"
|
||||
composition_3 : "Représentation OIF"
|
||||
composition_4 : ""
|
||||
composition_autres : ""
|
||||
date : "2023-11-23"
|
||||
depenses_prevues : " collation, pins-souvenirs , déplacements, filmage et photos, affiches, secrétariat et frais divers"
|
||||
description_courte : "Une rencontre-témoignage festive en présence des décideurs, des acteurs de la francophonie au Liban, pays fier de son plurilinguisme et sa diversité\n"
|
||||
description_longue : "Enseignants et élèves témoigneront des opportunités et des atouts que l’enseignement et l’apprentissage du français leur offrent à tous les niveaux : éducatif, personnel, professionnel, social, interculturel et humain. Leur amour pour le français, moyen d’ouverture au monde francophone ainsi qu’à l’international, est sans égal dans un pays plurilingue comme le Liban !\nUne réception clôturera cette belle journée de tous ceux qui œuvrent pour l’expansion de la langue et des valeurs françaises et francophones.\nProgramme\nOuverture: Discours des officiels\nChansons et musique. Trois performances musicales animeraient la cérémonie, au début, au milieu et à la fin\ntémoignages des enseignants .\n\n\n"
|
||||
engagement : ""
|
||||
fichier : "https://lejourdesprofs.org/wp-content/uploads/2023/09/Budget_previsionnel_JIPF_2023-envoye.docx"
|
||||
financement : [ 'a:1:{i:0;s:3:"oui";}' ]
|
||||
fonction : "Secrétaire Générale"
|
||||
heure_de_debut : "16H "
|
||||
heure_de_fin : "18H"
|
||||
institution : "Association Libanaise des Enseignants de Français,ALEF"
|
||||
lien_internet : "http://alef-liban.org"
|
||||
liste_des_depenses : "collation, pins-souvenirs , déplacements, filmage et photos, gestion de la communication , suivi logistique et technique, affiches , secrétariat et frais divers .\n"
|
||||
location : { address:"VGJ7+34P, Beyrouth, Liban", approximate:false, city:"Beyrouth", country:"Liban", street:"", coordinates:{ lat:33.8802185, lng:35.5128288 } }
|
||||
mode : [ "En présentiel" ]
|
||||
montant_demande : "1400 euros"
|
||||
nom : "Slim-Hoteit"
|
||||
participation : "100 participants"
|
||||
pays : ""
|
||||
plan_de_communication : "Avant : diffusion très large de l'information concernant la JIPF : réseaux sociaux et sites internet ALEF, FIPF, IFprof et journaux (L'Orient le Jour)\nPendant : présence des journalistes et couverture en directe sur la page facebook de l'ALEF\nAprès : large diffusion des rapports ,photos et vidéos dans la presse et sur les réseaux sociaux"
|
||||
prenom : "Ilham"
|
||||
public_vise : "100 personnes: officiels, enseignants, élèves, étudiants "
|
||||
recettes_prevues : "Participation de l'ALEF: gestion de la communication avant, pendant et après , suivi logistique et technique"
|
||||
resultat_attendu : " les recettes couvriront les dépenses"
|
||||
resultats_attendus : "Echanger dans une ambiance festive et rendre hommage aux enseignantes et enseignants le jour de leur fete internationale"
|
||||
se_connecter : ""
|
||||
telephone : "009613180576"
|
||||
*/
|
||||
|
||||
function mp_get_published_posts() {
|
||||
|
||||
$get_posts_args = array(
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
'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
|
||||
* - https://developer.wordpress.org/reference/functions/get_post_meta/
|
||||
* - https://developer.wordpress.org/reference/functions/get_post_custom/
|
||||
* if you try to use `get_fields(id)` to retrieve all the acf7 custom fields,
|
||||
* sometimes it fails eventhough you can get a specific value with `get_field(value, id)`,
|
||||
* it's because acf7 didn´t insert the field itself and so some hidden data is not there :
|
||||
* - https://coreysalzano.com/wordpress/acf-get_fields-not-working-but-get_field-does/
|
||||
*/
|
||||
|
||||
// add fields
|
||||
$fields = array(
|
||||
"heure_de_debut" => "string",
|
||||
"heure_de_fin" => "string",
|
||||
"categorie" => "string",
|
||||
"date" => "string",
|
||||
"pays" => "string",
|
||||
"adresse" => "string",
|
||||
"prenom" => "string",
|
||||
"nom" => "string",
|
||||
"location" => "object",
|
||||
);
|
||||
$event = (object)[];
|
||||
foreach($fields as $field => $of_type) {
|
||||
$value = get_field($field, $id);
|
||||
|
||||
//$actual_type = gettype($value);
|
||||
//if ($actual_type !== $of_type) {
|
||||
// mp_console_log("field '" . $field . "' has a value of type '" . $actual_type . "' instead of '" . $of_type . "'");
|
||||
//}
|
||||
|
||||
if ($value === "↓")
|
||||
$value = "Autre";
|
||||
if (gettype($value) === "string")
|
||||
$value = trim($value, " ");
|
||||
$event->$field = $value;
|
||||
}
|
||||
|
||||
// add mode irl or online (irl: true | false)
|
||||
$presentiel = get_field("mode", $id);
|
||||
$event->irl = false;
|
||||
if (isset($presentiel[0])) {
|
||||
if ($presentiel[0] === "En présentiel")
|
||||
$event->irl = true;
|
||||
}
|
||||
|
||||
// add post url
|
||||
$event->url = get_post_permalink($id);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
function mp_get_published_events() {
|
||||
$posts_list = mp_get_published_posts();
|
||||
|
||||
$events = [];
|
||||
foreach ($posts_list as $post) {
|
||||
$event = mp_fill_fields_value($post->ID);
|
||||
$event->id = $post->ID;
|
||||
$event->title = trim($post->post_title, " ");
|
||||
$event->index = null;
|
||||
array_push($events, $event);
|
||||
}
|
||||
return $events;
|
||||
}
|
||||
|
||||
/*
|
||||
event : {}
|
||||
- heure_de_debut : "";
|
||||
- heure_de_fin : "";
|
||||
- categorie : "";
|
||||
- date : "";
|
||||
- pays : "";
|
||||
- ville : "";
|
||||
- adresse : "";
|
||||
- prenom : "";
|
||||
- nom : "";
|
||||
- irl : bool;
|
||||
- id : x;
|
||||
- index : x (default null);
|
||||
- title : "";
|
||||
- url : "";
|
||||
- location : {}
|
||||
- street : "";
|
||||
- city : "";
|
||||
- country : "";
|
||||
- address : "";
|
||||
- approximate : bool;
|
||||
- coordinates : {}
|
||||
- lat : x;
|
||||
- lng : x;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------
|
||||
|
||||
Object {
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
169
plugins/map_prof/srcs/map/mp_get_filters.php
Normal file
169
plugins/map_prof/srcs/map/mp_get_filters.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
function mp_filter_compare($a, $b) {
|
||||
|
||||
$compare = strcmp($a->_name, $b->_name);
|
||||
|
||||
if ($a->_name === "Autre") {
|
||||
if ($compare !== 0)
|
||||
return 1;
|
||||
}
|
||||
if ($b->_name === "Autre") {
|
||||
if ($compare !== 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $compare;
|
||||
}
|
||||
|
||||
function mp_already_in_menu(&$menu, $name) {
|
||||
foreach ($menu as $field) {
|
||||
if ($field->_name == $name)
|
||||
return $field;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* creates the menus
|
||||
* from the events fields
|
||||
* and add the index of the event as it is in location (events when they are sorted)
|
||||
*
|
||||
* fields: [ countries:"", cities:"", categories:"", ... ]
|
||||
* name : field's values -> countries, cities, categories, ...
|
||||
* menu : [ { _name:"", field_1:[], field_2:[] }, ... ]
|
||||
* index : index of this event in locations[] array
|
||||
*/
|
||||
function mp_fill_name($fields, $name, &$menu, $index, &$event) {
|
||||
if ($fields[$name] == null)
|
||||
return;
|
||||
if (gettype($fields[$name]) != 'string')
|
||||
return;
|
||||
if (strlen($fields[$name]) == 0)
|
||||
return;
|
||||
// menu_item, ex: for menu "countries" -> france
|
||||
$menu_item = mp_already_in_menu($menu, $fields[$name]);
|
||||
if ($menu_item != null) {
|
||||
// add to this menu item, eg "Austria", the infos of this
|
||||
// event, like "city" or "category", if not there already
|
||||
foreach ($fields as $key_field => $value) {
|
||||
// no need to add name if already exist
|
||||
if ($key_field == $name)
|
||||
continue;
|
||||
if (! isset($menu_item->$key_field) )
|
||||
$menu_item->$key_field = [];
|
||||
if (!is_string($value)) {
|
||||
//mp_console_log("pour l'article '$event->title', le champ '$key_field' est supposé être de type 'string', mais il est de type '" . gettype($value) . "'");
|
||||
//if ( ! add_post_meta( $id, 'problem', "$value", true ) )
|
||||
// update_post_meta( $id, 'problem', "" );
|
||||
continue;
|
||||
}
|
||||
if (strlen($value) != 0) {
|
||||
if (! in_array($value, $menu_item->$key_field) )
|
||||
array_push($menu_item->$key_field, $value);
|
||||
}
|
||||
}
|
||||
// add location index, if not there already
|
||||
if (! in_array($index, $menu_item->indexes) ) {
|
||||
array_push($menu_item->indexes, $index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$menu_item = (object)[];
|
||||
$menu_item->_name = $fields[$name];
|
||||
// add lists of event info (cities, countries, ...)
|
||||
foreach ($fields as $key_field => $value) {
|
||||
if ($key_field == $name)
|
||||
continue;
|
||||
$menu_item->$key_field = [];
|
||||
if (!is_string($value)) {
|
||||
//mp_console_log("pour l'article '$event->title', le champ '$key_field' est supposé être de type 'string', mais il est de type '" . gettype($value) . "'");
|
||||
continue;
|
||||
}
|
||||
if (strlen($value) != 0)
|
||||
array_push($menu_item->$key_field, $value);
|
||||
}
|
||||
// add list of location index
|
||||
$menu_item->indexes = [$index];
|
||||
|
||||
// and add this item to list of menu
|
||||
array_push($menu, $menu_item);
|
||||
}
|
||||
}
|
||||
|
||||
function mp_get_filters(&$events) {
|
||||
$filters = (object)[];
|
||||
|
||||
foreach ($events as $event) {
|
||||
|
||||
// no index means no coordinates
|
||||
$index = $event->index;
|
||||
if ($index === null)
|
||||
continue;
|
||||
|
||||
// create array of menus
|
||||
$fields = array(
|
||||
"Pays" => $event->location->country,
|
||||
"Catégories" => $event->categorie,
|
||||
"mode" => ($event->irl)? "En présentiel" : "En ligne",
|
||||
);
|
||||
//mp_console_log("event: ");
|
||||
//mp_console_log($event);
|
||||
|
||||
// fill all menu with other menus without doubles
|
||||
foreach ($fields as $name => $value) {
|
||||
if (! isset($filters->$name))
|
||||
$filters->$name = [];
|
||||
mp_fill_name($fields, $name, $filters->$name, $index, $event);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($filters as $key => $value) {
|
||||
usort($filters->$key, 'mp_filter_compare');
|
||||
}
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/*
|
||||
{ }
|
||||
{ [ ] }
|
||||
filters: { - countries : [ { - _name : "" } ] }
|
||||
{ [ { - categories: [] } ] }
|
||||
{ [ { - indexes : [] }, ... ] }
|
||||
{ [ ] }
|
||||
{ }
|
||||
{ - categories: }
|
||||
{ - modes : }
|
||||
{ }
|
||||
*/
|
||||
|
||||
/*
|
||||
event : {}
|
||||
- heure_de_debut : "";
|
||||
- heure_de_fin : "";
|
||||
- categorie : "";
|
||||
- date : "";
|
||||
- pays : "";
|
||||
- ville : "";
|
||||
- adresse : "";
|
||||
- prenom : "";
|
||||
- nom : "";
|
||||
- irl : bool;
|
||||
- id : x;
|
||||
- index : x;
|
||||
- url : "";
|
||||
- title : "";
|
||||
- location : {}
|
||||
- street : "";
|
||||
- city : "";
|
||||
- country : "";
|
||||
- address : "";
|
||||
- approximate : bool;
|
||||
- coordinates : {}
|
||||
- lat : x;
|
||||
- lng : x;
|
||||
*/
|
||||
|
||||
?>
|
||||
66
plugins/map_prof/srcs/map/mp_get_locations.php
Normal file
66
plugins/map_prof/srcs/map/mp_get_locations.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
function mp_coord_already_exist(&$coordinates, &$locations) {
|
||||
foreach ($locations as $location) {
|
||||
if ($location->coordinates->lat == $coordinates->lat)
|
||||
if ($location->coordinates->lng == $coordinates->lng)
|
||||
return $location;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function mp_sort_n_insert(&$event, &$locations) {
|
||||
$coordinates = $event->location->coordinates;
|
||||
if ($coordinates == null)
|
||||
return;
|
||||
|
||||
$already_exist = mp_coord_already_exist($coordinates, $locations);
|
||||
if ($already_exist) {
|
||||
// add index to the event
|
||||
$index = $already_exist->index;
|
||||
$event->index = $index;
|
||||
// add event to events[]
|
||||
array_push($already_exist->events, $event);
|
||||
}
|
||||
else {
|
||||
// create new location object
|
||||
$location = (object)[];
|
||||
$location->events = [];
|
||||
|
||||
// add index to the location and event
|
||||
$index = count($locations);
|
||||
$location->index = $index;
|
||||
$event->index = $index;
|
||||
// add coordinates to the location
|
||||
$location->coordinates = $coordinates;
|
||||
// add first event to events[]
|
||||
array_push($location->events, $event);
|
||||
// add this location to locations[]
|
||||
array_push($locations, $location);
|
||||
}
|
||||
}
|
||||
|
||||
function mp_sort_events(&$events) {
|
||||
$locations = [];
|
||||
|
||||
foreach ($events as $event) {
|
||||
mp_sort_n_insert($event, $locations);
|
||||
};
|
||||
|
||||
return $locations;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
locations = [
|
||||
{
|
||||
index : x
|
||||
coordinates: {}
|
||||
events : [{}, ...]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
27
plugins/map_prof/srcs/map_posts/mp_post_events_pages.php
Normal file
27
plugins/map_prof/srcs/map_posts/mp_post_events_pages.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
function is_event_post() {
|
||||
if ( is_admin() )
|
||||
return false;
|
||||
if ( get_post_type() != "post" )
|
||||
return 0;
|
||||
if ( get_post_status() != "publish" )
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
function mp_post_event_pages_setting() {
|
||||
global $mp_zoom;
|
||||
global $mp_zoom_set;
|
||||
global $mp_coordinates_default;
|
||||
if (is_event_post()) {
|
||||
$mp_zoom = $mp_zoom_set[1];
|
||||
|
||||
$location = get_field("location");
|
||||
$coordinates = $location->coordinates;
|
||||
|
||||
$mp_coordinates_default = $coordinates;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
405
plugins/map_prof/srcs/menu/mp_menu_content.php
Normal file
405
plugins/map_prof/srcs/menu/mp_menu_content.php
Normal file
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
|
||||
function mp_get_all_posts() {
|
||||
|
||||
$get_posts_args = array(
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'any',
|
||||
'post_type' => 'post',
|
||||
);
|
||||
$posts_list = get_posts($get_posts_args);
|
||||
|
||||
return $posts_list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_posts_published($posts_list) {
|
||||
|
||||
$posts_published = [];
|
||||
foreach ($posts_list as $post) {
|
||||
$status = $post->post_status;
|
||||
if ($status == "publish")
|
||||
array_push($posts_published, $post);
|
||||
}
|
||||
return $posts_published;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_have_no_address($posts_list) {
|
||||
|
||||
$posts_no_address = [];
|
||||
foreach ($posts_list as $post) {
|
||||
$address = mp_get_address($post->ID);
|
||||
if (empty($address))
|
||||
array_push($posts_no_address, $post);
|
||||
}
|
||||
return $posts_no_address;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_have_no_coordinates($posts_list) {
|
||||
|
||||
$posts_no_coordinates = [];
|
||||
foreach ($posts_list as $post) {
|
||||
$location = get_field("location", $post->ID);
|
||||
if (empty($location))
|
||||
array_push($posts_no_coordinates, $post);
|
||||
else if (empty($location->coordinates))
|
||||
array_push($posts_no_coordinates, $post);
|
||||
}
|
||||
return $posts_no_coordinates;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_bad_categories($posts_list) {
|
||||
|
||||
$posts_bad_categories = [];
|
||||
foreach ($posts_list as $post) {
|
||||
$value = get_field("categorie", $post->ID);
|
||||
if (! is_string($value)) {
|
||||
array_push($posts_bad_categories, $post);
|
||||
//mp_console_log("categorie:");
|
||||
//mp_console_log($value);
|
||||
}
|
||||
if (str_starts_with($value, '["')) {
|
||||
array_push($posts_bad_categories, $post);
|
||||
}
|
||||
}
|
||||
return $posts_bad_categories;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function count_publish($arr_posts) {
|
||||
return($arr_posts->post_status === "publish");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function mp_show_list_posts_no_address($posts) {
|
||||
|
||||
$all_posts = count($posts);
|
||||
$published_posts = count(array_filter($posts, "count_publish"));
|
||||
|
||||
echo <<<HTML
|
||||
<div style="border: 1px solid red; margin: 20px 20px 20px auto; padding: 0px 20px;">
|
||||
<p style="color: red;">
|
||||
<b>ATTENTION !</b>
|
||||
</p>
|
||||
<input type="checkbox" class="hide_not_published" id="posts_no_address_published">
|
||||
<label for="posts_no_address_published">afficher uniquement les articles publiés</label>
|
||||
<p>
|
||||
<b>
|
||||
HTML;
|
||||
echo "<span class='count_all_posts'>$all_posts</span>";
|
||||
echo "<span class='count_published_posts'>$published_posts</span>";
|
||||
echo '</b>';
|
||||
if (count($posts) == 1)
|
||||
echo " article n'a pas d'adresse :";
|
||||
else
|
||||
echo " articles n'ont pas d'adresses :";
|
||||
echo <<<HTML
|
||||
</p>
|
||||
<ul style="list-style: square inside;">
|
||||
HTML;
|
||||
foreach ($posts as $post) {
|
||||
if ($post->post_status === "publish") {
|
||||
echo <<<HTML
|
||||
<li class="jipf_post_publish"><b>
|
||||
HTML;
|
||||
}
|
||||
else {
|
||||
echo <<<HTML
|
||||
<li><b>
|
||||
HTML;
|
||||
}
|
||||
echo 'id: ';
|
||||
echo $post->ID;
|
||||
echo ' (status: ';
|
||||
echo $post->post_status;
|
||||
echo ') - ';
|
||||
if (!empty($post->mode))
|
||||
echo $post->mode[0];
|
||||
echo ' : </b>';
|
||||
echo $post->post_title;
|
||||
echo <<<HTML
|
||||
</li>
|
||||
HTML;
|
||||
}
|
||||
echo <<<HTML
|
||||
</ul>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_show_list_posts_bad_categories($posts) {
|
||||
|
||||
$all_posts = count($posts);
|
||||
$published_posts = count(array_filter($posts, "count_publish"));
|
||||
|
||||
echo <<<HTML
|
||||
<div style="border: 1px solid red; margin: 20px 20px 20px auto; padding: 0px 20px;">
|
||||
<p style="color: red;">
|
||||
<b>ATTENTION !</b>
|
||||
</p>
|
||||
<input type="checkbox" class="hide_not_published" id="posts_bad_categories_published">
|
||||
<label for="posts_bad_categories_published">afficher uniquement les articles publiés</label>
|
||||
<p>
|
||||
<b>
|
||||
HTML;
|
||||
echo "<span class='count_all_posts'>$all_posts</span>";
|
||||
echo "<span class='count_published_posts'>$published_posts</span>";
|
||||
echo '</b>';
|
||||
if (count($posts) == 1)
|
||||
echo " article à sa catégorie mal formatée :";
|
||||
else
|
||||
echo " articles ont leur catégorie mal formatée :";
|
||||
echo <<<HTML
|
||||
</p>
|
||||
<ul style="list-style: square inside;">
|
||||
HTML;
|
||||
foreach ($posts as $post) {
|
||||
if ($post->post_status === "publish") {
|
||||
echo <<<HTML
|
||||
<li class="jipf_post_publish"><b>
|
||||
HTML;
|
||||
}
|
||||
else {
|
||||
echo <<<HTML
|
||||
<li><b>
|
||||
HTML;
|
||||
}
|
||||
echo 'id: ';
|
||||
echo $post->ID;
|
||||
echo ' (status: ';
|
||||
echo $post->post_status;
|
||||
echo ') - ';
|
||||
if (!empty($post->mode))
|
||||
echo $post->mode[0];
|
||||
echo ' : </b>';
|
||||
echo $post->post_title;
|
||||
echo <<<HTML
|
||||
<p style="margin:0px;">
|
||||
<span style="color:blue;">catégorie: </span>
|
||||
HTML;
|
||||
$categorie = get_field("categorie", $post->ID);
|
||||
echo '<span>';
|
||||
var_dump($categorie);
|
||||
echo '</span>';
|
||||
echo <<<HTML
|
||||
</p>
|
||||
</li>
|
||||
HTML;
|
||||
}
|
||||
echo <<<HTML
|
||||
</ul>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function mp_show_list_posts_no_coordinates($posts) {
|
||||
|
||||
$all_posts = count($posts);
|
||||
$published_posts = count(array_filter($posts, "count_publish"));
|
||||
|
||||
echo <<<HTML
|
||||
<div style="border: 1px solid blue; margin: 20px 20px 20px auto; padding: 0px 20px;">
|
||||
<p style="color: blue;">
|
||||
<b>INFORMATION :</b>
|
||||
</p>
|
||||
<input type="checkbox" class="hide_not_published" id="posts_no_coordinates_published">
|
||||
<label for="posts_no_coordinates_published">afficher uniquement les articles publiés</label>
|
||||
<p>
|
||||
<b>
|
||||
HTML;
|
||||
echo "<span class='count_all_posts'>$all_posts</span>";
|
||||
echo "<span class='count_published_posts'>$published_posts</span>";
|
||||
echo '</b>';
|
||||
if (count($posts) == 1)
|
||||
echo " article n'a pas de coordonnees :";
|
||||
else
|
||||
echo " articles n'ont pas de coordonnees :";
|
||||
echo <<<HTML
|
||||
</p>
|
||||
<ul style="list-style: square inside;">
|
||||
HTML;
|
||||
foreach ($posts as $post) {
|
||||
if ($post->post_status === "publish") {
|
||||
echo <<<HTML
|
||||
<li class="jipf_post_publish"><b>
|
||||
HTML;
|
||||
}
|
||||
else {
|
||||
echo <<<HTML
|
||||
<li><b>
|
||||
HTML;
|
||||
}
|
||||
echo 'id: ';
|
||||
echo $post->ID;
|
||||
echo ' (status: ';
|
||||
echo $post->post_status;
|
||||
echo ') - ';
|
||||
if (!empty($post->mode))
|
||||
echo $post->mode[0];
|
||||
echo ' : </b>';
|
||||
echo $post->post_title;
|
||||
echo <<<HTML
|
||||
</li>
|
||||
HTML;
|
||||
}
|
||||
echo <<<HTML
|
||||
</ul>
|
||||
<p style="background-color: lightblue; padding: 5px 10px; width: fit-content;">
|
||||
<b>pour actualiser les coordonnees d'un article, il suffit de le remettre en "brouillon" puis de le publier a nouveau</b>
|
||||
</p>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_show_post_number($posts_list, $posts_published) {
|
||||
|
||||
echo <<<HTML
|
||||
<p>nombre d'articles au total : <b>
|
||||
HTML;
|
||||
echo count($posts_list);
|
||||
echo "</b> (dont <b>";
|
||||
echo count($posts_published) . "</b>";
|
||||
if (count($posts_published) == 1)
|
||||
echo " publié)</p>";
|
||||
else
|
||||
echo " publiés)</p>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_show_api_key_n_ip() {
|
||||
global $mp_api_key;
|
||||
global $mp_api_key_geo;
|
||||
|
||||
echo <<<HTML
|
||||
<p>l'adresse ip du serveur est : <b>
|
||||
HTML;
|
||||
$external_ip = mp_get_ip();
|
||||
echo $external_ip;
|
||||
echo <<<HTML
|
||||
</b></p>
|
||||
HTML;
|
||||
|
||||
echo <<<HTML
|
||||
<p>les cles api de google maps utilisees sont :</p>
|
||||
<ul style="list-style: square inside; max-width: 500px;">
|
||||
<li>pour la carte : <b style='float:right; margin-right: 10px;'>
|
||||
HTML;
|
||||
echo $mp_api_key;
|
||||
echo <<<HTML
|
||||
</b></li>
|
||||
<li>pour les coordonnees : <b style='float:right; margin-right: 10px;'>
|
||||
HTML;
|
||||
echo $mp_api_key_geo;
|
||||
echo <<<HTML
|
||||
</b></li></ul>
|
||||
<p>(elles sont inscrites dans ./settings/mp_required.php)</p>
|
||||
HTML;
|
||||
|
||||
// need to use an api key with special restrictions :
|
||||
// https://stackoverflow.com/questions/42167695/api-key-browser-api-keys-cannot-have-referer-restrictions-when-used-with-this-ap
|
||||
echo <<<HTML
|
||||
<p style="color: blue;">
|
||||
<b>→ pour la carte : </b>
|
||||
cette cle api peut etre restreinte par url, et par api avec l'api <b>"Maps Javascript API"</b>
|
||||
</p>
|
||||
<p style="color: blue;">
|
||||
<b>→ pour les coordonnees : </b>
|
||||
cette cle api ne doit pas etre restreinte par url, elle peut etre restreinte par adresse ip du serveur, et par api avec l'api <b>"Geocoding API"</b>
|
||||
</p>
|
||||
<p style="color: blue;">
|
||||
<b>→ pour utiliser une seule cle api : </b>
|
||||
cette cle api ne doit pas etre restreinte ni par url ni par adresse ip, elle peut etre restreinte par api avec les deux apis <b>"Maps Javascript API"</b> et <b>"Geocoding API"</b>
|
||||
</p>
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ljdp_map_plugin_content() {
|
||||
|
||||
$posts_list = mp_get_all_posts();
|
||||
//mp_console_log("posts_list: ");
|
||||
//mp_console_log($posts_list);
|
||||
|
||||
$posts_published = mp_posts_published($posts_list);
|
||||
|
||||
$posts_no_address = mp_have_no_address($posts_list);
|
||||
//mp_console_log("posts_no_address: ");
|
||||
//mp_console_log($posts_no_address);
|
||||
|
||||
$posts_no_coordinates = mp_have_no_coordinates($posts_list);
|
||||
//mp_console_log("posts_no_coordinates: ");
|
||||
//mp_console_log($posts_no_coordinates);
|
||||
|
||||
$posts_bad_categories = mp_bad_categories($posts_list);
|
||||
//mp_console_log("posts_bad_categories: ");
|
||||
//mp_console_log($posts_bad_categories);
|
||||
|
||||
|
||||
echo <<<HTML
|
||||
<style>
|
||||
li {
|
||||
list-style-position: outside;
|
||||
margin-left: 10px;
|
||||
}
|
||||
input.hide_not_published:checked ~ ul li:not(.jipf_post_publish) {
|
||||
display: none;
|
||||
}
|
||||
.count_published_posts {
|
||||
display: none;
|
||||
}
|
||||
input.hide_not_published:checked ~ p .count_all_posts {
|
||||
display: none;
|
||||
}
|
||||
input.hide_not_published:checked ~ p .count_published_posts {
|
||||
display: inline;
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
<h2>JIPF map plugin</h2>
|
||||
HTML;
|
||||
|
||||
mp_show_post_number($posts_list, $posts_published);
|
||||
|
||||
mp_show_api_key_n_ip();
|
||||
|
||||
if (count($posts_no_address) > 0)
|
||||
mp_show_list_posts_no_address($posts_no_address);
|
||||
|
||||
if (count($posts_bad_categories) > 0)
|
||||
mp_show_list_posts_bad_categories($posts_bad_categories);
|
||||
|
||||
if (count($posts_no_coordinates) > 0){
|
||||
mp_show_list_posts_no_coordinates($posts_no_coordinates);
|
||||
}
|
||||
else {
|
||||
echo <<<HTML
|
||||
<p style="color: green;">✔ tous les articles ont des coordonnees correctes :)</p>
|
||||
HTML;
|
||||
}
|
||||
|
||||
echo <<<HTML
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
?>
|
||||
78
plugins/map_prof/srcs/publish/mp_get_coordinates.php
Normal file
78
plugins/map_prof/srcs/publish/mp_get_coordinates.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
function mp_get_address($id) {
|
||||
$presentiel = get_field("mode", $id);
|
||||
|
||||
if (empty($presentiel))
|
||||
return null;
|
||||
|
||||
// irl or online
|
||||
if ($presentiel[0] === "En présentiel")
|
||||
$address = get_field("adresse", $id);
|
||||
else
|
||||
$address = get_field("pays", $id);
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
function mp_get_coordinates($id) {
|
||||
global $mp_api_key_geo;
|
||||
$event = (object)[];
|
||||
$location = (object)[];
|
||||
$location->coordinates = null;
|
||||
$location->street = "";
|
||||
$location->city = "";
|
||||
$location->country = "";
|
||||
$location->address = "";
|
||||
$location->approximate = false;
|
||||
|
||||
$address = mp_get_address($id);
|
||||
//mp_console_log("adresse: " . $address);
|
||||
|
||||
// get coordinates from google maps api
|
||||
$geolocation = 'https://maps.googleapis.com/maps/api/geocode/json'
|
||||
. '?language=fr'
|
||||
. '&address=' . urlencode($address)
|
||||
. '&key=' . $mp_api_key_geo;
|
||||
//mp_console_log("geolocation: " . $geolocation);
|
||||
$jsoncontent = file_get_contents($geolocation);
|
||||
//mp_console_log("jsoncontent: " . $jsoncontent);
|
||||
|
||||
// extract coordinates from json
|
||||
// https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types
|
||||
$content = json_decode($jsoncontent);
|
||||
$location->coordinates = $content->results[0]->geometry->location;
|
||||
$location->address = $content->results[0]->formatted_address;
|
||||
foreach ($content->results[0]->address_components as $component) {
|
||||
if (in_array("street_number", $component->types))
|
||||
$location->street = $component->long_name;
|
||||
else if (in_array("route", $component->types)) {
|
||||
if (strlen($location->street) != 0)
|
||||
$location->street .= " ";
|
||||
$location->street .= $component->long_name;
|
||||
}
|
||||
else if (in_array("locality", $component->types))
|
||||
$location->city = $component->long_name;
|
||||
else if (in_array("postal_town", $component->types)) {
|
||||
if (strlen($location->city) != 0)
|
||||
$location->city .= "/";
|
||||
$location->city .= $component->long_name;
|
||||
}
|
||||
else if (in_array("country", $component->types))
|
||||
$location->country = $component->long_name;
|
||||
}
|
||||
if ($content->results[0]->geometry->location_type == "APPROXIMATE")
|
||||
$location->approximate = true;
|
||||
|
||||
// clean strings
|
||||
foreach ($location as $value) {
|
||||
if (gettype($value) != "string")
|
||||
continue;
|
||||
$value = trim($value, " ");
|
||||
}
|
||||
|
||||
return $location;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
48
plugins/map_prof/srcs/publish/mp_update_publish.php
Normal file
48
plugins/map_prof/srcs/publish/mp_update_publish.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
function mp_update_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',
|
||||
));
|
||||
};
|
||||
}
|
||||
add_action( 'admin_post_update_publish', 'mp_update_publish' );
|
||||
add_action( 'admin_post_nopriv_update_publish', 'mp_update_publish' );
|
||||
|
||||
// https://developer.wordpress.org/reference/hooks/admin_post_action/
|
||||
// https://wordpress.stackexchange.com/questions/309440/wordpress-plugin-how-to-run-function-when-button-is-clicked
|
||||
function mp_create_republish_button() {
|
||||
$content = '
|
||||
<br />
|
||||
<div style="border:1px solid black;padding:20px;">
|
||||
<h2>mettre a jour les publications</h2>
|
||||
<p>
|
||||
cliquez sur ce bouton pour mettre a jour toutes les publications
|
||||
<br />
|
||||
une nouvelle page vide va s\'ouvrir dans un nouvel onglet, vous pouvez la fermer
|
||||
</p>
|
||||
<form action="'.admin_url('admin-post.php').'" method="post" target="_blank">
|
||||
<input type="hidden" name="action" value="update_publish">
|
||||
<input type="submit" value="mettre a jour">
|
||||
</form>
|
||||
</div>
|
||||
<br />
|
||||
';
|
||||
return $content;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user