added link of pages for posts
This commit is contained in:
14
README.md
14
README.md
@@ -1,7 +1,17 @@
|
|||||||
|
|
||||||
# MAP
|
# MAP
|
||||||
|
|
||||||
### verifications:
|
#### todo
|
||||||
|
- [/] copy recent site version
|
||||||
|
- [ ] create links
|
||||||
|
- [ ] make links having map
|
||||||
|
- [ ] transform filter list in select
|
||||||
|
- [ ] make two infowindow size
|
||||||
|
if time:
|
||||||
|
- [ ] deal with error double event irl and online
|
||||||
|
- [ ] deal with multiplication of filters
|
||||||
|
- [ ] deal with window size
|
||||||
|
|
||||||
|
#### verifications:
|
||||||
- api only for this site on fabien's google account
|
- api only for this site on fabien's google account
|
||||||
- erased tmp css on site headers
|
- erased tmp css on site headers
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ require_once(dirname(__FILE__) . '/mp_url_api.php');
|
|||||||
require_once(dirname(__FILE__) . '/mp_add_to_scripts.php');
|
require_once(dirname(__FILE__) . '/mp_add_to_scripts.php');
|
||||||
require_once(dirname(__FILE__) . '/mp_get_coordinates.php');
|
require_once(dirname(__FILE__) . '/mp_get_coordinates.php');
|
||||||
require_once(dirname(__FILE__) . '/mp_get_events.php');
|
require_once(dirname(__FILE__) . '/mp_get_events.php');
|
||||||
require_once(dirname(__FILE__) . '/mp_sort_events.php');
|
require_once(dirname(__FILE__) . '/mp_get_locations.php');
|
||||||
require_once(dirname(__FILE__) . '/mp_get_filters.php');
|
require_once(dirname(__FILE__) . '/mp_get_filters.php');
|
||||||
require_once(dirname(__FILE__) . '/mp_address_errors.php');
|
require_once(dirname(__FILE__) . '/mp_address_errors.php');
|
||||||
require_once(dirname(__FILE__) . '/mp_create_div.php');
|
require_once(dirname(__FILE__) . '/mp_create_div.php');
|
||||||
@@ -127,14 +127,6 @@ add_shortcode('ljdp_errors_map', 'mp_errors_map');
|
|||||||
function post_published_coordinates($id, $post) {
|
function post_published_coordinates($id, $post) {
|
||||||
|
|
||||||
$location = mp_get_coordinates($id);
|
$location = mp_get_coordinates($id);
|
||||||
/*
|
|
||||||
coordinates;
|
|
||||||
street;
|
|
||||||
city;
|
|
||||||
country;
|
|
||||||
address;
|
|
||||||
approximate;
|
|
||||||
*/
|
|
||||||
|
|
||||||
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 );
|
||||||
|
|||||||
@@ -33,29 +33,32 @@ 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);
|
||||||
$location->coordinates = trim($content->results[0]->geometry->location, " ");
|
$location->coordinates = $content->results[0]->geometry->location;
|
||||||
$location->address = trim($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) {
|
||||||
if (in_array("street_number", $component->types))
|
if (in_array("street_number", $component->types))
|
||||||
$location->street = trim($component->long_name, " ");
|
$location->street = $component->long_name;
|
||||||
else if (in_array("route", $component->types)) {
|
else if (in_array("route", $component->types)) {
|
||||||
if (strlen($location->street) != 0)
|
if (strlen($location->street) != 0)
|
||||||
$location->street .= " ";
|
$location->street .= " ";
|
||||||
$location->street .= trim($component->long_name, " ");
|
$location->street .= $component->long_name;
|
||||||
}
|
}
|
||||||
else if (in_array("locality", $component->types))
|
else if (in_array("locality", $component->types))
|
||||||
$location->city = trim($component->long_name, " ");
|
$location->city = $component->long_name;
|
||||||
else if (in_array("postal_town", $component->types)) {
|
else if (in_array("postal_town", $component->types)) {
|
||||||
if (strlen($location->city) != 0)
|
if (strlen($location->city) != 0)
|
||||||
$location->city .= "/";
|
$location->city .= "/";
|
||||||
$location->city .= trim($component->long_name, " ");
|
$location->city .= $component->long_name;
|
||||||
}
|
}
|
||||||
else if (in_array("country", $component->types))
|
else if (in_array("country", $component->types))
|
||||||
$location->country = trim($component->long_name, " ");
|
$location->country = $component->long_name;
|
||||||
}
|
}
|
||||||
if ($content->results[0]->geometry->location_type == "APPROXIMATE")
|
if ($content->results[0]->geometry->location_type == "APPROXIMATE")
|
||||||
$location->approximate = true;
|
$location->approximate = true;
|
||||||
|
|
||||||
foreach ($location as $value) {
|
foreach ($location as $value) {
|
||||||
|
if (gettype($value) != "string")
|
||||||
|
continue;
|
||||||
$value = trim($value, " ");
|
$value = trim($value, " ");
|
||||||
mp_console_log($value);
|
mp_console_log($value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,24 +76,6 @@
|
|||||||
to_ping: ""
|
to_ping: ""
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// FUNCTION TO RETRIEVE FORMS FIELDS
|
|
||||||
// not used anymore
|
|
||||||
//
|
|
||||||
//function mp_get_form_fields() {
|
|
||||||
// $get_form_args = array(
|
|
||||||
// 'numberposts' => -1,
|
|
||||||
// 'post_status' => 'publish',
|
|
||||||
// 'post_type' => 'acf-field',
|
|
||||||
// );
|
|
||||||
// $forms = get_posts($get_form_args);
|
|
||||||
// $fields = [];
|
|
||||||
// foreach ($forms as $form) {
|
|
||||||
// $field = $form->post_excerpt;
|
|
||||||
// array_push($fields, $field);
|
|
||||||
// }
|
|
||||||
// return $fields;
|
|
||||||
//}
|
|
||||||
|
|
||||||
function mp_get_published_posts() {
|
function mp_get_published_posts() {
|
||||||
|
|
||||||
// FOR TESTS
|
// FOR TESTS
|
||||||
@@ -117,7 +99,6 @@ function mp_get_published_posts() {
|
|||||||
$get_posts_args = array(
|
$get_posts_args = array(
|
||||||
'numberposts' => -1,
|
'numberposts' => -1,
|
||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
//'post_status' => 'draft',
|
|
||||||
'post_type' => 'post',
|
'post_type' => 'post',
|
||||||
);
|
);
|
||||||
$posts_published = get_posts($get_posts_args);
|
$posts_published = get_posts($get_posts_args);
|
||||||
@@ -162,6 +143,9 @@ function mp_fill_fields_value($id) {
|
|||||||
if ($presentiel[0] === "En présentiel")
|
if ($presentiel[0] === "En présentiel")
|
||||||
$event->irl = true;
|
$event->irl = true;
|
||||||
|
|
||||||
|
// add post url
|
||||||
|
$event->url = get_post_permalink($id);
|
||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +177,7 @@ function mp_get_published_events() {
|
|||||||
- id : x;
|
- id : x;
|
||||||
- index : x (default null);
|
- index : x (default null);
|
||||||
- title : "";
|
- title : "";
|
||||||
|
- url : "";
|
||||||
- location : {}
|
- location : {}
|
||||||
- street : "";
|
- street : "";
|
||||||
- city : "";
|
- city : "";
|
||||||
|
|||||||
@@ -14,12 +14,9 @@ function attach_info_window(map, marker, events, infowindow) {
|
|||||||
presence = "en presentiel";
|
presence = "en presentiel";
|
||||||
|
|
||||||
window_content += `
|
window_content += `
|
||||||
<p>
|
<a href="${events[key].url}" target="_blank" rel="noopener noreferrer">
|
||||||
${events[key].title}
|
<p>${events[key].title}</p>
|
||||||
</p>
|
</a>
|
||||||
<p>
|
|
||||||
${presence}
|
|
||||||
</p>
|
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
window_content += '</div>';
|
window_content += '</div>';
|
||||||
|
|||||||
Reference in New Issue
Block a user