From 083afb9accd68d7ce63fd97d92ae1cacf7befad8 Mon Sep 17 00:00:00 2001 From: lenovo Date: Wed, 2 Nov 2022 22:13:43 +0100 Subject: [PATCH] better file organisation and default settings --- srcs/plugins/map_prof/{ => images}/marker.png | Bin .../map_prof/{ => images}/marker_cluster.png | Bin srcs/plugins/map_prof/map_prof_hooks.php | 32 ++++++--- srcs/plugins/map_prof/mp_add_to_scripts.php | 64 ++++-------------- ...ates_from_posts.php => mp_get_markers.php} | 6 ++ srcs/plugins/map_prof/scripts/mp_init_map.js | 2 +- .../map_prof/settings/mp_optionnals.php | 14 ++++ .../plugins/map_prof/settings/mp_required.php | 14 ++++ 8 files changed, 71 insertions(+), 61 deletions(-) rename srcs/plugins/map_prof/{ => images}/marker.png (100%) rename srcs/plugins/map_prof/{ => images}/marker_cluster.png (100%) rename srcs/plugins/map_prof/{mp_coordinates_from_posts.php => mp_get_markers.php} (96%) create mode 100644 srcs/plugins/map_prof/settings/mp_optionnals.php create mode 100644 srcs/plugins/map_prof/settings/mp_required.php diff --git a/srcs/plugins/map_prof/marker.png b/srcs/plugins/map_prof/images/marker.png similarity index 100% rename from srcs/plugins/map_prof/marker.png rename to srcs/plugins/map_prof/images/marker.png diff --git a/srcs/plugins/map_prof/marker_cluster.png b/srcs/plugins/map_prof/images/marker_cluster.png similarity index 100% rename from srcs/plugins/map_prof/marker_cluster.png rename to srcs/plugins/map_prof/images/marker_cluster.png diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index 882efef..1242350 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -10,17 +10,6 @@ Author URI: -/** - * global variables : - */ - -$mp_api_key = 'AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE'; -$mp_icon_url = '/wp-content/plugins/map_prof/marker.png'; -$mp_icon_size = [50, 50]; -$mp_icon_label_color = "red"; - - - /** * inclusions : */ @@ -28,6 +17,27 @@ $mp_icon_label_color = "red"; include_once(dirname(__FILE__) . '/mp_console_log.php'); require_once(dirname(__FILE__) . '/mp_url_api.php'); require_once(dirname(__FILE__) . '/mp_add_to_scripts.php'); +require_once(dirname(__FILE__) . '/settings/mp_required.php'); +require_once(dirname(__FILE__) . '/settings/mp_optionnals.php'); + + + +/** + * global variables : + */ + +$mp_icon_url = '/wp-content/plugins/map_prof/images/' . $mp_icon_file; +$mp_icon_size = [50, 50]; +if (isset($mp_icon_size_setting)) { + if (is_array($mp_icon_size_setting)) { + if (count($mp_icon_size_setting) === 2) { + if ( is_numeric($mp_icon_size_setting[0]) && is_numeric($mp_icon_size_setting[1]) ) { + $mp_icon_size = $mp_icon_size_setting; + } + } + } +} +//$mp_icon_label_color = "red"; diff --git a/srcs/plugins/map_prof/mp_add_to_scripts.php b/srcs/plugins/map_prof/mp_add_to_scripts.php index ccf12f4..5108e89 100644 --- a/srcs/plugins/map_prof/mp_add_to_scripts.php +++ b/srcs/plugins/map_prof/mp_add_to_scripts.php @@ -1,58 +1,24 @@ diff --git a/srcs/plugins/map_prof/mp_coordinates_from_posts.php b/srcs/plugins/map_prof/mp_get_markers.php similarity index 96% rename from srcs/plugins/map_prof/mp_coordinates_from_posts.php rename to srcs/plugins/map_prof/mp_get_markers.php index 50d4f19..a2442a6 100644 --- a/srcs/plugins/map_prof/mp_coordinates_from_posts.php +++ b/srcs/plugins/map_prof/mp_get_markers.php @@ -160,4 +160,10 @@ function mp_retrieve_address(&$posts_list) { return $locs; } +function mp_get_published_markers() { + $posts_list = mp_get_published_posts(); + $markers = mp_retrieve_address($posts_list); + return $markers; +} + ?> diff --git a/srcs/plugins/map_prof/scripts/mp_init_map.js b/srcs/plugins/map_prof/scripts/mp_init_map.js index d026a50..f368731 100644 --- a/srcs/plugins/map_prof/scripts/mp_init_map.js +++ b/srcs/plugins/map_prof/scripts/mp_init_map.js @@ -44,7 +44,7 @@ function mp_init_map() { label = { // text: String(count), text: "hello", - color: icon_label_color, +// color: icon_label_color, fontSize: "12px", }; let markers = []; diff --git a/srcs/plugins/map_prof/settings/mp_optionnals.php b/srcs/plugins/map_prof/settings/mp_optionnals.php new file mode 100644 index 0000000..15b00e6 --- /dev/null +++ b/srcs/plugins/map_prof/settings/mp_optionnals.php @@ -0,0 +1,14 @@ + diff --git a/srcs/plugins/map_prof/settings/mp_required.php b/srcs/plugins/map_prof/settings/mp_required.php new file mode 100644 index 0000000..f29c3b3 --- /dev/null +++ b/srcs/plugins/map_prof/settings/mp_required.php @@ -0,0 +1,14 @@ +