From 49daf21ae6ba1c1c4d3bc5f888ae0f436a414aeb Mon Sep 17 00:00:00 2001 From: lenovo Date: Mon, 14 Nov 2022 10:49:39 +0100 Subject: [PATCH] added shortcode for posts update --- README.md | 13 +++-- srcs/plugins/map_prof/map_prof_hooks.php | 57 +++++++++++++++++--- srcs/plugins/map_prof/mp_create_div.php | 2 +- srcs/plugins/map_prof/mp_get_coordinates.php | 2 +- srcs/plugins/map_prof/mp_get_events.php | 19 +------ srcs/plugins/map_prof/mp_get_locations.php | 1 + srcs/plugins/map_prof/scripts/mp_init_map.js | 1 + srcs/plugins/map_prof/styles/mp_filters.css | 14 +++-- 8 files changed, 72 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 5695283..ddcc475 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,21 @@ - irl / online - effacer - [/] sur ordi carte hauteur 600px, sur telephone 500px -- [ ] make two infowindow size -- [ ] infowindow with date in background color purple, and croice white +- [/] make two infowindow size +- [/] infowindow with date in background color purple, and croice white - [ ] check errors on real site - [ ] create action to publish all - [/] deal with multiplication of filters - [ ] deal with error double event irl and online - [ ] change appearance of filter according to other filters -- [ ] deal with window size +- [/] deal with window size + +- la carte ne s'affiche pas sur les pages +- infowindow enlever scroll border +- zoom sur cluster problem +- enlever ordre alphabetique categories +- reduire espace checkboxs +- reduire hauteur du select menu #### verifications: - api only for this site on fabien's google account diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index fc9db9a..fa3a8f0 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -103,16 +103,16 @@ function mp_ljdp_map() { */ $events = mp_get_published_events(); - //mp_console_log("php events:"); - //mp_console_log($events); + mp_console_log("php events:"); + mp_console_log($events); $locations = mp_sort_events($events); - //mp_console_log("php locations:"); - //mp_console_log($locations); + mp_console_log("php locations:"); + mp_console_log($locations); $filters = mp_get_filters($events); - //mp_console_log("php filters:"); - //mp_console_log($filters); + mp_console_log("php filters:"); + mp_console_log($filters); $to_add = array( "locations" => $locations, @@ -147,6 +147,48 @@ 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; +} +add_shortcode('ljdp_update_publish', 'mp_add_update_button'); + + + + /** * errors map */ @@ -172,6 +214,9 @@ function post_published_coordinates($id, $post) { if ( ! add_post_meta( $id, 'location', $location, true ) ) update_post_meta( $id, 'location', $location ); + if ( ! add_post_meta( $id, 'test', "ok", true ) ) + update_post_meta( $id, 'test', "ok" ); + } add_action( 'publish_post', 'post_published_coordinates', 10, 2 ); diff --git a/srcs/plugins/map_prof/mp_create_div.php b/srcs/plugins/map_prof/mp_create_div.php index 86cbdcf..f748bf7 100644 --- a/srcs/plugins/map_prof/mp_create_div.php +++ b/srcs/plugins/map_prof/mp_create_div.php @@ -83,7 +83,7 @@ function mp_create_div(&$filters) { for="filter_menu_reset" class="filter_menu filter_menu_reset" > -

Éffacer

+

Effacer

'; diff --git a/srcs/plugins/map_prof/mp_get_coordinates.php b/srcs/plugins/map_prof/mp_get_coordinates.php index 21a94e8..8bc5128 100644 --- a/srcs/plugins/map_prof/mp_get_coordinates.php +++ b/srcs/plugins/map_prof/mp_get_coordinates.php @@ -33,6 +33,7 @@ function mp_get_coordinates($id) { // extract coordinates from json // https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types $content = json_decode($jsoncontent); + mp_console_log($content); $location->coordinates = $content->results[0]->geometry->location; $location->address = $content->results[0]->formatted_address; foreach ($content->results[0]->address_components as $component) { @@ -60,7 +61,6 @@ function mp_get_coordinates($id) { if (gettype($value) != "string") continue; $value = trim($value, " "); - mp_console_log($value); } return $location; diff --git a/srcs/plugins/map_prof/mp_get_events.php b/srcs/plugins/map_prof/mp_get_events.php index 89101da..7dcd9f4 100644 --- a/srcs/plugins/map_prof/mp_get_events.php +++ b/srcs/plugins/map_prof/mp_get_events.php @@ -78,24 +78,6 @@ function mp_get_published_posts() { -// FOR TESTS -// script to publish or unpublish posts -// -// $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', -// )); -// }; - $get_posts_args = array( 'numberposts' => -1, 'post_status' => 'publish', @@ -127,6 +109,7 @@ function mp_fill_fields_value($id) { "adresse", "prenom", "nom", + "test", "location", ); $event = (object)[]; diff --git a/srcs/plugins/map_prof/mp_get_locations.php b/srcs/plugins/map_prof/mp_get_locations.php index 8ff65e5..8810b90 100644 --- a/srcs/plugins/map_prof/mp_get_locations.php +++ b/srcs/plugins/map_prof/mp_get_locations.php @@ -11,6 +11,7 @@ function mp_coord_already_exist(&$coordinates, &$locations) { function mp_sort_n_insert(&$event, &$locations) { $coordinates = $event->location->coordinates; + mp_console_log("1"); if ($coordinates == null) return; diff --git a/srcs/plugins/map_prof/scripts/mp_init_map.js b/srcs/plugins/map_prof/scripts/mp_init_map.js index bb4483f..3c4c22c 100644 --- a/srcs/plugins/map_prof/scripts/mp_init_map.js +++ b/srcs/plugins/map_prof/scripts/mp_init_map.js @@ -46,6 +46,7 @@ function mp_init_map() { * - let max_zoom = x */ + let map_div = document.getElementById("ljdp_map"); //let filters_div = document.getElementById("ljdp_map_filters"); g_infowindow = new google.maps.InfoWindow(); diff --git a/srcs/plugins/map_prof/styles/mp_filters.css b/srcs/plugins/map_prof/styles/mp_filters.css index 783695c..a5c95b0 100644 --- a/srcs/plugins/map_prof/styles/mp_filters.css +++ b/srcs/plugins/map_prof/styles/mp_filters.css @@ -59,7 +59,7 @@ font-size: 100%; font-weight: 500; color: #666; - border: 2px solid #ba197a; + border: 1px solid #ba197a; } @@ -81,7 +81,7 @@ position: absolute; top: calc( 50% - var(--size) / 2 - 1px ); left: calc( var(--left-offset) * -1 ); - border: 2px solid #ba197a; + border: 1px solid #ba197a; border-radius: 3px; box-sizing: border-box; width: var(--size); @@ -96,15 +96,16 @@ background-color: #e3359e; background-color: #e74ba9; background-color: #ea62b3; - */ background-color: #ed78be; - /* background-color: #f08fc9; background-color: #f3a5d4; background-color: #f6bcdf; background-color: #f9d2e9; background-color: #fce9f4; */ + /* + */ + background-color: #ccc; } @@ -119,7 +120,7 @@ flex-shrink: 2; white-space: nowrap; */ - border: 2px solid #ba197a; + border: 1px solid #ba197a; background-color: #ba197a; color: #fff; padding: 5px 10px; @@ -131,8 +132,5 @@ #ljdp_map_filters { flex-wrap: wrap; } - #ljdp_map_filters .filter_menu { - width: 100%; - } }