diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php
index 7c69e68..53281a3 100644
--- a/srcs/plugins/map_prof/map_prof_hooks.php
+++ b/srcs/plugins/map_prof/map_prof_hooks.php
@@ -100,6 +100,7 @@ function mp_add_div() {
wp_enqueue_style('mp_style_zoom', plugins_url('styles/mp_zoom.css', __FILE__), '', '', false);
wp_enqueue_script('mp_info_window', plugins_url('scripts/mp_info_window.js', __FILE__), '', '', false);
+ wp_enqueue_script('mp_errors', plugins_url('scripts/mp_errors.js', __FILE__), '', '', false);
wp_enqueue_script('mp_create_markers', plugins_url('scripts/mp_create_markers.js', __FILE__), '', '', false);
wp_enqueue_script('mp_draw_clusters', plugins_url('scripts/mp_draw_clusters.js', __FILE__), '', '', false);
wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true);
@@ -137,6 +138,44 @@ add_shortcode('lejourduprof_map', 'mp_add_div');
+/**
+ * errors map
+ */
+
+function mp_errors_map() {
+
+ $errors = "";
+ $count = 0;
+
+ $get_posts_args = array(
+ 'numberposts' => -1,
+ 'post_status' => 'publish',
+ //'post_status' => 'draft',
+ 'post_type' => 'post',
+ );
+ $posts = get_posts($get_posts_args);
+ foreach ($posts as $post) {
+ $id = $post->ID;
+ $coordinate = get_field('coordinates', $id);
+ if ($coordinate == null) {
+ $count++;
+ $errors .= '
erreur :
- article : "'; + $errors .= $post->post_title . '"
- adresse : "'; + $errors .= get_field('adresse', $id) . ', '; + $errors .= get_field('ville', $id) . ', '; + $errors .= get_field('pays', $id) . ''; + $errors .= '"
'; + } + } + $errors = "nombre d'erreurs : " . $count . "
" . $errors; + return $errors; +} +add_shortcode('ljdp_errors_map', 'mp_errors_map'); + + + + + /** * when a post is saved or published or updated, * find its coordinates diff --git a/srcs/plugins/map_prof/scripts/mp_errors_map.js b/srcs/plugins/map_prof/scripts/mp_errors_map.js new file mode 100644 index 0000000..4d868a6 --- /dev/null +++ b/srcs/plugins/map_prof/scripts/mp_errors_map.js @@ -0,0 +1,7 @@ +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); +}