start importing data from posts
This commit is contained in:
@@ -52,76 +52,4 @@ function mp_add_div() {
|
|||||||
}
|
}
|
||||||
add_shortcode('lejourduprof_map', 'mp_add_div');
|
add_shortcode('lejourduprof_map', 'mp_add_div');
|
||||||
|
|
||||||
|
|
||||||
//function print_content($content){
|
|
||||||
//
|
|
||||||
// // print only on the page 'map', and other conditions
|
|
||||||
// // https://developer.wordpress.org/reference/hooks/the_content/
|
|
||||||
// if (!( is_page('map_prof') && in_the_loop() && is_main_query() ))
|
|
||||||
// return $content;
|
|
||||||
//
|
|
||||||
// // https://developer.wordpress.org/reference/functions/get_posts/
|
|
||||||
// $get_posts_args = array(
|
|
||||||
// 'numberposts' => -1,
|
|
||||||
// 'post_status' => 'publish',
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// $posts_list = get_posts($get_posts_args);
|
|
||||||
// $content .= "<p>";
|
|
||||||
// $content .= "nb posts published : ";
|
|
||||||
// $content .= count($posts_list);
|
|
||||||
// $content .= "</p>";
|
|
||||||
// foreach ($posts_list as $post_value) {
|
|
||||||
// $content .= "<div>";
|
|
||||||
// $content .= "- post title: [";
|
|
||||||
// $content .= $post_value->post_title;
|
|
||||||
// $content .= "] - content: [";
|
|
||||||
// $content .= $post_value->post_content;
|
|
||||||
// $content .= "]";
|
|
||||||
// $content .= "</div>";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // TESTS : print posts full content
|
|
||||||
// //
|
|
||||||
// //$posts_list = get_posts($args);
|
|
||||||
// //$content .= "<p>";
|
|
||||||
// //$content .= "nb posts published : ";
|
|
||||||
// //$content .= count($posts_list);
|
|
||||||
// //$content .= "</p>";
|
|
||||||
// //foreach ($posts_list as $post_key => $post_value) {
|
|
||||||
// // $content .= "<p>";
|
|
||||||
// // $content .= "post content : ";
|
|
||||||
// // $content .= $post_key;
|
|
||||||
// // $content .= " : ";
|
|
||||||
// // $content .= "<br>";
|
|
||||||
// // foreach ($post_value as $key => $value) {
|
|
||||||
// // $content .= "- [";
|
|
||||||
// // $content .= $key;
|
|
||||||
// // $content .= "]: [";
|
|
||||||
// // $content .= $value;
|
|
||||||
// // $content .= "]<br>";
|
|
||||||
// // }
|
|
||||||
// // $content .= "</p>";
|
|
||||||
// //}
|
|
||||||
//
|
|
||||||
// $content .= '<div id="map"></div>';
|
|
||||||
// $content .= '<script>
|
|
||||||
// function initMap() {
|
|
||||||
// var location = {lat: 38.8833, lng: -77.0167};
|
|
||||||
// var map = new google.maps.Map(document.getElementById("map"), {
|
|
||||||
// zoom: 12,
|
|
||||||
// center: location
|
|
||||||
// });
|
|
||||||
// var marker = new google.maps.Marker({
|
|
||||||
// position: location,
|
|
||||||
// map: map
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// </script>';
|
|
||||||
// $content .= '<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE&callback=initMap"></script>';
|
|
||||||
//
|
|
||||||
// return $content;
|
|
||||||
//};
|
|
||||||
//add_action('the_content', 'print_content', 1);
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,17 +1,66 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// // TESTS : print posts full content
|
||||||
|
// //
|
||||||
|
// //$posts_list = get_posts($args);
|
||||||
|
// //$content .= "<p>";
|
||||||
|
// //$content .= "nb posts published : ";
|
||||||
|
// //$content .= count($posts_list);
|
||||||
|
// //$content .= "</p>";
|
||||||
|
// //foreach ($posts_list as $post_key => $post_value) {
|
||||||
|
// // $content .= "<p>";
|
||||||
|
// // $content .= "post content : ";
|
||||||
|
// // $content .= $post_key;
|
||||||
|
// // $content .= " : ";
|
||||||
|
// // $content .= "<br>";
|
||||||
|
// // foreach ($post_value as $key => $value) {
|
||||||
|
// // $content .= "- [";
|
||||||
|
// // $content .= $key;
|
||||||
|
// // $content .= "]: [";
|
||||||
|
// // $content .= $value;
|
||||||
|
// // $content .= "]<br>";
|
||||||
|
// // }
|
||||||
|
// // $content .= "</p>";
|
||||||
|
// //}
|
||||||
|
|
||||||
function mp_get_locations() {
|
function mp_get_locations() {
|
||||||
$locations = '
|
|
||||||
let locations = [
|
// https://developer.wordpress.org/reference/functions/get_posts/
|
||||||
{lat: 38.8833, lng: -77.0167},
|
$get_posts_args = array(
|
||||||
{lat: 39.8833, lng: -76.0167},
|
'numberposts' => -1,
|
||||||
];
|
'post_status' => 'publish',
|
||||||
';
|
);
|
||||||
|
$posts_list = get_posts($get_posts_args);
|
||||||
|
$locs = "";
|
||||||
|
foreach ($posts_list as $post_key => $post_value) {
|
||||||
|
$locs .= "\n"
|
||||||
|
. 'post_key: '
|
||||||
|
. $post_key . "\n"
|
||||||
|
. 'post_value: ' . "\n";
|
||||||
|
foreach ($post_value as $key => $value) {
|
||||||
|
$locs .= " "
|
||||||
|
. $key
|
||||||
|
. ': '
|
||||||
|
. $value . "\n"
|
||||||
|
;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
mp_console_log("locs : \n" . $locs);
|
||||||
|
|
||||||
|
$locations =
|
||||||
|
'let locations = ['
|
||||||
|
. '{lat: 38.8833, lng: -77.0167}' . ','
|
||||||
|
. '{lat: 39.8833, lng: -76.0167}' . ','
|
||||||
|
. '];'
|
||||||
|
;
|
||||||
wp_add_inline_script('mp_init_map', $locations, 'before');
|
wp_add_inline_script('mp_init_map', $locations, 'before');
|
||||||
}
|
}
|
||||||
function mp_get_markers() {
|
function mp_get_markers() {
|
||||||
$markers = 'let icon_url = "'
|
$markers =
|
||||||
. '/wp-content/plugins/map_prof/marker.png'
|
'let icon_url = "'
|
||||||
. '";';
|
. '/wp-content/plugins/map_prof/marker.png'
|
||||||
|
. '";'
|
||||||
|
;
|
||||||
wp_add_inline_script('mp_init_map', $markers, 'before');
|
wp_add_inline_script('mp_init_map', $markers, 'before');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user