From b13f34ebd2ac77eb24cb2c069acca6a478b67199 Mon Sep 17 00:00:00 2001 From: lenovo Date: Tue, 15 Nov 2022 12:42:58 +0100 Subject: [PATCH] change architecture of files + hide filter before css is loaded + fusion categories 'autre' and arrow + put categorie 'autre' at bottom of list --- README.md | 6 +- srcs/plugins/map_prof/map_prof_hooks.php | 150 +++--------------- srcs/plugins/map_prof/mp_enqueue.php | 26 +++ .../map_prof/{ => settings}/mp_url_api.php | 0 .../{ => srcs/errors}/mp_address_errors.php | 0 .../{ => srcs/map}/mp_add_to_scripts.php | 0 .../map_prof/{ => srcs/map}/mp_create_div.php | 2 +- .../map_prof/{ => srcs/map}/mp_get_events.php | 4 +- .../{ => srcs/map}/mp_get_filters.php | 27 +++- .../{ => srcs/map}/mp_get_locations.php | 0 .../srcs/map_posts/mp_post_events_pages.php | 27 ++++ .../{ => srcs/publish}/mp_get_coordinates.php | 0 .../srcs/publish/mp_update_publish.php | 44 +++++ srcs/plugins/map_prof/styles/mp_filters.css | 11 +- .../map_prof/{ => utils}/mp_console_log.php | 0 15 files changed, 154 insertions(+), 143 deletions(-) create mode 100644 srcs/plugins/map_prof/mp_enqueue.php rename srcs/plugins/map_prof/{ => settings}/mp_url_api.php (100%) rename srcs/plugins/map_prof/{ => srcs/errors}/mp_address_errors.php (100%) rename srcs/plugins/map_prof/{ => srcs/map}/mp_add_to_scripts.php (100%) rename srcs/plugins/map_prof/{ => srcs/map}/mp_create_div.php (98%) rename srcs/plugins/map_prof/{ => srcs/map}/mp_get_events.php (97%) rename srcs/plugins/map_prof/{ => srcs/map}/mp_get_filters.php (87%) rename srcs/plugins/map_prof/{ => srcs/map}/mp_get_locations.php (100%) create mode 100644 srcs/plugins/map_prof/srcs/map_posts/mp_post_events_pages.php rename srcs/plugins/map_prof/{ => srcs/publish}/mp_get_coordinates.php (100%) create mode 100644 srcs/plugins/map_prof/srcs/publish/mp_update_publish.php rename srcs/plugins/map_prof/{ => utils}/mp_console_log.php (100%) diff --git a/README.md b/README.md index 74b067c..7a5d847 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,11 @@ - [/] filtres sur chrome - [/] infowindow new design - [/] infowindow enlever scroll border -- [ ] reduire hauteur du select menu +- [ ] hide filters before css ready +- [x] reduire hauteur du select menu - [ ] zoom sur cluster problem -- [ ] dans categories, placer "autres" en bas, et transformer fleches en "autres" +- [/] dans categories, placer "autres" en bas +- [/] dans categories, transformer fleches en "autres" - [ ] effacer les fenetres, au moins sur le bouton effacer, ou sur mouvement #### verifications: diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index c48a42f..b74571a 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -16,53 +16,31 @@ Author URI: * inclusions : */ -include_once(dirname(__FILE__) . '/mp_console_log.php'); +include_once(dirname(__FILE__) . '/utils/mp_console_log.php'); + +require_once(dirname(__FILE__) . '/mp_enqueue.php'); require_once(dirname(__FILE__) . '/settings/mp_required.php'); require_once(dirname(__FILE__) . '/settings/mp_optionnals.php'); require_once(dirname(__FILE__) . '/settings/mp_globals.php'); +require_once(dirname(__FILE__) . '/settings/mp_url_api.php'); -require_once(dirname(__FILE__) . '/mp_url_api.php'); -require_once(dirname(__FILE__) . '/mp_add_to_scripts.php'); -require_once(dirname(__FILE__) . '/mp_get_coordinates.php'); -require_once(dirname(__FILE__) . '/mp_get_events.php'); -require_once(dirname(__FILE__) . '/mp_get_locations.php'); -require_once(dirname(__FILE__) . '/mp_get_filters.php'); -require_once(dirname(__FILE__) . '/mp_address_errors.php'); -require_once(dirname(__FILE__) . '/mp_create_div.php'); +require_once(dirname(__FILE__) . '/srcs/errors/mp_address_errors.php'); +require_once(dirname(__FILE__) . '/srcs/map/mp_add_to_scripts.php'); +require_once(dirname(__FILE__) . '/srcs/map/mp_create_div.php'); +require_once(dirname(__FILE__) . '/srcs/map/mp_get_events.php'); +require_once(dirname(__FILE__) . '/srcs/map/mp_get_filters.php'); +require_once(dirname(__FILE__) . '/srcs/map/mp_get_locations.php'); + +require_once(dirname(__FILE__) . '/srcs/map_posts/mp_post_events_pages.php'); + +require_once(dirname(__FILE__) . '/srcs/publish/mp_get_coordinates.php'); +require_once(dirname(__FILE__) . '/srcs/publish/mp_update_publish.php'); -// // temp test -// -// add_action( 'wp', 'my_front_end_function'); -// function my_front_end_function() { -// if ( is_admin() ) -// return; -// if ( get_post_type() != "post" ) -// return; -// if ( get_post_status() != "publish" ) -// return; -// -// $location = get_field(location); -// mp_console_log("location:"); -// mp_console_log($location); -// -// $coordinates = $location->coordinates; -// mp_console_log("coordinates:"); -// mp_console_log($coordinates); -// } -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; -} @@ -73,75 +51,21 @@ function is_event_post() { function mp_ljdp_map() { - - /* * * * * * * * * * * * * * * - * ENQUEUE SCRIPTS AND STYLES - */ - - // https://developers.google.com/maps/documentation/javascript/marker-clustering - $marker_clusterer = "https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"; - - wp_enqueue_style('mp__style', plugins_url('styles/mp__style.css', __FILE__), '', '', false); - - // enqueue header - wp_enqueue_script('mp_info_window', plugins_url('scripts/mp_info_window.js', __FILE__), '', '', false); - wp_enqueue_script('mp_errors_map', plugins_url('scripts/mp_errors_map.js', __FILE__), '', '', false); - wp_enqueue_script('mp_create_filters', plugins_url('scripts/mp_create_filters.js', __FILE__), '', '', false); - wp_enqueue_script('mp_create_markers', plugins_url('scripts/mp_create_markers.js', __FILE__), '', '', false); - wp_enqueue_script('mp_create_map', plugins_url('scripts/mp_create_map.js', __FILE__), '', '', false); - wp_enqueue_script('mp_draw_clusters', plugins_url('scripts/mp_draw_clusters.js', __FILE__), '', '', false); - wp_enqueue_script('mp_filter_events', plugins_url('scripts/mp_filter_events.js', __FILE__), '', '', false); - - // enqueue footer - wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true); - wp_enqueue_script('mp_init_map', plugins_url('scripts/mp_init_map.js', __FILE__), ['mp_marker_clusterer'],'', true); - wp_enqueue_script('mp_google_api', mp_url_api(), ['mp_init_map'], '', true); - - - /* * * * * * * * * - * FIND LOCATIONS - */ + mp_enqueue_scripts_and_styles(); $events = mp_get_published_events(); - //mp_console_log("php events:"); - //mp_console_log($events); - $locations = mp_sort_events($events); - //mp_console_log("php locations:"); - //mp_console_log($locations); - $filters = mp_get_filters($events); - //mp_console_log("php filters:"); - //mp_console_log($filters); + // if post event instead of map page, change coordinate and zoom + mp_post_event_pages_setting(); - // if post event instead of map page, change ccoordinate and zoom - 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; - } - - $to_add = array( + mp_add_to_scripts(array( "locations" => $locations, "filters" => $filters, - ); + )); - mp_add_to_scripts($to_add); + return mp_create_div($filters); - - /* * * * * * * * - * ADD FILTERS - */ - - $mp_map_div = mp_create_div($filters); - - return $mp_map_div; } add_shortcode('lejourduprof_map', 'mp_ljdp_map'); @@ -153,38 +77,8 @@ add_shortcode('lejourduprof_map', 'mp_ljdp_map'); * re-publish posts */ -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_add_update_button() { - $content = ' -
-

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; + return mp_create_republish_button(); } add_shortcode('ljdp_update_publish', 'mp_add_update_button'); diff --git a/srcs/plugins/map_prof/mp_enqueue.php b/srcs/plugins/map_prof/mp_enqueue.php new file mode 100644 index 0000000..c20c9ef --- /dev/null +++ b/srcs/plugins/map_prof/mp_enqueue.php @@ -0,0 +1,26 @@ + diff --git a/srcs/plugins/map_prof/mp_url_api.php b/srcs/plugins/map_prof/settings/mp_url_api.php similarity index 100% rename from srcs/plugins/map_prof/mp_url_api.php rename to srcs/plugins/map_prof/settings/mp_url_api.php diff --git a/srcs/plugins/map_prof/mp_address_errors.php b/srcs/plugins/map_prof/srcs/errors/mp_address_errors.php similarity index 100% rename from srcs/plugins/map_prof/mp_address_errors.php rename to srcs/plugins/map_prof/srcs/errors/mp_address_errors.php diff --git a/srcs/plugins/map_prof/mp_add_to_scripts.php b/srcs/plugins/map_prof/srcs/map/mp_add_to_scripts.php similarity index 100% rename from srcs/plugins/map_prof/mp_add_to_scripts.php rename to srcs/plugins/map_prof/srcs/map/mp_add_to_scripts.php diff --git a/srcs/plugins/map_prof/mp_create_div.php b/srcs/plugins/map_prof/srcs/map/mp_create_div.php similarity index 98% rename from srcs/plugins/map_prof/mp_create_div.php rename to srcs/plugins/map_prof/srcs/map/mp_create_div.php index 4532359..b5d518d 100644 --- a/srcs/plugins/map_prof/mp_create_div.php +++ b/srcs/plugins/map_prof/srcs/map/mp_create_div.php @@ -58,7 +58,7 @@ function mp_create_div(&$filters) { $mp_map_div = '
-
+