finally a tuto that seems ok
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
- [symlink pbm with php-fpm](https://joshtronic.com/2019/07/29/symlinks-with-nginx-and-php-fpm/)
|
- [symlink pbm with php-fpm](https://joshtronic.com/2019/07/29/symlinks-with-nginx-and-php-fpm/)
|
||||||
- [my post on unix stack](https://unix.stackexchange.com/questions/722503/symlink-doent-works-with-nginx-and-php-fpm-and-docker/722511#722511)
|
- [my post on unix stack](https://unix.stackexchange.com/questions/722503/symlink-doent-works-with-nginx-and-php-fpm-and-docker/722511#722511)
|
||||||
- [my post on wordpress stack](https://wordpress.stackexchange.com/questions/410735/i-dont-understand-how-symlinks-in-plugin-work)
|
- [my post on wordpress stack](https://wordpress.stackexchange.com/questions/410735/i-dont-understand-how-symlinks-in-plugin-work)
|
||||||
|
- [maps api in php](http://www.learningaboutelectronics.com/Articles/Google-maps-API-JSON-PHP.php)
|
||||||
|
|
||||||
---
|
---
|
||||||
---
|
---
|
||||||
|
|||||||
13
srcs/plugins/google_map/debug.php
Normal file
13
srcs/plugins/google_map/debug.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// https://stackify.com/how-to-log-to-console-in-php/
|
||||||
|
function console_log($output, $with_script_tags = true) {
|
||||||
|
$js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) .
|
||||||
|
');';
|
||||||
|
if ($with_script_tags) {
|
||||||
|
$js_code = '<script>' . $js_code . '</script>';
|
||||||
|
}
|
||||||
|
echo $js_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
23
srcs/plugins/google_map/get_url.php
Normal file
23
srcs/plugins/google_map/get_url.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function get_url( $url ) {
|
||||||
|
if ( in_array('curl', get_loaded_extensions()) ) {
|
||||||
|
$args = curl_init();
|
||||||
|
|
||||||
|
curl_setopt($args, CURLOPT_AUTOREFERER, TRUE);
|
||||||
|
curl_setopt($args, CURLOPT_HEADER, 0);
|
||||||
|
curl_setopt($args, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($args, CURLOPT_REFERER, site_url());
|
||||||
|
curl_setopt($args, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($args, CURLOPT_FOLLOWLOCATION, TRUE);
|
||||||
|
|
||||||
|
$data = curl_exec($args);
|
||||||
|
curl_close($args);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
console_log("curl is not installed");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
39
srcs/plugins/google_map/index.php
Executable file → Normal file
39
srcs/plugins/google_map/index.php
Executable file → Normal file
@@ -1,31 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Plugin Name: Google Map
|
/* Plugin Name: gmap_test
|
||||||
Plugin URI: https://www.inkthemes.com/
|
Plugin URI:
|
||||||
Description: Integrate Google Maps on any page or post in a simple way.
|
Description: Integrate Google Maps on any page or post in a simple way
|
||||||
Version: 1.0
|
Version: 1.0
|
||||||
Author: Jaya Rai
|
Author: hugogogo
|
||||||
Author URI: https://www.inkthemes.com/
|
Author URI:
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
include_once('debug.php');
|
||||||
|
require_once('get_url.php');
|
||||||
|
?>
|
||||||
|
|
||||||
// https://www.inkthemes.com/implement-google-map-plugin-for-wodpress/
|
<?php
|
||||||
// Error: Publishing failed. The response is not a valid JSON response.
|
|
||||||
// -> https://wordpress.org/support/topic/publishing-failed-error-message-the-response-is-not-a-valid-json-response-2/
|
|
||||||
// - solution permalink -> broken
|
|
||||||
// - permalink broken : https://wordpress.org/support/topic/permalinks-change-breaks-all-links/
|
|
||||||
// - solution classic editor -> ok
|
|
||||||
|
|
||||||
// https://stackify.com/how-to-log-to-console-in-php/
|
|
||||||
function console_log($output, $with_script_tags = true) {
|
|
||||||
$js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) .
|
|
||||||
');';
|
|
||||||
if ($with_script_tags) {
|
|
||||||
$js_code = '<script>' . $js_code . '</script>';
|
|
||||||
}
|
|
||||||
echo $js_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('admin_menu', 'ink_menu_page');
|
add_action('admin_menu', 'ink_menu_page');
|
||||||
function ink_menu_page() {
|
function ink_menu_page() {
|
||||||
@@ -75,18 +63,17 @@ function show_google_map() {
|
|||||||
$GoogleMap_Latitude = get_option('googleMap_latitude_position');
|
$GoogleMap_Latitude = get_option('googleMap_latitude_position');
|
||||||
$GoogleMap_Longitude = get_option('googleMap_longitude_position');
|
$GoogleMap_Longitude = get_option('googleMap_longitude_position');
|
||||||
$GoogleMap_zoom = get_option('map_zoom_value');
|
$GoogleMap_zoom = get_option('map_zoom_value');
|
||||||
|
//src="https://maps.googleapis.com/maps/api/geocode/json?address=paris&key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE
|
||||||
?>
|
?>
|
||||||
<script
|
<script async defer
|
||||||
src="http://maps.googleapis.com/maps/api/js?&sensor=false?&key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE">
|
src="http://maps.googleapis.com/maps/api/js?&sensor=false?&key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE">
|
||||||
</script>
|
</script>
|
||||||
<div class="latitude"><?php echo $GoogleMap_Latitude; ?></div>
|
<div class="latitude"><?php echo $GoogleMap_Latitude; ?></div>
|
||||||
<div class="longitude" ><?php echo $GoogleMap_Longitude; ?></div>
|
<div class="longitude" ><?php echo $GoogleMap_Longitude; ?></div>
|
||||||
<div class="zoom"><?php echo $GoogleMap_zoom; ?></div>
|
<div class="zoom"><?php echo $GoogleMap_zoom; ?></div>
|
||||||
<div id="showmap"> </div>
|
<div id="showmap"> </div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
add_shortcode('googlemap', 'show_google_map');
|
add_shortcode('googlemap', 'show_google_map');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
0
srcs/plugins/google_map/script.js
Executable file → Normal file
0
srcs/plugins/google_map/script.js
Executable file → Normal file
0
srcs/plugins/google_map/style.css
Executable file → Normal file
0
srcs/plugins/google_map/style.css
Executable file → Normal file
@@ -37,7 +37,7 @@ function add_map_api(){
|
|||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
add_action('wp_head', 'add_map_api');
|
//add_action('wp_head', 'add_map_api');
|
||||||
|
|
||||||
function print_content($content){
|
function print_content($content){
|
||||||
|
|
||||||
@@ -93,6 +93,6 @@ function print_content($content){
|
|||||||
//$content .= "<div id='map'><p>OSM map 2</p></div>";
|
//$content .= "<div id='map'><p>OSM map 2</p></div>";
|
||||||
return $content;
|
return $content;
|
||||||
};
|
};
|
||||||
add_action('the_content', 'print_content', 1);
|
//add_action('the_content', 'print_content', 1);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user