finally a tuto that seems ok

This commit is contained in:
lenovo
2022-10-26 19:55:16 +02:00
parent c9e794b4ec
commit 40963ce3cb
7 changed files with 52 additions and 28 deletions

View 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;
}
?>

View 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
View File

@@ -1,31 +1,19 @@
<?php
/* Plugin Name: Google Map
Plugin URI: https://www.inkthemes.com/
Description: Integrate Google Maps on any page or post in a simple way.
/* Plugin Name: gmap_test
Plugin URI:
Description: Integrate Google Maps on any page or post in a simple way
Version: 1.0
Author: Jaya Rai
Author URI: https://www.inkthemes.com/
Author: hugogogo
Author URI:
*/
?>
<?php
include_once('debug.php');
require_once('get_url.php');
?>
// https://www.inkthemes.com/implement-google-map-plugin-for-wodpress/
// 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;
}
<?php
add_action('admin_menu', 'ink_menu_page');
function ink_menu_page() {
@@ -75,18 +63,17 @@ function show_google_map() {
$GoogleMap_Latitude = get_option('googleMap_latitude_position');
$GoogleMap_Longitude = get_option('googleMap_longitude_position');
$GoogleMap_zoom = get_option('map_zoom_value');
?>
<script
//src="https://maps.googleapis.com/maps/api/geocode/json?address=paris&key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE
?>
<script async defer
src="http://maps.googleapis.com/maps/api/js?&sensor=false?&key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE">
</script>
<div class="latitude"><?php echo $GoogleMap_Latitude; ?></div>
<div class="longitude" ><?php echo $GoogleMap_Longitude; ?></div>
<div class="zoom"><?php echo $GoogleMap_zoom; ?></div>
<div id="showmap"> </div>
<?php
<?php
}
add_shortcode('googlemap', 'show_google_map');
?>

0
srcs/plugins/google_map/script.js Executable file → Normal file
View File

0
srcs/plugins/google_map/style.css Executable file → Normal file
View File