added shortcode for posts update

This commit is contained in:
lenovo
2022-11-14 10:49:39 +01:00
parent dfd3dc607d
commit 49daf21ae6
8 changed files with 72 additions and 37 deletions

View File

@@ -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

View File

@@ -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 = '
<br />
<p>cliquez sur ce bouton pour mettre a jour toutes les publications<p>
<p>une nouvelle page vide va s\'ouvrir dans un nouvel onglet, vous pouvez la fermer<p>
<form action="'.admin_url('admin-post.php').'" method="post" target="_blank">
<input type="hidden" name="action" value="update_publish">
<input type="submit" value="mettre a jour">
</form>
<br />
';
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 );

View File

@@ -83,7 +83,7 @@ function mp_create_div(&$filters) {
for="filter_menu_reset"
class="filter_menu filter_menu_reset"
>
<p>Éffacer</p>
<p>Effacer</p>
</label>
';

View File

@@ -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;

View File

@@ -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)[];

View File

@@ -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;

View File

@@ -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();

View File

@@ -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%;
}
}