80 lines
2.2 KiB
PHP
80 lines
2.2 KiB
PHP
<?php
|
|
/* Plugin Name: gmap_test
|
|
Plugin URI:
|
|
Description: Integrate Google Maps on any page or post in a simple way
|
|
Version: 1.0
|
|
Author: hugogogo
|
|
Author URI:
|
|
*/
|
|
?>
|
|
|
|
<?php
|
|
include_once('debug.php');
|
|
require_once('get_url.php');
|
|
?>
|
|
|
|
<?php
|
|
|
|
add_action('admin_menu', 'ink_menu_page');
|
|
function ink_menu_page() {
|
|
add_menu_page('GM', 'Google Map', 'manage_options', 'gm_setting', 'ink_gm_setting', '', 120);
|
|
}
|
|
function ink_gm_setting(){
|
|
?>
|
|
<h2>Google Map</h2>
|
|
<form action="" method="post">
|
|
<div class="ink_set">
|
|
<label>Latitude : </label>
|
|
<input type="text" name="latitude" class="gm_lat">
|
|
</div>
|
|
<div class="ink_set">
|
|
<label>Longitude : </label>
|
|
<input type="text" name="longitude" class="gm_log">
|
|
</div>
|
|
<div class="ink_set">
|
|
<label>Zoom : </label>
|
|
<input type="text" name="zoom" class="gm_zoom">
|
|
</div>
|
|
<input type="submit" name="submit" class="submit_button">
|
|
</form>
|
|
<?php
|
|
}
|
|
|
|
if(isset($_POST['submit'])){
|
|
$latitude = $_POST['latitude'];
|
|
$logitude = $_POST['longitude'];
|
|
$zoom = $_POST['zoom'];
|
|
$map_type = $_POST['map_type'];
|
|
update_option('googleMap_latitude_position', $latitude );
|
|
update_option('googleMap_longitude_position', $logitude );
|
|
update_option('map_zoom_value', $zoom);
|
|
}
|
|
|
|
add_action( 'init', 'my_init_script' );
|
|
function my_init_script() {
|
|
$script_path = plugins_url('script.js', __FILE__);
|
|
wp_enqueue_script('my_script', $script_path, array('jquery'));
|
|
$style_path = plugins_url('style.css', __FILE__);
|
|
wp_enqueue_style('my_style', $style_path);
|
|
}
|
|
|
|
add_shortcode('googlemap', 'show_google_map');
|
|
function show_google_map() {
|
|
global $wpdb;
|
|
$GoogleMap_Latitude = get_option('googleMap_latitude_position');
|
|
$GoogleMap_Longitude = get_option('googleMap_longitude_position');
|
|
$GoogleMap_zoom = get_option('map_zoom_value');
|
|
//src="https://maps.googleapis.com/maps/api/geocode/json?address=paris&key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE
|
|
return '
|
|
<script
|
|
src="https://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>
|
|
';
|
|
}
|
|
|
|
?>
|