diff --git a/Makefile b/Makefile
index 83976ee..82e39eb 100644
--- a/Makefile
+++ b/Makefile
@@ -95,18 +95,18 @@ logs: require build_logs up
require:
# remove all the lines starting with "HOST_VOLUME_" in .env
@echo $(B_PURPLE)"removes all lines starting with 'HOST_VOLUMES' in .env"$(RESET)
- @sed -i "/^HOST_VOLUME_/d" ./srcs/.env
+ sed -i "/^HOST_VOLUME_/d" ./srcs/.env
# add new expended lines starting with "HOST_VOLUME_" after the line "# EXPENDED LINES :" in .env
@echo $(B_PURPLE)"add new expended lines starting with 'HOST_VOLUME_' in .env"$(RESET)
- @$(foreach val,$(EXPENDED_ENV_VAR),sed -i "/^# EXPENDED LINES/a\$(val)" ./srcs/.env;)
+ $(foreach val,$(EXPENDED_ENV_VAR),sed -i "/^# EXPENDED LINES/a\$(val)" ./srcs/.env;)
# create the volumes directories
@echo $(B_PURPLE)"create the volumes directories"$(RESET)
- @mkdir -p $(VOLUMES_D)
+ mkdir -p $(VOLUMES_D)
# verify if the wordpress url is added to the local path
@echo $(B_PURPLE)"verify if the wordpress url is added to the local path"$(RESET)
- @- if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \
- @echo $(B_PURPLE)"nop ! adding it"$(RESET) \
- bash -c 'echo -e "\n# adding for lejourduprof (you can delete it)\n127.0.0.1 $(WP_URL)" >> /etc/hosts'; \
+ - if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \
+ echo $(B_PURPLE)"nop ! adding it"$(RESET) \
+ bash -c 'echo -e "\n# adding for lejourduprof (you can delete it)\n127.0.0.1 $(WP_URL)" >> /etc/hosts';
fi
build:
diff --git a/srcs/.env b/srcs/.env
index 6397325..3c995a7 100644
--- a/srcs/.env
+++ b/srcs/.env
@@ -14,6 +14,7 @@ DB_PSWD="too bad you have read this now i have to erase your memory"
# WORDPRESS SETUP
WP_URL=local_lejourduprof.com
+WP_PORT=3003
WP_VOLUME_DIR=/var/www/html
WP_VOLUME_PLUGINS=/home/www-data
WP_TITLE=title
diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml
index 7803118..de16f84 100644
--- a/srcs/docker-compose.yml
+++ b/srcs/docker-compose.yml
@@ -14,7 +14,7 @@ services:
networks:
- inception
ports:
- - "443":"443"
+ - "${WP_PORT}:443"
volumes:
- wp_volume:${WP_VOLUME_DIR}
- wp_plugins:${WP_VOLUME_PLUGINS}
diff --git a/srcs/plugins/map_prof/images/marker.png b/srcs/plugins/map_prof/images/marker.png
deleted file mode 100644
index bb6d6c9..0000000
Binary files a/srcs/plugins/map_prof/images/marker.png and /dev/null differ
diff --git a/srcs/plugins/map_prof/images/marker_cluster.png b/srcs/plugins/map_prof/images/marker_cluster.png
deleted file mode 100644
index 0367cfc..0000000
Binary files a/srcs/plugins/map_prof/images/marker_cluster.png and /dev/null differ
diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php
deleted file mode 100644
index e023bf9..0000000
--- a/srcs/plugins/map_prof/map_prof_hooks.php
+++ /dev/null
@@ -1,170 +0,0 @@
-categorie) === "array") {
- // mp_console_log($event->categorie);
- // }
- // if (str_starts_with($event->categorie, '["')) {
- // mp_console_log($event->categorie);
- // }
- //}
-
- $locations = mp_sort_events($events); // mp_get_locations.php
- //mp_console_log("locations: ");
- //mp_console_log($locations);
-
- $filters = mp_get_filters($events); // mp_get_filters.php
-
- // if post event instead of map page, change coordinate and zoom
- mp_post_event_pages_setting();
-
- mp_add_to_scripts(array(
- "locations" => $locations,
- "filters" => $filters,
- "jipf_events" => $events,
- ));
-
- return mp_create_div($filters);
-}
-add_shortcode('lejourduprof_map', 'mp_ljdp_map');
-
-/*
- script in divi :
-
-
-*/
-
-
-
-
-
-/**
- * re-publish posts
- */
-
-// function mp_add_update_button() {
-// return mp_create_republish_button();
-// }
-// add_shortcode('ljdp_update_publish', 'mp_add_update_button');
-
-
-
-
-
-/**
- * errors map
- */
-
-function mp_errors_map() {
- return mp_find_address_errors();
-}
-add_shortcode('ljdp_errors_map', 'mp_errors_map');
-
-
-
-
-
-/**
- * when a post is saved or published or updated,
- * find its coordinates
- */
-
-function post_published_coordinates($id, $post) {
-
- $location = mp_get_coordinates($id);
- //mp_console_log("location: ");
- //mp_console_log($location);
-
- if ( ! add_post_meta( $id, 'location', $location, true ) )
- update_post_meta( $id, 'location', $location );
-
-}
-add_action( 'publish_post', 'post_published_coordinates', 10, 2 );
-
-
-
-
-
-/**
- * menu plugin
- */
-
-function ljdp_map_menu() {
- add_menu_page(
- 'JIPF map', // page_title
- 'JIPF map', // menu_title
- 'manage_options', // capability
- 'ljdp-map-plugin', // menu_slug
- 'ljdp_map_plugin_content' // callback function to display page content
- );
-}
-add_action('admin_menu', 'ljdp_map_menu');
-
-?>
diff --git a/srcs/plugins/map_prof/mp_enqueue.php b/srcs/plugins/map_prof/mp_enqueue.php
deleted file mode 100644
index 8e00caf..0000000
--- a/srcs/plugins/map_prof/mp_enqueue.php
+++ /dev/null
@@ -1,26 +0,0 @@
-
diff --git a/srcs/plugins/map_prof/scripts/mp_create_filters.js b/srcs/plugins/map_prof/scripts/mp_create_filters.js
deleted file mode 100644
index fc7ad8e..0000000
--- a/srcs/plugins/map_prof/scripts/mp_create_filters.js
+++ /dev/null
@@ -1,103 +0,0 @@
-function fill_filters(filters_div) {
-
- /*
- * following variable are created by mp_add_to_script.php
- *
- * { }
- * { [ ] }
- * - filters: { - pays : [ { - _name : "" } ] }
- * { [ { - villes : [] } ] }
- * { [ { - categories: [] } ] }
- * { [ { - mode : [] }, ...] }
- * { [ ] }
- * { }
- * { [ ] }
- * { - villes : [ { - _name : "" } ] }
- * { [ { - pays : [] } ] }
- * { [ { - categories: [] } ] }
- * { [ { - mode : [] }, ...] }
- * { [ ] }
- * { }
- * { [ ] }
- * { - categories: [ { - _name : "" } ] }
- * { [ { - pays : [] } ] }
- * { [ { - villes : [] } ] }
- * { [ { - mode : [] }, ...] }
- * { [ ] }
- * { }
- * { }
- * { [ ] }
- * { - mode : [ { - _name : "" } ] }
- * { [ { - pays : [] } ] }
- * { [ { - villes : [] } ] }
- * { [ { - categories: [] }, ...] }
- * { [ ] }
- * { }
- *
- */
-
- let content = "";
- // use Object.keys to obtain an array of object keys
- let keys = Object.keys(filters);
- keys.forEach((key) => {
-
- // // version input checkbox
- //
- // content += `
- //
- // `;
-
- // // version select
- //
- // content += `
- //
- // `;
-
- // // version div
- //
- content += `
-
- `;
-
- });
-
- filters_div.innerHTML = content;
-}
diff --git a/srcs/plugins/map_prof/scripts/mp_create_map.js b/srcs/plugins/map_prof/scripts/mp_create_map.js
deleted file mode 100644
index ead03cc..0000000
--- a/srcs/plugins/map_prof/scripts/mp_create_map.js
+++ /dev/null
@@ -1,41 +0,0 @@
-
-function restrict_map(restrict) {
- let map_restriction = {
- latLngBounds: g_world_bound,
- strictBounds: true,
- };
- if (restrict)
- g_map.setOptions({restriction: map_restriction,});
- else
- g_map.setOptions({restriction: null,});
-};
-
-function create_map(map_div) {
- // default map center to france
- let map_center = coordinates_default;
- // map_center = {lat:-2.515748362923059, lng:32.93366215464864};
- let map_restriction = {
- latLngBounds: g_world_bound,
- strictBounds: true,
- };
- let map_options = {
- /* map options : https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions */
- disableDefaultUI: true,
- zoomControl: true,
- scaleControl: true,
- zoom: map_zoom,
-
- //gestureHandling: "cooperative",
- gestureHandling: "greedy",
- //gestureHandling: "none",
- //gestureHandling: "auto",
-
- //disableDoubleClickZoom: "false", // deprecated
- //draggable: "true", // deprecated
-
- center: map_center,
- restriction: map_restriction,
- }
-
- return new google.maps.Map(map_div, map_options);
-}
diff --git a/srcs/plugins/map_prof/scripts/mp_create_markers.js b/srcs/plugins/map_prof/scripts/mp_create_markers.js
deleted file mode 100644
index 00838d2..0000000
--- a/srcs/plugins/map_prof/scripts/mp_create_markers.js
+++ /dev/null
@@ -1,57 +0,0 @@
-function create_markers(map, locations, infowindow) {
-
- /*
- * following variable are created by mp_add_to_script.php
- * - let icon_color = ""
- * - let icon_color_back = ""
- * - let icon_size = [x, y]
- * - let cluster_size_factor = Number
- * - let icon_stroke_width = Number
- */
-
- let icon_circle_radius = 40 - icon_stroke_width / 2;
-
- let markers = [];
- for (loc of locations) {
-
- if (loc.coordinates == null)
- continue;
-
- let count = loc.events.length;
-
- let marker_icon_size = [
- icon_size[0] + ( icon_size_factor * (count - 2) ),
- icon_size[1] + ( icon_size_factor * (count - 2) )
- ];
- let svg_icon = window.btoa(`
-
-
-
- `);
- let icon_options = {
- url: `data:image/svg+xml;base64,${svg_icon}`,
- scaledSize: new google.maps.Size(marker_icon_size[0], marker_icon_size[1]),
- };
- let marker_label = {
- text: String(count),
- color: icon_color,
- fontSize: "12px",
- fontWeight: "bold",
- };
- let marker_title = `address of ${count} events`;
-
- let marker = new google.maps.Marker({
- position: loc.coordinates,
- map: map,
- icon: icon_options,
- title: marker_title,
- label: marker_label,
- });
-
- attach_info_window(map, marker, loc.events, infowindow);
-
- markers.push(marker);
- };
-
- return markers;
-}
diff --git a/srcs/plugins/map_prof/scripts/mp_draw_clusters.js b/srcs/plugins/map_prof/scripts/mp_draw_clusters.js
deleted file mode 100644
index 8f00a8a..0000000
--- a/srcs/plugins/map_prof/scripts/mp_draw_clusters.js
+++ /dev/null
@@ -1,58 +0,0 @@
-function draw_clusters(map, markers) {
-
- /*
- * following variable are created by mp_add_to_script.php
- * - let icon_color = ""
- * - let icon_color_back = ""
- * - let icon_size = [x, y]
- * - let icon_size_factor = Number
- * - let icon_stroke_width = Number
- */
-
- let icon_circle_radius = 40 - icon_stroke_width / 2;
-
- let renderer = {
- render({ count, position }, stats) {
-
- /* CLUSTERS SETTINGS */
-
- let marker_icon_size = [
- icon_size[0] + ( icon_size_factor * (count - 2) ),
- icon_size[1] + ( icon_size_factor * (count - 2) )
- ];
- let cluster_svg = window.btoa(`
-
-
-
- `);
- let cluster_icon = {
- url: `data:image/svg+xml;base64,${cluster_svg}`,
- scaledSize: new google.maps.Size(marker_icon_size[0], marker_icon_size[1]),
- };
- let cluster_label = {
- text: String(count),
- color: icon_color,
- fontSize: "12px",
- fontWeight: "bold",
- };
- let cluster_title = `Cluster of ${count} markers`;
- let cluster_zIndex = Number(google.maps.Marker.MAX_ZINDEX) + count;
-
- return new google.maps.Marker({
- position,
- icon: cluster_icon,
- label: cluster_label,
- title: cluster_title,
- zIndex: cluster_zIndex,
- });
- }
- }
-
- let onClusterClick = (_, cluster, map) => {
- restrict_map(false);
- map.fitBounds(cluster.bounds);
- restrict_map(true);
- };
-
- return new markerClusterer.MarkerClusterer({ map, markers, renderer, onClusterClick });
-}
diff --git a/srcs/plugins/map_prof/scripts/mp_errors_map.js b/srcs/plugins/map_prof/scripts/mp_errors_map.js
deleted file mode 100644
index 4d868a6..0000000
--- a/srcs/plugins/map_prof/scripts/mp_errors_map.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function print_error(error) {
- let div_map = document.getElementById("ljdp_map");
- let p_err = document.createElement('p');
-
- p_err.textContent = error;
- div_map.after(p_err);
-}
diff --git a/srcs/plugins/map_prof/scripts/mp_filter_events.js b/srcs/plugins/map_prof/scripts/mp_filter_events.js
deleted file mode 100644
index e2a4f22..0000000
--- a/srcs/plugins/map_prof/scripts/mp_filter_events.js
+++ /dev/null
@@ -1,278 +0,0 @@
-
-// https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html
-// add true for noDraw
-// bounds : https://stackoverflow.com/questions/19304574/center-set-zoom-of-map-to-cover-all-visible-markers/19304625#19304625
-
-
-
-function array_first_not_in_second(first, second) {
- let temp_array = [];
- for (let index of first) {
- if (second.indexOf(index) == -1) {
- temp_array.push(index);
- }
- }
- return temp_array;
-}
-
-function filter_selection_indexes(menu, indexes, reverse, add) {
-
- if (indexes.length === 0) {
- // if array of index is empty, delete menu
- delete g_indexes[menu];
- }
- else if (reverse) {
- // if reverse is true, delete all indexes in g_indexes.menu
- // https://stackoverflow.com/questions/5113374/javascript-check-if-variable-exists-is-defined-initialized
- if ( typeof(g_indexes[menu]) !== "undefined" && g_indexes[menu] !== null ) {
- // creates an array with all values of g_indexes[menu] minus indexes
- let temp_array = array_first_not_in_second(g_indexes[menu], indexes);
- if (temp_array.length === 0)
- delete g_indexes[menu];
- else
- g_indexes[menu] = [].concat(temp_array);
- }
- }
- else {
- if (add && typeof(g_indexes[menu]) !== "undefined") {
- // add array of menus to g_indexes{}
- // creates an array with all values of indexes that are not in g_indexes[menu] already
- let temp_array = array_first_not_in_second(indexes, g_indexes[menu]);
- g_indexes[menu] = g_indexes[menu].concat(temp_array);
- }
- else {
- // replace or create array of menu in g_indexes{}
- g_indexes[menu] = [].concat(indexes);
- }
- }
-
- // loop through all arrays of g_indexes to find intersection
- // take first one as comparison
- let keys = Object.keys(g_indexes);
- let intersection = [];
- let compare = [];
- keys.forEach((key, i) => {
- if (i == 0) {
- intersection = g_indexes[key];
- }
- else {
- let temp = [];
- compare = g_indexes[key];
- for (let index of intersection) {
- if (compare.indexOf(index) != -1)
- temp.push(index);
- }
- intersection = [].concat(temp);
- }
- });
- return intersection;
-}
-
-function redraw_clusters(indexes) {
-
- let indexes_count = indexes.length;
-
- if (indexes_count !== 0) {
- // if index array, hide all other markers, and if zoomin, zoom to new markers
- g_marker_cluster.clearMarkers(true);
-
- let marker = g_markers[0];
- let current_bounds = g_map.getBounds();
- let bounds = new google.maps.LatLngBounds();
-
- let outside_bounds = false;
- for (let index of indexes) {
- marker = g_markers[index];
- position = marker.getPosition();
- if (! current_bounds.contains(position))
- outside_bounds = true;
- bounds.extend(position);
-
- g_marker_cluster.addMarker(marker, true);
- }
- if (outside_bounds) {
- if (indexes_count === 1) {
- g_map.setCenter(position);
- g_map.setZoom(max_zoom);
- }
- else if (indexes_count > 1) {
- g_map.fitBounds(bounds);
- }
- }
-
- }
- else if ( Object.keys(g_indexes).length === 0 ) {
- // object is empty, there are no filters
- g_map.setCenter(coordinates_default);
- g_map.setZoom(2);
- g_marker_cluster.addMarkers(g_markers, true);
- }
- else {
- // filters intersection lets no markers on the map
- g_marker_cluster.clearMarkers(true);
- }
-
- g_marker_cluster.render();
-}
-
-function html_item(menu_name, menu_item) {
- let item = menu_item.replace(/ /g, "_");
- let html_id = `filter_${menu_name}_${item}`;
- return document.getElementById(html_id);
-}
-
-function toggle_menu_items(menu_name, x_abled) {
-
- let name = menu_name.replace(/ /g, "_");
- let class_name = `filter_menu_${name}`;
- let items = document.getElementsByClassName(class_name);
-
- if (x_abled === "disable") {
- for (let item of items) {
- // if item is a menu title (like 'categorie' or 'pays')
- // don't remove 'enable', instead add it, because it's not in the list of 'to_enable'
- if (item.selected) {
- item.classList.add('enable');
- }
- else {
- item.classList.remove('enable');
- }
- if (item.classList.contains('to_enable')) {
- item.classList.replace('to_enable', 'enable');
- item.removeAttribute('disabled');
- }
- else if (! item.selected)
- item.setAttribute('disabled', '');
- }
- }
- else {
- for (let item of items) {
- item.classList.remove('enable');
- item.removeAttribute('disabled');
- }
- }
-}
-
-function disable_menus(menu_name_ori, menu_item_ori, reverse, menu_index) {
-
- let menu_item_name = "";
- if (menu_item_ori == null) // it's a menu name
- menu_item_name = menu_name_ori;
- else
- menu_item_name = menu_item_ori._name;
- let item_ori_html = html_item(menu_name_ori, menu_item_name);
- let is_enabled = item_ori_html.classList.contains('enable');
-
- // in case it's a menu title, like "Pays" or "Categories",
- // and it does'nt contains 'enable'
- // just act like Reset button
- // it's too bad it will also go through this menu items even though it's unnecessary
- if (menu_index == 'menu_name') { // it's a menu name
- if (! is_enabled) {
- // "item" as a menu name will select all items in all menus
- toggle_menu_items("item", "enable");
- }
- return;
- }
-
- // if it's Mode menu,
- // and it was the first selection, meaning it does'nt contains 'enable'
- // and both (irl and online) are abled or disabled,
- // just act like Reset button
- // it's too bas it will also go through this menu items even though it's unnecessary
- if (menu_name_ori === "mode") {
- let mode_menus = document.getElementsByClassName("filter_menu_mode");
- let state = 0;
- for (let mode_menu of mode_menus) {
- if (mode_menu.checked)
- state++;
- else
- state--;
- }
- if (state != 0) { // state equal 0 if both have a different state, because (0 + 1 - 1 = 0) and (0 - 1 + 1 = 0)
- if (! is_enabled) {
- // "item" as a menu name will select all items in all menus
- toggle_menu_items("item", "enable");
- return;
- }
- }
- else if (reverse) { // menu is "mode" and only one item is selected and the action was to deselect one, so the action has trigered one item but really we want to see the options of the other item, so let's switch them
- if (menu_index == 0)
- menu_index++;
- else
- menu_index--;
- menu_item_ori = filters[menu_name_ori][menu_index];
- }
- }
-
- let keys = Object.keys(menu_item_ori);
- // loop through list of other menu_items available for this menu_item
- // loop though menu names (pays, categories, mode)
- for (let menu_name of keys) {
- if (menu_name === "_name")
- continue;
- if (menu_name === "indexes")
- continue;
- else if (! is_enabled) {
-
- // // it's too bad it will disable all and then enable certains, it would be better to check each time
- // toggle_menu_items(menu_name, "disable");
- // // loop through items in menu names (ex. for "pays" : france, chili, cuba)
- // for (let item of menu_item_ori[menu_name]) {
- // let item_html = html_item(menu_name, item);
- // item_html.classList.add('enable');
- // item_html.removeAttribute('disabled');
- // }
-
- for (let item of menu_item_ori[menu_name]) {
- let item_html = html_item(menu_name, item);
- item_html.classList.add('to_enable');
- }
- toggle_menu_items(menu_name, "disable");
- }
- }
-}
-
-function filter_show_only(element, menu_name) {
-
- g_infowindow.close();
-
- let menu_index = element.getAttribute("data-menu_index");
- let menu_item = null;
- let indexes = [];
- if (menu_index != "menu_name") {
- menu_item = filters[menu_name][menu_index];
- indexes = menu_item.indexes;
- }
-
- add = false;
- reverse = false;
- if (element.type === "checkbox") {
- reverse = ! element.checked;
- add = true;
- }
-
- disable_menus(menu_name, menu_item, reverse, menu_index);
-
- let index_array = filter_selection_indexes(menu_name, indexes, reverse, add);
-
- redraw_clusters(index_array);
-}
-
-function filter_show_all() {
-
- g_infowindow.close();
-
- // "item" as a menu name will select all items in all menus
- toggle_menu_items("item", "enable");
-
- g_indexes = {};
- g_marker_cluster.clearMarkers(true);
- g_marker_cluster.addMarkers(g_markers);
- /* dont use fitBounds because it's not well centered */
- /* instead use setCenter and setZoom */
- //g_map.fitBounds(g__init_bounds);
- g_map.setCenter(coordinates_default);
- g_map.setZoom(2);
-}
-
diff --git a/srcs/plugins/map_prof/scripts/mp_info_window.js b/srcs/plugins/map_prof/scripts/mp_info_window.js
deleted file mode 100644
index bc75e5a..0000000
--- a/srcs/plugins/map_prof/scripts/mp_info_window.js
+++ /dev/null
@@ -1,82 +0,0 @@
-
-function attach_info_window(map, marker, events, infowindow) {
-
- /*
- * https://developers.google.com/maps/documentation/javascript/infowindows
- * https://stackoverflow.com/questions/11106671/google-maps-api-multiple-markers-with-infowindows
- */
-
- let window_content = `
-
-
-
-
${events[0].location.address}
-
-
- `;
- for (key in events) {
- window_content += `
-
- ${events[key].title}
-
- `;
- };
- window_content += `
-
-
- `;
-
- marker.addListener('click', () => {
-
- let view_center = map.getCenter();
- // height must be half css value (mp_info_windows.css -> '--size: XXXpx;')
- let window_offset = { width: 0, height: 275 };
-
- infowindow.setOptions({
- //disableAutoPan: true,
- disableAutoPan: false,
- content: window_content,
-
- /* dimensions */
- //maxWidth: 400,
- //minWidth: 400,
-
- /* center window */
- position: view_center,
- pixelOffset: window_offset,
-
- //shouldFocus: false,
- });
-
- infowindow.open(map);
- });
-
-}
-
-/*
- 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;
-*/
-
diff --git a/srcs/plugins/map_prof/scripts/mp_init_map.js b/srcs/plugins/map_prof/scripts/mp_init_map.js
deleted file mode 100644
index 6eda725..0000000
--- a/srcs/plugins/map_prof/scripts/mp_init_map.js
+++ /dev/null
@@ -1,72 +0,0 @@
-
-let g_map = {};
-let g_markers = [];
-let g_marker_cluster = {};
-let g_indexes = {};
-let g_infowindow = {};
-const g_world_bound = {
- north: 80,
- south: -80,
- west: -180,
- east: 180,
-};
-
-/*
- * following variable are created by mp_add_to_script.php
- * - let events
- * - let locations = [
- * {
- * coordinates: {}
- * events : [{}, ...]
- * },
- * ...
- * ]
- *
- * { }
- * { [ ] }
- * - let filters: { - pays : [ { - _name : "" } ] }
- * { [ { - villes : [] } ] }
- * { [ { - categories: [] } ] }
- * { [ { - indexes : [] } ] }
- * { [ { - mode : [] }, ...] }
- * { [ ] }
- * { }
- * { - villes : ... }
- * { - categories: ... }
- * { - mode : ... }
- * { }
- *
- * - let coordinates_default = {lat: ,lng: }
- * - let icon_color = ""
- * - let icon_color_back = ""
- * - let icon_size = [x, y]
- * - let cluster_size_factor = Number
- * - let map_zoom = x
- * - let max_zoom = x
- */
-
-function mp_init_map() {
-
- let map_div = document.getElementById("ljdp_map");
- //let filters_div = document.getElementById("ljdp_map_filters");
- g_infowindow = new google.maps.InfoWindow();
-
- g_map = create_map(map_div);
- g_markers = create_markers(g_map, locations, g_infowindow);
- g_marker_cluster = draw_clusters(g_map, g_markers);
-
- // add listener to close infowindow
- // https://developers.google.com/maps/documentation/javascript/events
- g_map.addListener('click', function() {
- g_infowindow.close();
- });
- g_map.addListener('drag', function() {
- g_infowindow.close();
- });
- g_map.addListener('zoom_changed', function() {
- g_infowindow.close();
- });
-
- //g_map.addListener('clusteringbegin', restrict_map(false));
-
-}
diff --git a/srcs/plugins/map_prof/scripts/mp_publish_error.js b/srcs/plugins/map_prof/scripts/mp_publish_error.js
deleted file mode 100644
index 5d1270e..0000000
--- a/srcs/plugins/map_prof/scripts/mp_publish_error.js
+++ /dev/null
@@ -1,21 +0,0 @@
-
-console.log("publish error");
-
-wp.data.dispatch( 'core/notices' ).createNotice(
- 'error', // Can be one of: success, info, warning, error.
- 'impossible de publier : le pays est invalide', // Text string to display.
- {
- isDismissible: true, // Whether the user can dismiss the notice.
- }
-);
-
-//( function ( wp ) {
-// console.log("publish error");
-// wp.data.dispatch( 'core/notices' ).createNotice(
-// 'error', // Can be one of: success, info, warning, error.
-// 'impossible de publie : le pays est invalide', // Text string to display.
-// {
-// isDismissible: true, // Whether the user can dismiss the notice.
-// }
-// );
-//} )( window.wp );
diff --git a/srcs/plugins/map_prof/settings/mp_globals.php b/srcs/plugins/map_prof/settings/mp_globals.php
deleted file mode 100644
index d64fb4e..0000000
--- a/srcs/plugins/map_prof/settings/mp_globals.php
+++ /dev/null
@@ -1,80 +0,0 @@
- 46.227638, "lng" => 2.213749]; // france
-if (isset($mp_settings_coordinates_default))
- $mp_coordinates_default = $mp_settings_coordinates_default;
-
-
-/* ICON COLOR
-*/
-$mp_icon_color = "#ba197a";
-$mp_icon_color_back = "#ffffff99";
-if (isset($mp_settings_icon_color))
- $mp_icon_color = $mp_settings_icon_color;
-if (isset($mp_settings_icon_color_back))
- $mp_icon_color_back = $mp_settings_icon_color_back;
-
-
-/* ICON STROKE WIDTH
-*/
-$mp_icon_stroke_width = 6;
-if (isset($mp_settings_icon_stroke_width))
- $mp_icon_stroke_width = $mp_settings_icon_stroke_width;
-
-
-/* MAX ZOOM
-*/
-$mp_max_zoom = 5;
-if (isset($mp_settings_max_zoom))
- $mp_max_zoom = $mp_settings_max_zoom;
-
-
-?>
diff --git a/srcs/plugins/map_prof/settings/mp_optionnals.php b/srcs/plugins/map_prof/settings/mp_optionnals.php
deleted file mode 100644
index 0722820..0000000
--- a/srcs/plugins/map_prof/settings/mp_optionnals.php
+++ /dev/null
@@ -1,86 +0,0 @@
- 30.0, "lng" => -1.0]; // carte mieux centree
-
-
-
-/* ************************************
- couleurs d'icones
- - couleur de contour
- - couleur de remplissage
- _
- valeurs par defaut "#ba197a"
- "#ffffff99"
- ************************************ */
-//$mp_settings_icon_color = "#d168a8";
-//$mp_settings_icon_color_back = "#ffffff80"; // transparency :
- // 0.0 : 00
- // 0.1 : 1a
- // 0.2 : 33
- // 0.3 : 4d
- // 0.4 : 66
- // 0.5 : 80
- // 0.6 : 99
- // 0.7 : b3
- // 0.8 : cc
- // 0.9 : e6
-
-
-
-/* ************************************
- epaisseur de trait des icones
- _
- valeurs par defaut "6"
- ************************************ */
-$mp_settings_icon_stroke_width = 8;
-
-
-
-
-/* ************************************
- zoom automatique maximum sur les
- marqueurs
- _
- valeurs par defaut "5"
- ************************************ */
-$mp_settings_max_zoom = 4;
-
-
-
-?>
diff --git a/srcs/plugins/map_prof/settings/mp_required.php b/srcs/plugins/map_prof/settings/mp_required.php
deleted file mode 100644
index 8b1c938..0000000
--- a/srcs/plugins/map_prof/settings/mp_required.php
+++ /dev/null
@@ -1,17 +0,0 @@
-
diff --git a/srcs/plugins/map_prof/settings/mp_url_api.php b/srcs/plugins/map_prof/settings/mp_url_api.php
deleted file mode 100644
index 3ae9fca..0000000
--- a/srcs/plugins/map_prof/settings/mp_url_api.php
+++ /dev/null
@@ -1,23 +0,0 @@
- 'https://maps.googleapis.com/maps/api/js',
- 'key' => $mp_api_key,
- 'callback' => 'mp_init_map',
- );
- $mp_src = "";
- foreach ($mp_url as $url_key => $url_value) {
- if ($url_key === 'src') {
- $mp_src .= $url_value;
- if (count($mp_url) > 1)
- $mp_src .= "?";
- }
- else
- $mp_src .= "&" . $url_key . "=" . $url_value;
- };
-
- return $mp_src;
-}
-?>
diff --git a/srcs/plugins/map_prof/srcs/errors/mp_address_errors.php b/srcs/plugins/map_prof/srcs/errors/mp_address_errors.php
deleted file mode 100644
index 93ef820..0000000
--- a/srcs/plugins/map_prof/srcs/errors/mp_address_errors.php
+++ /dev/null
@@ -1,96 +0,0 @@
-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 = 'article : "'
- . $post->post_title . '"
- adresse fournie : "'
- . get_field('adresse', $id) . ', '
- . get_field('ville', $id) . ', '
- . get_field('pays', $id)
- . '"
- adresse trouvée : "'
- . $location->address
- . '"
';
-
- 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 = "nombre d'erreurs : " . $count_errors . " ";
-// $message .= "nombre d'adresses incompletes pour des evenements en presentiels : " . $count_incompletes . " ";
- $message .= "nombre d'adresses approximatives pour des evenements en presentiels : " . $count_approximates . " ";
- $message .= "erreurs : " . $errors;
-// $message .= "adresses incompletes: " . $incompletes;
- $message .= "approximatives : " . $approximates;
-
- return $message;
-}
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/map/mp_add_to_scripts.php b/srcs/plugins/map_prof/srcs/map/mp_add_to_scripts.php
deleted file mode 100644
index c8a991d..0000000
--- a/srcs/plugins/map_prof/srcs/map/mp_add_to_scripts.php
+++ /dev/null
@@ -1,34 +0,0 @@
- $var) {
- wp_add_inline_script('mp_init_map', mp_php_to_js($var, $key), 'before');
- }
-}
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/map/mp_create_div.php b/srcs/plugins/map_prof/srcs/map/mp_create_div.php
deleted file mode 100644
index e563f72..0000000
--- a/srcs/plugins/map_prof/srcs/map/mp_create_div.php
+++ /dev/null
@@ -1,135 +0,0 @@
-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 = '
-
- ';
-
- 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 .= '
-
-
- ';
- }
-
- return $content;
-};
-
-function mp_create_div(&$filters) {
- $mp_map_div = '
-
-
-
- ';
-
- 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 .= '
-
-
- ';
-
- $mp_map_div .= '
-
-
-
- ';
-
- return $mp_map_div;
-};
-
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/map/mp_get_events.php b/srcs/plugins/map_prof/srcs/map/mp_get_events.php
deleted file mode 100644
index 508ff4b..0000000
--- a/srcs/plugins/map_prof/srcs/map/mp_get_events.php
+++ /dev/null
@@ -1,196 +0,0 @@
- -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 {
-}
-
-
-*/
-
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/map/mp_get_filters.php b/srcs/plugins/map_prof/srcs/map/mp_get_filters.php
deleted file mode 100644
index a2282f0..0000000
--- a/srcs/plugins/map_prof/srcs/map/mp_get_filters.php
+++ /dev/null
@@ -1,169 +0,0 @@
-_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;
-*/
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/map/mp_get_locations.php b/srcs/plugins/map_prof/srcs/map/mp_get_locations.php
deleted file mode 100644
index 8ff65e5..0000000
--- a/srcs/plugins/map_prof/srcs/map/mp_get_locations.php
+++ /dev/null
@@ -1,66 +0,0 @@
-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 : [{}, ...]
- },
- ...
- ]
-
-*/
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/map_posts/mp_post_events_pages.php b/srcs/plugins/map_prof/srcs/map_posts/mp_post_events_pages.php
deleted file mode 100644
index 953f36a..0000000
--- a/srcs/plugins/map_prof/srcs/map_posts/mp_post_events_pages.php
+++ /dev/null
@@ -1,27 +0,0 @@
-coordinates;
-
- $mp_coordinates_default = $coordinates;
- }
-}
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php b/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php
deleted file mode 100644
index 0462bc0..0000000
--- a/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php
+++ /dev/null
@@ -1,405 +0,0 @@
- -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 <<
-
- ATTENTION !
-
-
- afficher uniquement les articles publiés
-
-
- HTML;
- echo "$all_posts ";
- echo "$published_posts ";
- echo ' ';
- if (count($posts) == 1)
- echo " article n'a pas d'adresse :";
- else
- echo " articles n'ont pas d'adresses :";
- echo <<
-
- HTML;
- foreach ($posts as $post) {
- if ($post->post_status === "publish") {
- echo <<
- HTML;
- }
- else {
- echo <<
- HTML;
- }
- echo 'id: ';
- echo $post->ID;
- echo ' (status: ';
- echo $post->post_status;
- echo ') - ';
- if (!empty($post->mode))
- echo $post->mode[0];
- echo ' : ';
- echo $post->post_title;
- echo <<
- HTML;
- }
- echo <<
-
- HTML;
-}
-
-
-
-function mp_show_list_posts_bad_categories($posts) {
-
- $all_posts = count($posts);
- $published_posts = count(array_filter($posts, "count_publish"));
-
- echo <<
-
- ATTENTION !
-
-
- afficher uniquement les articles publiés
-
-
- HTML;
- echo "$all_posts ";
- echo "$published_posts ";
- echo ' ';
- if (count($posts) == 1)
- echo " article à sa catégorie mal formatée :";
- else
- echo " articles ont leur catégorie mal formatée :";
- echo <<
-
- HTML;
- foreach ($posts as $post) {
- if ($post->post_status === "publish") {
- echo <<
- HTML;
- }
- else {
- echo <<
- HTML;
- }
- echo 'id: ';
- echo $post->ID;
- echo ' (status: ';
- echo $post->post_status;
- echo ') - ';
- if (!empty($post->mode))
- echo $post->mode[0];
- echo ' : ';
- echo $post->post_title;
- echo <<
- catégorie:
- HTML;
- $categorie = get_field("categorie", $post->ID);
- echo '';
- var_dump($categorie);
- echo ' ';
- echo <<
-
- HTML;
- }
- echo <<
-
- HTML;
-}
-
-
-
-
-function mp_show_list_posts_no_coordinates($posts) {
-
- $all_posts = count($posts);
- $published_posts = count(array_filter($posts, "count_publish"));
-
- echo <<
-
- INFORMATION :
-
-
- afficher uniquement les articles publiés
-
-
- HTML;
- echo "$all_posts ";
- echo "$published_posts ";
- echo ' ';
- if (count($posts) == 1)
- echo " article n'a pas de coordonnees :";
- else
- echo " articles n'ont pas de coordonnees :";
- echo <<
-
- HTML;
- foreach ($posts as $post) {
- if ($post->post_status === "publish") {
- echo <<
- HTML;
- }
- else {
- echo <<
- HTML;
- }
- echo 'id: ';
- echo $post->ID;
- echo ' (status: ';
- echo $post->post_status;
- echo ') - ';
- if (!empty($post->mode))
- echo $post->mode[0];
- echo ' : ';
- echo $post->post_title;
- echo <<
- HTML;
- }
- echo <<
-
- pour actualiser les coordonnees d'un article, il suffit de le remettre en "brouillon" puis de le publier a nouveau
-
-
- HTML;
-}
-
-
-
-function mp_show_post_number($posts_list, $posts_published) {
-
- echo <<nombre d'articles au total :
- HTML;
- echo count($posts_list);
- echo " (dont ";
- echo count($posts_published) . " ";
- if (count($posts_published) == 1)
- echo " publié)";
- else
- echo " publiés)";
-}
-
-
-
-function mp_show_api_key_n_ip() {
- global $mp_api_key;
- global $mp_api_key_geo;
-
- echo <<l'adresse ip du serveur est :
- HTML;
- $external_ip = mp_get_ip();
- echo $external_ip;
- echo <<
- HTML;
-
- echo <<les cles api de google maps utilisees sont :
-
- pour la carte :
- HTML;
- echo $mp_api_key;
- echo <<
- pour les coordonnees :
- HTML;
- echo $mp_api_key_geo;
- echo <<
- (elles sont inscrites dans ./settings/mp_required.php)
- 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 <<
- → pour la carte :
- cette cle api peut etre restreinte par url, et par api avec l'api "Maps Javascript API"
-
-
- → pour les coordonnees :
- 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 "Geocoding API"
-
-
- → pour utiliser une seule cle api :
- 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 "Maps Javascript API" et "Geocoding API"
-
- 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 <<
- 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;
- }
-
-
-
JIPF map plugin
- 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 <<✔ tous les articles ont des coordonnees correctes :)
- HTML;
- }
-
- echo <<
- HTML;
-}
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/publish/mp_get_coordinates.php b/srcs/plugins/map_prof/srcs/publish/mp_get_coordinates.php
deleted file mode 100644
index 5ba104f..0000000
--- a/srcs/plugins/map_prof/srcs/publish/mp_get_coordinates.php
+++ /dev/null
@@ -1,78 +0,0 @@
-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;
-}
-
-
-?>
diff --git a/srcs/plugins/map_prof/srcs/publish/mp_update_publish.php b/srcs/plugins/map_prof/srcs/publish/mp_update_publish.php
deleted file mode 100644
index d71e646..0000000
--- a/srcs/plugins/map_prof/srcs/publish/mp_update_publish.php
+++ /dev/null
@@ -1,48 +0,0 @@
- -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 = '
-
-
-
mettre a jour les publications
-
- cliquez sur ce bouton pour mettre a jour toutes les publications
-
- une nouvelle page vide va s\'ouvrir dans un nouvel onglet, vous pouvez la fermer
-
-
-
-
- ';
- return $content;
-}
-
-*/
-
-?>
diff --git a/srcs/plugins/map_prof/styles/mp__style.css b/srcs/plugins/map_prof/styles/mp__style.css
deleted file mode 100644
index 540ecf6..0000000
--- a/srcs/plugins/map_prof/styles/mp__style.css
+++ /dev/null
@@ -1,22 +0,0 @@
-
-@import "mp_info_windows.css";
-@import "mp_zoom.css";
-@import "mp_filters.css";
-
-#ljdp_map_wrapper {
- position: relative;
-}
-
-#ljdp_map {
- height: 600px;
- width: 100%;
-}
-
-
-@media only screen and (max-width: 700px) {
- #ljdp_map {
- height: 400px;
- }
-}
-
-
diff --git a/srcs/plugins/map_prof/styles/mp_filters.css b/srcs/plugins/map_prof/styles/mp_filters.css
deleted file mode 100644
index e09b9e2..0000000
--- a/srcs/plugins/map_prof/styles/mp_filters.css
+++ /dev/null
@@ -1,146 +0,0 @@
-
-/*
- * FILTERS
- */
-
-/*
- #ba197a;
-*/
-
-/* **************************************
- GENERAL SETTINGS
-*/
-
-/*
-*/
-#ljdp_map_filters,
-#ljdp_map_filters * {
- display: flex;
- flex-direction: row;
- position: relative;
- margin: auto;
-}
-
-#ljdp_map_filters {
- display: flex !important;
- position: relative;
- width: 100%;
- z-index: 1;
- gap: 10px;
- margin-bottom: 10px;
-}
-#ljdp_map_filters .filter_menu {
- display: flex !important;
- width: auto;
- cursor: pointer;
- border-radius: 3px;
- white-space: nowrap;
-}
-
-
-
-
-/* **************************************
- DROP DOWN MENU
-*/
-
-/*
-*/
-#ljdp_map_filters .filter_menu_drop {
- width: 100%;
- height: auto;
- margin: 0px;
- padding: 5px;
- font-size: 100%;
- font-weight: 500;
- color: #666;
- border: 1px solid #ba197a;
-}
-#ljdp_map_filters .filter_menu_drop option {
- font-size: 100%;
- font-weight: 500;
- color: #666;
-}
-
-
-
-
-
-/* **************************************
- MENU CHECKBOX
-*/
-
-#ljdp_map_filters .filter_menu_checkbox p {
- --size: 16px;
- --left-offset: calc( var(--size) + 5px );
- margin-left: var(--left-offset);
-}
-
-#ljdp_map_filters .filter_menu_checkbox p::before {
- content: "";
- position: absolute;
- top: calc( 50% - var(--size) / 2 - 1px );
- left: calc( var(--left-offset) * -1 );
- border: 1px solid #ba197a;
- border-radius: 3px;
- box-sizing: border-box;
- width: var(--size);
- height: var(--size);
-}
-
-#ljdp_map_filters input.filter_menu_checkbox:checked
-+ label.filter_menu_checkbox p::before {
- background-color: #ccc;
-}
-
-#ljdp_map_filters input.filter_menu_checkbox:disabled
-+ label.filter_menu_checkbox {
- cursor: default;
-}
-#ljdp_map_filters input.filter_menu_checkbox:disabled
-+ label.filter_menu_checkbox p::before {
- border-color: #ccc;
- background-color: #ccc;
-}
-#ljdp_map_filters input.filter_menu_checkbox:disabled
-+ label.filter_menu_checkbox p {
- color: #ccc;
-}
-
-
-
-
-/* **************************************
- MENU RESET
-*/
-
-#ljdp_map_filters .filter_menu_reset {
-/*
- flex-shrink: 2;
- white-space: nowrap;
-*/
- border: 1px solid #ba197a;
- background-color: #ba197a;
- color: #fff;
- padding: 5px 10px;
-}
-
-
-
-
-
-
-
-/* **************************************
- RESONSIVE DESIGN
-*/
-
-
-@media only screen and (max-width: 700px) {
- #ljdp_map_filters {
- flex-wrap: wrap;
- margin: 10px;
- width: auto;
- }
-}
-
diff --git a/srcs/plugins/map_prof/styles/mp_info_windows.css b/srcs/plugins/map_prof/styles/mp_info_windows.css
deleted file mode 100644
index b31e5fe..0000000
--- a/srcs/plugins/map_prof/styles/mp_info_windows.css
+++ /dev/null
@@ -1,187 +0,0 @@
-
-/*
- * INFO WINDOW
- */
-
-
-
-
-/* **************************************
- GOOGLE WINDOW
-*/
-
-div.gm-style-iw.gm-style-iw-c {
- padding: 0px !important;
- background-color: transparent;
- pointer-events: none;
- box-shadow: 0 2px 7px 1px rgba(0,0,0,.3);
- box-shadow: none;
- border-radius: 0 !important;
- max-width: 75vw !important;
-}
-
-
-
-
-/* **************************************
- GOOGLE TRIANGLE
-*/
-
-.gm-style-iw-tc {
- display: none !important;
-}
-
-
-
-
-/* **************************************
- GOOGLE CROICE
-*/
-
-button.gm-ui-hover-effect {
- display: none !important;
-}
-
-
-
-
-/* **************************************
- CONTENT
-*/
-
-#infowindow_limits,
-#infowindow_limits * {
- display: flex;
- flex-direction: row;
- position: relative;
- margin: auto;
- width: 100%;
-}
-
-#infowindow_limits {
- /* height must be twice js 'height' value (mp_info_windows.js -> '{ ... height: XXX }' */
- height: 550px;
- max-width: 380px;
- flex-direction: column;
- pointer-events: none;
- background-color: transparent;
-}
-
-#infowindow_limits .infowindow {
- pointer-events: auto;
- height: auto;
- max-height: 400px;
- padding: 0px;
- overflow: scroll;
- flex-direction: column;
- border-radius: 3px;
- background-color: #fff;
- border: 1px solid #ccc;
-}
-
-#infowindow_limits #infowindow_close {
- position: absolute;
- top: 0px;
- right: 0px;
- width: 30px;
- height: 30px;
- cursor: pointer;
-}
-
-#infowindow_limits #infowindow_close::before {
- content: "";
- position: absolute;
- top: calc(50% - 0.8px);
- left: 25%;
- width: 50%;
- height: 1.6px;
- background-color: #fff;
- transform: rotate(-45deg);
-}
-
-#infowindow_limits #infowindow_close::after {
- content: "";
- position: absolute;
- top: calc(50% - 0.8px);
- left: 25%;
- width: 50%;
- height: 1.6px;
- background-color: #fff;
- transform: rotate(45deg);
-}
-
-#infowindow_limits .infowindow_head {
- padding: 5px 10px;
- margin: 0px;
- background-color: #ab197a;
-}
-
-#infowindow_limits .infowindow_head p {
- font-size: 115%;
- font-weight: 500;
- line-height: 1.7em;
- color: #fff;
- margin-right: 30px;
-}
-
-#infowindow_limits .infowindow_body {
- padding: 10px 10px 10px 10px;
- margin: 0px;
-}
-
-#infowindow_limits .infowindow_body::after {
- content: "";
- position: absolute;
- bottom: 0px;
- left: 0px;
- margin: 0px;
- width: 100%;
- height: 1px;
- background-color: #ccc;
-}
-
-#infowindow_limits .infowindow_body p {
- font-size: 115%;
- font-weight: 500;
- line-height: 1.7em;
- color: #666;
-}
-
-
-
-
-/* **************************************
- HIDE SCROLL BARS
-*/
-/* chrome safari opera */
-.gm-style-iw-d::-webkit-scrollbar,
-#infowindow_limits::-webkit-scrollbar,
-#infowindow_limits .infowindow::-webkit-scrollbar {
- display: none;
-}
-
-.gm-style-iw-d,
-#infowindow_limits,
-#infowindow_limits .infowindow {
- -ms-overflow-style: none; /* Ie edge */
- scrollbar-width: none; /* firefox */
-}
-
-
-
-
-
-/* **************************************
- MOBILE RESPONSIVE
-*/
-
-@media only screen and (max-width: 400px) {
- #infowindow_limits .infowindow_body p,
- #infowindow_limits .infowindow_head p {
- font-size: 100%;
- }
-}
-
-
-
-
diff --git a/srcs/plugins/map_prof/styles/mp_zoom.css b/srcs/plugins/map_prof/styles/mp_zoom.css
deleted file mode 100644
index 4b75f65..0000000
--- a/srcs/plugins/map_prof/styles/mp_zoom.css
+++ /dev/null
@@ -1,24 +0,0 @@
-
-/*
- * ZOOM BUTTONS
- */
-
-
-/* hide the rectangular box container
-div.gmnoprint div {
- visibility: hidden;
-}
-*/
-/* shape buttons in circles
-button.gm-control-active {
- visibility: visible;
- border-radius: 50% !important;
- background-color: rgb(255, 255, 255) !important;
-}
-*/
-/* gap between the buttons
-button.gm-control-active ~ div {
- height: 10px !important;
-}
-*/
-
diff --git a/srcs/plugins/map_prof/utils/mp_console_log.php b/srcs/plugins/map_prof/utils/mp_console_log.php
deleted file mode 100644
index a975a1a..0000000
--- a/srcs/plugins/map_prof/utils/mp_console_log.php
+++ /dev/null
@@ -1,28 +0,0 @@
-' . $js_code . '';
- echo $js_code;
-}
-
-// function mp_console_log($output, $with_script_tags = true) {
-// $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) .
-// ');';
-// if ($with_script_tags) {
-// $js_code = '';
-// }
-// echo $js_code;
-// }
-
-?>
diff --git a/srcs/plugins/map_prof/utils/mp_get_ip.php b/srcs/plugins/map_prof/utils/mp_get_ip.php
deleted file mode 100644
index 84acfee..0000000
--- a/srcs/plugins/map_prof/utils/mp_get_ip.php
+++ /dev/null
@@ -1,18 +0,0 @@
-
diff --git a/srcs/requirements/wordpress/conf/wp_entrypoint.sh b/srcs/requirements/wordpress/conf/wp_entrypoint.sh
index ac086bb..c5386da 100644
--- a/srcs/requirements/wordpress/conf/wp_entrypoint.sh
+++ b/srcs/requirements/wordpress/conf/wp_entrypoint.sh
@@ -29,20 +29,29 @@ else
fi
+# concat url with port if not 443
+echo -n "check port : "
+COMPLETE_URL="${WP_URL}"
+if [ ! ${WP_PORT} -eq 443 ]; then
+ COMPLETE_URL="${WP_URL}:${WP_PORT}"
+fi
+# install wp if not already installed
if ! wp core is-installed --path="${WP_VOLUME_DIR}" 2> /dev/null
then
- echo -e ${YELLOW}installing...${RESET}
- echo -e ${YELLOW}wp config create...${RESET}
+ echo -e ${YELLOW}installing :${RESET}
+
#wp config create \
+ echo -e ${YELLOW}wp config create...${RESET}
php wp-cli.phar config create \
--dbhost="${DB_HOST}" \
--dbname="${DB_NAME}" \
--dbuser="${DB_USER}" \
--dbpass="${DB_PSWD}" \
--path="${WP_VOLUME_DIR}" --allow-root
- echo -e ${YELLOW}wp core install...${RESET}
+
#wp core install \
+ echo -e ${YELLOW}wp core install...${RESET}
php wp-cli.phar core install \
--url="${WP_URL}" \
--title="${WP_TITLE}" \
@@ -51,8 +60,9 @@ then
--admin_password="${WP_ADMIN_PSWD}" \
--skip-email \
--path="${WP_VOLUME_DIR}" --allow-root
- echo -e ${YELLOW}wp user create...${RESET}
+
#wp user create \
+ echo -e ${YELLOW}wp user create...${RESET}
php wp-cli.phar user create \
"${WP_USER}" "${WP_USER_EMAIL}" \
--user_pass="${WP_USER_PSWD}" \
@@ -70,8 +80,33 @@ then
echo -e ${GREEN}done !${RESET}
else
echo -e ${GREEN}wp is installed${RESET}
+
+ echo -e ${YELLOW}checking config.php file with current url...${RESET}
+ HOME=$(php wp-cli.phar config get WP_HOME --path=${WP_VOLUME_DIR})
+ if [ ${HOME} != ${COMPLETE_URL} ] ; then
+ php wp-cli.phar config set WP_HOME ${COMPLETE_URL} --path=${WP_VOLUME_DIR}
+ fi
+ SITEURL=$(php wp-cli.phar config get WP_SITEURL --path=${WP_VOLUME_DIR})
+ if [ ${SITEURL} != ${COMPLETE_URL} ] ; then
+ php wp-cli.phar config set WP_SITEURL ${COMPLETE_URL} --path=${WP_VOLUME_DIR}
+ fi
fi
+# HOME=$(php wp-cli.phar config get WP_HOME --path=${WP_VOLUME_DIR})
+# echo -e "HOME : ${HOME}\n"
+# SITEURL=$(php wp-cli.phar config get WP_SITEURL --path=${WP_VOLUME_DIR})
+# echo -e "SITEURL : ${SITEURL}\n"
+ LIST=$(php wp-cli.phar config list --path=${WP_VOLUME_DIR} --format="dotenv")
+ echo -e "LIST : ${LIST}\n"
+#
+# #DB_HOME=$(php wp-cli.phar db query "SELECT option_value FROM wp_options WHERE option_name = 'home'" --path=${WP_VOLUME_DIR})
+# #DB_HOME=$(php wp-cli.phar db query 'SELECT * FROM wp_options WHERE option_name LIKE "%home%"' --skip-column-names --path=${WP_VOLUME_DIR})
+# DB_HOME=$(php wp-cli.phar db query 'SELECT * FROM wp_options WHERE option_name="home"' --skip-column-names --path=${WP_VOLUME_DIR})
+# echo -e "DB_HOME :\n${DB_HOME}\n"
+# DB_URL=$(php wp-cli.phar db query 'SELECT * FROM wp_options WHERE option_name="siteurl"' --skip-column-names --path=${WP_VOLUME_DIR})
+# echo -e "DB_URL :\n${DB_URL}\n"
+
+
exec "${PHP_VERSION}" -FR