added shortcode for posts update
This commit is contained in:
13
README.md
13
README.md
@@ -18,14 +18,21 @@
|
|||||||
- irl / online
|
- irl / online
|
||||||
- effacer
|
- effacer
|
||||||
- [/] sur ordi carte hauteur 600px, sur telephone 500px
|
- [/] sur ordi carte hauteur 600px, sur telephone 500px
|
||||||
- [ ] make two infowindow size
|
- [/] make two infowindow size
|
||||||
- [ ] infowindow with date in background color purple, and croice white
|
- [/] infowindow with date in background color purple, and croice white
|
||||||
- [ ] check errors on real site
|
- [ ] check errors on real site
|
||||||
- [ ] create action to publish all
|
- [ ] create action to publish all
|
||||||
- [/] deal with multiplication of filters
|
- [/] deal with multiplication of filters
|
||||||
- [ ] deal with error double event irl and online
|
- [ ] deal with error double event irl and online
|
||||||
- [ ] change appearance of filter according to other filters
|
- [ ] 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:
|
#### verifications:
|
||||||
- api only for this site on fabien's google account
|
- api only for this site on fabien's google account
|
||||||
|
|||||||
@@ -103,16 +103,16 @@ function mp_ljdp_map() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$events = mp_get_published_events();
|
$events = mp_get_published_events();
|
||||||
//mp_console_log("php events:");
|
mp_console_log("php events:");
|
||||||
//mp_console_log($events);
|
mp_console_log($events);
|
||||||
|
|
||||||
$locations = mp_sort_events($events);
|
$locations = mp_sort_events($events);
|
||||||
//mp_console_log("php locations:");
|
mp_console_log("php locations:");
|
||||||
//mp_console_log($locations);
|
mp_console_log($locations);
|
||||||
|
|
||||||
$filters = mp_get_filters($events);
|
$filters = mp_get_filters($events);
|
||||||
//mp_console_log("php filters:");
|
mp_console_log("php filters:");
|
||||||
//mp_console_log($filters);
|
mp_console_log($filters);
|
||||||
|
|
||||||
$to_add = array(
|
$to_add = array(
|
||||||
"locations" => $locations,
|
"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
|
* errors map
|
||||||
*/
|
*/
|
||||||
@@ -172,6 +214,9 @@ function post_published_coordinates($id, $post) {
|
|||||||
if ( ! add_post_meta( $id, 'location', $location, true ) )
|
if ( ! add_post_meta( $id, 'location', $location, true ) )
|
||||||
update_post_meta( $id, 'location', $location );
|
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 );
|
add_action( 'publish_post', 'post_published_coordinates', 10, 2 );
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ function mp_create_div(&$filters) {
|
|||||||
for="filter_menu_reset"
|
for="filter_menu_reset"
|
||||||
class="filter_menu filter_menu_reset"
|
class="filter_menu filter_menu_reset"
|
||||||
>
|
>
|
||||||
<p>Éffacer</p>
|
<p>Effacer</p>
|
||||||
</label>
|
</label>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ function mp_get_coordinates($id) {
|
|||||||
// extract coordinates from json
|
// extract coordinates from json
|
||||||
// https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types
|
// https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types
|
||||||
$content = json_decode($jsoncontent);
|
$content = json_decode($jsoncontent);
|
||||||
|
mp_console_log($content);
|
||||||
$location->coordinates = $content->results[0]->geometry->location;
|
$location->coordinates = $content->results[0]->geometry->location;
|
||||||
$location->address = $content->results[0]->formatted_address;
|
$location->address = $content->results[0]->formatted_address;
|
||||||
foreach ($content->results[0]->address_components as $component) {
|
foreach ($content->results[0]->address_components as $component) {
|
||||||
@@ -60,7 +61,6 @@ function mp_get_coordinates($id) {
|
|||||||
if (gettype($value) != "string")
|
if (gettype($value) != "string")
|
||||||
continue;
|
continue;
|
||||||
$value = trim($value, " ");
|
$value = trim($value, " ");
|
||||||
mp_console_log($value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $location;
|
return $location;
|
||||||
|
|||||||
@@ -78,24 +78,6 @@
|
|||||||
|
|
||||||
function mp_get_published_posts() {
|
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(
|
$get_posts_args = array(
|
||||||
'numberposts' => -1,
|
'numberposts' => -1,
|
||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
@@ -127,6 +109,7 @@ function mp_fill_fields_value($id) {
|
|||||||
"adresse",
|
"adresse",
|
||||||
"prenom",
|
"prenom",
|
||||||
"nom",
|
"nom",
|
||||||
|
"test",
|
||||||
"location",
|
"location",
|
||||||
);
|
);
|
||||||
$event = (object)[];
|
$event = (object)[];
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ function mp_coord_already_exist(&$coordinates, &$locations) {
|
|||||||
|
|
||||||
function mp_sort_n_insert(&$event, &$locations) {
|
function mp_sort_n_insert(&$event, &$locations) {
|
||||||
$coordinates = $event->location->coordinates;
|
$coordinates = $event->location->coordinates;
|
||||||
|
mp_console_log("1");
|
||||||
if ($coordinates == null)
|
if ($coordinates == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ function mp_init_map() {
|
|||||||
* - let max_zoom = x
|
* - let max_zoom = x
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
let map_div = document.getElementById("ljdp_map");
|
let map_div = document.getElementById("ljdp_map");
|
||||||
//let filters_div = document.getElementById("ljdp_map_filters");
|
//let filters_div = document.getElementById("ljdp_map_filters");
|
||||||
g_infowindow = new google.maps.InfoWindow();
|
g_infowindow = new google.maps.InfoWindow();
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
font-size: 100%;
|
font-size: 100%;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #666;
|
color: #666;
|
||||||
border: 2px solid #ba197a;
|
border: 1px solid #ba197a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc( 50% - var(--size) / 2 - 1px );
|
top: calc( 50% - var(--size) / 2 - 1px );
|
||||||
left: calc( var(--left-offset) * -1 );
|
left: calc( var(--left-offset) * -1 );
|
||||||
border: 2px solid #ba197a;
|
border: 1px solid #ba197a;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: var(--size);
|
width: var(--size);
|
||||||
@@ -96,15 +96,16 @@
|
|||||||
background-color: #e3359e;
|
background-color: #e3359e;
|
||||||
background-color: #e74ba9;
|
background-color: #e74ba9;
|
||||||
background-color: #ea62b3;
|
background-color: #ea62b3;
|
||||||
*/
|
|
||||||
background-color: #ed78be;
|
background-color: #ed78be;
|
||||||
/*
|
|
||||||
background-color: #f08fc9;
|
background-color: #f08fc9;
|
||||||
background-color: #f3a5d4;
|
background-color: #f3a5d4;
|
||||||
background-color: #f6bcdf;
|
background-color: #f6bcdf;
|
||||||
background-color: #f9d2e9;
|
background-color: #f9d2e9;
|
||||||
background-color: #fce9f4;
|
background-color: #fce9f4;
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
background-color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@
|
|||||||
flex-shrink: 2;
|
flex-shrink: 2;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
*/
|
*/
|
||||||
border: 2px solid #ba197a;
|
border: 1px solid #ba197a;
|
||||||
background-color: #ba197a;
|
background-color: #ba197a;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
@@ -131,8 +132,5 @@
|
|||||||
#ljdp_map_filters {
|
#ljdp_map_filters {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
#ljdp_map_filters .filter_menu {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user