WP Google Map - Version 1.0.0

Version Description

  • Initial version of Google Map Embed Plugin.
Download this release

Release Info

Developer milonfci
Plugin Icon 128x128 WP Google Map
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

assets/css/wp-gmap-style.css ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******* For Google Map Rendering ******/
2
+ .controls {
3
+ margin-top: 10px;
4
+ border: 1px solid transparent;
5
+ border-radius: 2px 0 0 2px;
6
+ box-sizing: border-box;
7
+ -moz-box-sizing: border-box;
8
+ height: 32px;
9
+ outline: none;
10
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
11
+ }
12
+
13
+ #pac-input {
14
+ background-color: #fff;
15
+ font-family: Roboto;
16
+ font-size: 15px;
17
+ font-weight: 300;
18
+ margin-left: 12px;
19
+ padding: 0 11px 0 13px;
20
+ text-overflow: ellipsis;
21
+ width: 300px;
22
+ }
23
+
24
+ #pac-input:focus {
25
+ border-color: #4d90fe;
26
+ }
27
+
28
+ .pac-container {
29
+ font-family: Roboto;
30
+ z-index: 99999;
31
+ }
32
+
33
+ #type-selector {
34
+ color: #fff;
35
+ background-color: #4d90fe;
36
+ padding: 5px 11px 0px 11px;
37
+ }
38
+
39
+ #type-selector label {
40
+ font-family: Roboto;
41
+ font-size: 13px;
42
+ font-weight: 300;
43
+ }
44
+
45
+ #target {
46
+ width: 345px;
47
+ }
48
+
49
+ /******* Google Map Settings ******/
50
+ #gmap_container_inner {
51
+ background-color: white;
52
+ float: left;
53
+ width: 100%;
54
+ }
55
+
56
+ .popup-content {
57
+ position: relative;
58
+ width: 60%;
59
+ }
60
+
61
+ /******* Map Nav Related ********/
62
+ ul#wp-gmap-nav {
63
+ list-style-type: none;
64
+ padding: 0;
65
+ margin: 0px;
66
+ }
67
+
68
+ ul#wp-gmap-nav li {
69
+ display: inline-block;
70
+ background-color: #32c896;
71
+ border-bottom: solid 5px #238b68;
72
+ color: #fff;
73
+ cursor: pointer;
74
+ }
75
+
76
+ ul#wp-gmap-nav li:hover, ul#wp-gmap-nav .active {
77
+ background-color: #238b68;
78
+ }
79
+
80
+ ul#wp-gmap-nav li a {
81
+ color: white;
82
+ text-decoration: none;
83
+ display: block;
84
+ padding: 5px 20px;
85
+ font-weight: bold;
86
+ }
87
+
88
+ /******* Map Tab Related ******/
89
+ #wp-gmap-tabs .wp-gmap-tab-content {
90
+ display: none;
91
+ }
92
+
93
+ #wp-gmap-tabs .active {
94
+ display: block;
95
+ }
96
+
97
+ /******* Map List Related ******/
98
+ .wp-gmap-list {
99
+ padding: 1%;
100
+ float: left;
101
+ width: 97%;
102
+ }
103
+
104
+ .wp-gmap-single {
105
+ padding: .2% 1%;
106
+ float: left;
107
+ width: 97%;
108
+ border: 1px #ccc solid;
109
+ margin: 7px 0px;
110
+ background-color: #f3f3f3;
111
+ }
112
+
113
+ .wp-gmap-single-left {
114
+ width: 80%;
115
+ float: left;
116
+ }
117
+
118
+ .wp-gmap-single-title {
119
+ font-size: 18px;
120
+ font-weight: 600;
121
+ padding: 5px 0;
122
+ }
123
+
124
+ .wp-gmap-single-action {
125
+ width: 20%;
126
+ padding: 13px 0;
127
+ float: left;
128
+ text-align: right;
129
+ }
130
+
131
+ /******* Map Properties ******/
132
+ .wp-gmap-properties {
133
+ width: 30%;
134
+ padding: 1%;
135
+ border: 1px #ccc solid;
136
+ background-color: #f3f3f3;
137
+ margin: 9px;
138
+ float: left;
139
+ }
140
+
141
+ .gmap_properties tr {
142
+ height: 50px;
143
+ }
144
+ .gmap_properties tr .regular-text{
145
+ width: 24em !important;
146
+ }
147
+
148
+ /******* To Preview Map ******/
149
+ .wp-gmap-preview {
150
+ width: 62%;
151
+ padding: 1%;
152
+ border: 1px #ccc solid;
153
+ background-color: #f3f3f3;
154
+ margin: 9px;
155
+ float: left;
156
+ }
assets/js/custom.js ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ $(function () {
3
+
4
+ //******* On Open Button Click *******
5
+ //$('body #srm_gmap_embed,body #srm_gmap_embed1').on('click', openSrmGmapPopup);
6
+
7
+ //******* On Close Button Click*******
8
+ $(document.body).on('click', '.wp_gmap_close_btn', removeSrmGmapPopup);
9
+
10
+ //******* On Escape Button Click *******
11
+ $(document).keyup(function (e) {
12
+ if (e.which == 27) {
13
+ removeSrmGmapPopup();
14
+ }
15
+ });
16
+
17
+ //******* To Open Gmap Popup *******
18
+ function openSrmGmapPopup() {
19
+ $("body #cboxOverlay,#wp_gmap_popup_container").css('display', 'block');
20
+ readyGmapPopupWindow();
21
+ }
22
+
23
+ //******* Removing Popup Box *******
24
+ function removeSrmGmapPopup() {
25
+ self.parent.tb_remove();
26
+ }
27
+
28
+ //******* To load Maps List *******
29
+ function loadSrmGmapsList() {
30
+ $("#wp-gmap-all").find(".spinner").addClass('is-active');
31
+ $("#wpgmapembed_list").html('');
32
+ var data = {
33
+ 'action': 'wpgmapembed_popup_load_map_data',
34
+ 'data': ''
35
+ };
36
+ jQuery.post(ajaxurl, data, function (response) {
37
+ $("#wp-gmap-all").find(".spinner").removeClass('is-active');
38
+ $("#wpgmapembed_list").html(response);
39
+ });
40
+ }
41
+
42
+ //******* Initiate Google Map/List *******
43
+ function readyGmapPopupWindow() {
44
+ loadSrmGmapsList();
45
+ }
46
+ window.onload = readyGmapPopupWindow;
47
+
48
+ //******* To insert ShortCode From List *******
49
+ $(document.body).on('click', ".wpgmap-insert-shortcode", function () {
50
+
51
+ var shortcode = $(this).parent().parent().find('.wpgmap-shortcode').val();
52
+ if (!tinyMCE.activeEditor || tinyMCE.activeEditor.isHidden()) {
53
+ $('textarea#content').val(shortcode);
54
+ } else {
55
+ tinyMCE.execCommand('mceInsertContent', false, shortcode);
56
+ }
57
+ removeSrmGmapPopup();
58
+ });
59
+
60
+ //******* To Edit/Update Map Data *******
61
+ $(document.body).on('click', ".wpgmap-insert-delete", function () {
62
+ if (!confirm("Are you sure to Delete")) {
63
+ return false;
64
+ }
65
+ $("#wp-gmap-nav").find('.spinner').addClass('is-active');
66
+ var btn_class = $(this);
67
+ btn_class.prop('disabled', true);
68
+ var post_id = $(this).data('id');
69
+ var data = {
70
+ 'action': 'wpgmapembed_remove_wpgmap',
71
+ 'post_id': post_id
72
+ };
73
+
74
+ jQuery.post(ajaxurl, data, function (response) {
75
+ response = JSON.parse(response);
76
+ btn_class.prop('disabled', false);
77
+ window.location.reload();
78
+ });
79
+ });
80
+
81
+ //************** On Save, Update and Insert Button on Click
82
+ $(document.body).on('click', "#wp-gmap-embed-save,#wp-gmap-embed-save-and-insert,#wp-gmap-embed-update", function () {
83
+
84
+ $(this).prop('disabled', true);
85
+
86
+ var btn_id = $(this).attr('id');
87
+
88
+ if (btn_id == 'wp-gmap-embed-save') {
89
+ var parent = $("body #wp-gmap-new");
90
+ } else if (btn_id == 'wp-gmap-embed-update') {
91
+ var parent = $("body #wp-gmap-edit");
92
+ }
93
+
94
+
95
+ $(this).parent().find(".spinner").addClass('is-active');
96
+
97
+ // getting checkbox value
98
+ if (parent.find("#wpgmap_show_heading").is(':checked') === true) {
99
+ var wpgmap_show_heading = 1;
100
+ } else {
101
+ var wpgmap_show_heading = 0;
102
+ }
103
+
104
+ if (parent.find("#wpgmap_show_infowindow").is(':checked') === true) {
105
+ var wpgmap_show_infowindow = 1;
106
+ } else {
107
+ var wpgmap_show_infowindow = 0;
108
+ }
109
+
110
+ var wpgmap_title = parent.find("#wpgmap_title").val();
111
+ var wpgmap_latlng = parent.find("#wpgmap_latlng").val();
112
+ var wpgmap_map_zoom = parent.find("#wpgmap_map_zoom").val();
113
+ var wpgmap_map_width = parent.find("#wpgmap_map_width").val();
114
+ var wpgmap_map_height = parent.find("#wpgmap_map_height").val();
115
+ var wpgmap_map_type = parent.find("#wpgmap_map_type").val();
116
+ var wpgmap_map_address = parent.find("#wpgmap_map_address").val();
117
+
118
+ var map_data = {
119
+ wpgmap_title: wpgmap_title,
120
+ wpgmap_show_heading: wpgmap_show_heading,
121
+ wpgmap_latlng: wpgmap_latlng,
122
+ wpgmap_map_zoom: wpgmap_map_zoom,
123
+ wpgmap_map_width: wpgmap_map_width,
124
+ wpgmap_map_height: wpgmap_map_height,
125
+ wpgmap_map_type: wpgmap_map_type,
126
+ wpgmap_map_address: wpgmap_map_address,
127
+ wpgmap_show_infowindow: wpgmap_show_infowindow
128
+ };
129
+
130
+ if (btn_id == 'wp-gmap-embed-save') {
131
+ map_data.action_type = 'save';
132
+ } else if (btn_id == 'wp-gmap-embed-update') {
133
+ map_data.action_type = 'update';
134
+ map_data.post_id = parent.find("#wpgmap_map_id").val();
135
+ }
136
+
137
+ var data = {
138
+ 'action': 'wpgmapembed_save_map_data',
139
+ 'map_data': map_data
140
+ };
141
+
142
+
143
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
144
+ jQuery.post(ajaxurl, data, function (response) {
145
+ $("#" + btn_id).parent().find(".spinner").removeClass('is-active');
146
+ response = JSON.parse(response);
147
+ if (response.responseCode == 0) {
148
+ $("#" + btn_id).prop('disabled', false);
149
+ parent.find('.wpgmap_msg_error').html('<div class="error bellow-h2 notice notice-error is-dismissible"><p>' + response.message + '</p></div>');
150
+ } else {
151
+
152
+ if (btn_id == 'wp-gmap-embed-save' || btn_id == 'wp-gmap-embed-update') {
153
+
154
+ $("#" + btn_id).prop('disabled', false);
155
+ // readyGmapPopupWindow();
156
+ window.location.href = '?page=wpgmapembed';
157
+ $('body #wp-gmap-all .wpgmap_msg_error').html('<div class="success bellow-h2 notice notice-success is-dismissible"><p>' + response.message + '</p></div>');
158
+ }
159
+ $("#wpgmap_title,#wpgmap_latlng, #wpgmap_map_address").val("");
160
+ $("#wpgmap_show_heading,#wpgmap_show_infowindow").prop("checked", false);
161
+
162
+ }
163
+ });
164
+ });
165
+
166
+ });
167
+ })(jQuery);
assets/js/geo_based_map.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function initWpGmap(lat, lng) {
2
+ google.maps.event.addDomListener(window, 'load',
3
+ initAutocomplete('map', 'pac-input', lat, lng, 'roadmap', 13)
4
+ );
5
+ }
6
+ var tryAPIGeolocation = function () {
7
+ jQuery.post("https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyBcVcz5OZ6eNBi5d7CFYHIdtsEI5BQlm68", function (success) {
8
+ initWpGmap(success.location.lat, success.location.lng);
9
+ })
10
+ .fail(function (err) {
11
+ console.log("API Geolocation error! \n\n" + err);
12
+ });
13
+ };
14
+ var browserGeolocationSuccess = function (position) {
15
+ initWpGmap(position.coords.latitude, position.coords.longitude);
16
+ };
17
+
18
+ var browserGeolocationFail = function (error) {
19
+ switch (error.code) {
20
+ case error.TIMEOUT:
21
+ console.log("Browser geolocation error !\n\nTimeout.");
22
+ initWpGmap(40.73359922990751, -74.02791395625002);
23
+ break;
24
+ case error.PERMISSION_DENIED:
25
+ tryAPIGeolocation();
26
+ break;
27
+ case error.POSITION_UNAVAILABLE:
28
+ console.log("Browser geolocation error !\n\nPosition unavailable.");
29
+ initWpGmap(40.73359922990751, -74.02791395625002);
30
+ break;
31
+
32
+ }
33
+ };
34
+
35
+ var tryGeolocation = function () {
36
+ if (navigator.geolocation) {
37
+ navigator.geolocation.getCurrentPosition(
38
+ browserGeolocationSuccess,
39
+ browserGeolocationFail,
40
+ {maximumAge: 50000, timeout: 20000, enableHighAccuracy: true});
41
+ } else {
42
+ initWpGmap(40.73359922990751, -74.02791395625002);
43
+ }
44
+ };
45
+
46
+ tryGeolocation();
assets/js/srm_gmap_loader.js ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function wpgmapSetAddressByLatLng(lat, lng, id) {
2
+ jQuery.getJSON('https://maps.googleapis.com/maps/api/geocode/json?latlng=' + lat + ',' + lng + '&sensor=true')
3
+ .done(function (location) {
4
+
5
+ document.getElementById('wpgmap_map_address').value = location.results[0].formatted_address;
6
+
7
+ });
8
+
9
+ }
10
+
11
+ // to render Google Map
12
+ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
13
+ document.getElementById("wpgmap_latlng").value = center_lat + "," + center_lng;
14
+
15
+ wpgmapSetAddressByLatLng(center_lat, center_lng);
16
+
17
+ var map = new google.maps.Map(document.getElementById(id), {
18
+ center: {lat: center_lat, lng: center_lng},
19
+ zoom: zoom,
20
+ mapTypeId: map_type
21
+ });
22
+ var marker1 = new google.maps.Marker({
23
+ position: new google.maps.LatLng(center_lat, center_lng),
24
+ title: "",
25
+ draggable: true,
26
+ animation: google.maps.Animation.DROP
27
+ });
28
+ marker1.setMap(map);
29
+ // Create the search box and link it to the UI element.
30
+ var input = document.getElementById(input);
31
+ var searchBox = new google.maps.places.SearchBox(input);
32
+ map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
33
+
34
+ // Bias the SearchBox results towards current map's viewport.
35
+ map.addListener('bounds_changed', function () {
36
+ searchBox.setBounds(map.getBounds());
37
+ });
38
+
39
+ var markers = [];
40
+ // Listen for the event fired when the user selects a prediction and retrieve
41
+ // more details for that place.
42
+ searchBox.addListener('places_changed', function () {
43
+
44
+ var places = searchBox.getPlaces();
45
+
46
+ if (places.length == 0) {
47
+ return;
48
+ }
49
+ marker1.setMap(null);
50
+ // Clear out the old markers.
51
+ markers.forEach(function (marker) {
52
+ marker.setMap(null);
53
+ });
54
+ markers = [];
55
+
56
+ // For each place, get the icon, name and location.
57
+ var bounds = new google.maps.LatLngBounds();
58
+ places.forEach(function (place) {
59
+ if (!place.geometry) {
60
+ console.log("Returned place contains no geometry");
61
+ return;
62
+ }
63
+ // Create a marker for each place.
64
+ markers.push(new google.maps.Marker({
65
+ map: map,
66
+ title: place.name,
67
+ draggable: true,
68
+ position: place.geometry.location
69
+ }));
70
+
71
+ document.getElementById("wpgmap_latlng").value = place.geometry.location.lat() + "," + place.geometry.location.lng();
72
+ wpgmapSetAddressByLatLng(place.geometry.location.lat(), place.geometry.location.lng());
73
+
74
+ if (place.geometry.viewport) {
75
+ // Only geocodes have viewport.
76
+ bounds.union(place.geometry.viewport);
77
+ } else {
78
+ bounds.extend(place.geometry.location);
79
+ }
80
+ });
81
+ map.fitBounds(bounds);
82
+ markers[0].addListener('dragend', function (markerLocation) {
83
+ document.getElementById("wpgmap_latlng").value = markerLocation.latLng.lat() + "," + markerLocation.latLng.lng();
84
+ wpgmapSetAddressByLatLng(markerLocation.latLng.lat(), markerLocation.latLng.lng());
85
+ });
86
+
87
+ });
88
+ marker1.addListener('dragend', function (markerLocation) {
89
+ document.getElementById("wpgmap_latlng").value = markerLocation.latLng.lat() + "," + markerLocation.latLng.lng();
90
+ wpgmapSetAddressByLatLng(markerLocation.latLng.lat(), markerLocation.latLng.lng());
91
+ });
92
+
93
+ }
gmap_icon_18.png ADDED
Binary file
includes/gmap.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit;
3
+ if (isset($_GET['page'])) {
4
+ $wpgmap_page = esc_html($_GET['page']);
5
+ $wpgmap_tag = '';
6
+ if (isset($_GET['tag'])) {
7
+ $wpgmap_tag = esc_html($_GET['tag']);
8
+ }
9
+ ?>
10
+ <div class="wrap">
11
+ <script type="text/javascript"
12
+ src="<?php echo esc_url(plugins_url("../assets/js/srm_gmap_loader.js", __FILE__)); ?>"></script>
13
+ <div id="gmap_container_inner">
14
+ <!--modal contents-->
15
+
16
+ <ul id="wp-gmap-nav">
17
+ <li class="<?php echo ($wpgmap_page == 'wpgmapembed' && $wpgmap_tag == '') ? 'active' : ''; ?>">
18
+ <a href="<?php echo admin_url(); ?>admin.php?page=wpgmapembed" data-id="wp-gmap-all"
19
+ class="media-menu-item">All Maps</a>
20
+ </li>
21
+ <li class="<?php echo $wpgmap_tag == 'new' ? 'active' : ''; ?>">
22
+ <a href="<?php echo esc_url(admin_url().'admin.php?page=wpgmapembed&tag=new'); ?>" data-id="wp-gmap-new"
23
+ class="media-menu-item">Create New Map</a>
24
+ </li>
25
+ <span class="spinner" style="margin-right: 20px !important;float:right"></span>
26
+ </ul>
27
+
28
+ <div id="wp-gmap-tabs">
29
+ <!---------------------------new map tab-------------->
30
+ <?php
31
+ if ($wpgmap_page == 'wpgmapembed' && $wpgmap_tag == '') {
32
+ ?>
33
+ <div class="wp-gmap-tab-content active" id="wp-gmap-all">
34
+ <?php
35
+ require_once (plugin_dir_path(__FILE__) . '/wpgmap_list.php');
36
+ ?>
37
+ </div>
38
+ <?php
39
+ }
40
+ ?>
41
+ <!---------------------------new map tab-------------->
42
+
43
+ <div
44
+ class="wp-gmap-tab-content <?php echo ($_GET['page'] == 'wpgmapembed' && $_GET['tag'] == 'new') ? 'active' : ''; ?>"
45
+ id="wp-gmap-new">
46
+ <?php
47
+ if ($wpgmap_page == 'wpgmapembed' && $wpgmap_tag == 'new') {
48
+ require_once (plugin_dir_path(__FILE__) . '/wpgmap_create.php');
49
+ }
50
+ ?>
51
+ </div>
52
+
53
+ <!---------------------------Existing map update-------------->
54
+
55
+ <div
56
+ class="wp-gmap-tab-content <?php echo ($wpgmap_page == 'wpgmapembed' && $wpgmap_tag == 'edit') ? 'active' : ''; ?>"
57
+ id="wp-gmap-edit">
58
+ <?php
59
+ if ($wpgmap_page == 'wpgmapembed' && $wpgmap_tag == 'edit') {
60
+ require_once (plugin_dir_path(__FILE__) . '/wpgmap_edit.php');
61
+ }
62
+ ?>
63
+ </div>
64
+
65
+ </div>
66
+ </div>
67
+ </div>
68
+ <?php
69
+ }
70
+ ?>
includes/shortcodes.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit;
3
+ // ************* Google Map SRM Shortcode***************
4
+ if (!function_exists('srm_gmap_embed_shortcode')) {
5
+
6
+ function srm_gmap_embed_shortcode($atts, $content)
7
+ {
8
+ static $count;
9
+ if (!$count) {
10
+ $count = 0;
11
+ }
12
+ $count++;
13
+
14
+ $wpgmap_title = esc_html(get_post_meta($atts['id'], 'wpgmap_title', true));
15
+ $wpgmap_show_heading = esc_html(get_post_meta($atts['id'], 'wpgmap_show_heading', true));
16
+ $wpgmap_latlng = esc_html(get_post_meta($atts['id'], 'wpgmap_latlng', true));
17
+ $wpgmap_map_zoom = esc_html(get_post_meta($atts['id'], 'wpgmap_map_zoom', true));
18
+ $wpgmap_map_width = esc_html(get_post_meta($atts['id'], 'wpgmap_map_width', true));
19
+ $wpgmap_map_height = esc_html(get_post_meta($atts['id'], 'wpgmap_map_height', true));
20
+ $wpgmap_map_type = esc_html(get_post_meta($atts['id'], 'wpgmap_map_type', true));
21
+ $wpgmap_map_address = esc_html(get_post_meta($atts['id'], 'wpgmap_map_address', true));
22
+ $wpgmap_show_infowindow = get_post_meta($atts['id'], 'wpgmap_show_infowindow', true);
23
+
24
+ ob_start();
25
+
26
+ if (isset($wpgmap_show_heading) && $wpgmap_show_heading == 1) {
27
+ echo "<h1>" . $wpgmap_title . "</h1>";
28
+ }
29
+ ?>
30
+ <script type="text/javascript">
31
+ google.maps.event.addDomListener(window, 'load', function () {
32
+ var map = new google.maps.Map(document.getElementById("srm_gmp_embed_<?php echo $count; ?>"), {
33
+ center: new google.maps.LatLng(<?php echo $wpgmap_latlng;?>),
34
+ zoom:<?php echo $wpgmap_map_zoom;?>,
35
+ mapTypeId: google.maps.MapTypeId.<?php echo $wpgmap_map_type;?>
36
+ });
37
+
38
+ var marker = new google.maps.Marker({
39
+ position: new google.maps.LatLng(<?php echo $wpgmap_latlng;?>),
40
+ map: map,
41
+ animation: google.maps.Animation.DROP
42
+ });
43
+ marker.setMap(map);
44
+
45
+ <?php
46
+ if($wpgmap_show_infowindow){
47
+ ?>
48
+ var infowindow = new google.maps.InfoWindow({
49
+ content: "<?php echo $wpgmap_map_address;?>"
50
+ });
51
+
52
+ infowindow.open(map, marker);
53
+
54
+ google.maps.event.addListener(marker, 'click', function () {
55
+ infowindow.open(map, marker);
56
+ });
57
+
58
+ <?php
59
+ }
60
+ ?>
61
+
62
+ });
63
+ </script>
64
+
65
+ <div id="srm_gmp_embed_<?php echo $count; ?>"
66
+ style="width:<?php echo $wpgmap_map_width . ' !important'; ?>;height:<?php echo $wpgmap_map_height; ?> !important;margin:5px 0; ">
67
+
68
+ </div>
69
+ <?php
70
+ return ob_get_clean();
71
+ }
72
+
73
+ }
74
+
75
+ //******* Define Shortcode for Google Map SRM
76
+ add_shortcode('gmap-embed', 'srm_gmap_embed_shortcode');
includes/widget.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit;
3
+ /**
4
+ * Creating widget for Google Map SRM
5
+ */
6
+ class srmgmap_widget extends WP_Widget
7
+ {
8
+
9
+ public $base_id = 'srmgmap_widget'; //widget id
10
+ public $widget_name = 'Google Map SRM'; //widget name
11
+ public $widget_options = array(
12
+ 'description' => 'Google Map SRM' //widget description
13
+ );
14
+
15
+ public function __construct()
16
+ {
17
+ parent::__construct($this->base_id, $this->widget_name, $this->widget_options);
18
+ }
19
+
20
+ // Map display in front
21
+ public function widget($args, $instance)
22
+ {
23
+ extract($args);
24
+ extract($instance);
25
+ echo $before_widget. $before_title;
26
+ echo do_shortcode($instance['srmgmap_shortcode']);
27
+ echo $after_widget;
28
+ }
29
+
30
+ /**
31
+ * Google Map Widget
32
+ * @return String $instance
33
+ */
34
+ public function form($instance)
35
+ {
36
+ ?>
37
+ <p>
38
+ <label for="<?php echo $this->get_field_id('srmgmap_shortcode'); ?>"> Enter Google Map Shortcode:</label>
39
+ </p>
40
+ <p>
41
+ <input id="<?php echo $this->get_field_id('srmgmap_shortcode'); ?>"
42
+ name="<?php echo $this->get_field_name('srmgmap_shortcode'); ?>"
43
+ value='<?php echo esc_attr(esc_html(isset($instance['srmgmap_shortcode'])?$instance['srmgmap_shortcode']:'')); ?>' type="text" class="widefat">
44
+ </p>
45
+
46
+ <?php
47
+ }
48
+
49
+ }
50
+
51
+ add_action('widgets_init', create_function('', 'return register_widget("srmgmap_widget");'));
includes/wpgmap_create.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('ABSPATH')) exit; ?>
2
+ <div data-columns="8">
3
+
4
+ <span class="wpgmap_msg_error" style="width:80%;">
5
+ <!--validation error will goes here-->
6
+ </span>
7
+
8
+ <!-- google map properties -->
9
+ <div class="wp-gmap-properties">
10
+ <table class="gmap_properties">
11
+ <tr>
12
+ <td>
13
+ <label for="wpgmap_title"><b>Map Title</b></label><br/>
14
+ <input id="wpgmap_title" name="wpgmap_title" value="" type="text"
15
+ class="regular-text">
16
+ <br/>
17
+
18
+ <input type="checkbox" value="1" name="wpgmap_show_heading"
19
+ id="wpgmap_show_heading">
20
+ <label for="wpgmap_show_heading">Show as map title</label>
21
+ </td>
22
+ </tr>
23
+ <tr>
24
+ <td>
25
+ <label for="wpgmap_latlng"><b>Latitude, Longitude</b></label><br/>
26
+ <input id="wpgmap_latlng" name="wpgmap_latlng" value="" type="text"
27
+ class="regular-text">
28
+ </td>
29
+ </tr>
30
+
31
+ <tr>
32
+ <td>
33
+ <label for="wpgmap_map_zoom"><b>Zoom</b></label><br/>
34
+ <input id="wpgmap_map_zoom" name="wpgmap_map_zoom" value="13" type="text"
35
+ class="regular-text">
36
+ </td>
37
+ </tr>
38
+
39
+ <tr>
40
+ <td>
41
+ <label for="wpgmap_map_width"><b>Width (%)</b></label><br/>
42
+ <input id="wpgmap_map_width" name="wpgmap_map_width" value="100%"
43
+ type="text" class="regular-text">
44
+ </td>
45
+ </tr>
46
+
47
+ <tr>
48
+ <td>
49
+ <label for="wpgmap_map_height"><b>Height (px)</b></label><br/>
50
+ <input id="wpgmap_map_height" name="wpgmap_map_height" value="300px"
51
+ type="text" class="regular-text">
52
+ </td>
53
+ </tr>
54
+
55
+ <tr>
56
+ <td>
57
+ <label for="wpgmap_map_type"><b>Map Type</b></label><br/>
58
+ <select id="wpgmap_map_type" class="regular-text" style="width:25em;">
59
+ <option>ROADMAP</option>
60
+ <option>SATELLITE</option>
61
+ <option>HYBRID</option>
62
+ <option>TERRAIN</option>
63
+ </select>
64
+ </td>
65
+ </tr>
66
+
67
+ <tr>
68
+ <td>
69
+ <label for="wpgmap_map_address"><b>Location Address</b></label><br/>
70
+ <input type="text" id="wpgmap_map_address" style="width:25em;"
71
+ name="wpgmap_map_address" class="regular-text">
72
+
73
+ <br/>
74
+
75
+ <label for="wpgmap_show_infowindow"><input type="checkbox" value="1"
76
+ name="wpgmap_show_infowindow"
77
+ id="wpgmap_show_infowindow">
78
+ Show in marker infowindow</label>
79
+ </td>
80
+ </tr>
81
+
82
+ </table>
83
+ </div>
84
+
85
+
86
+ <div class="wp-gmap-preview">
87
+ <input id="pac-input" class="controls" type="text" placeholder="Search Box"/>
88
+ <div id="map" style="height: 415px;"></div>
89
+ </div>
90
+
91
+ <script type="text/javascript"
92
+ src="<?php echo esc_url(plugins_url("../assets/js/geo_based_map.js", __FILE__)); ?>"></script>
93
+ </div>
94
+
95
+ <div class="media-frame-toolbar">
96
+ <div class="media-toolbar">
97
+ <div class="media-toolbar-secondary"
98
+ style="text-align: right;float: right;margin-top:10px;">
99
+ <span class="spinner" style="margin: 0px !important;float:left;"></span>
100
+ <button class="button button-primary" id="wp-gmap-embed-save">Save</button>
101
+ </div>
102
+ </div>
103
+ </div>
includes/wpgmap_edit.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit;
3
+ $gmap_data = $this->get_wpgmapembed_data(intval($_GET['id']));
4
+ $wpgmap_single = json_decode($gmap_data);
5
+ list($wpgmap_lat, $wpgmap_lng) = explode(',', esc_html($wpgmap_single->wpgmap_latlng));
6
+ ?>
7
+ <div data-columns="8">
8
+ <!-- getting hidden id-->
9
+ <input id="wpgmap_map_id" name="wpgmap_map_id" value="<?php echo intval($_GET['id']); ?>" type="hidden"/>
10
+
11
+ <span class="wpgmap_msg_error" style="width:80%;">
12
+ <!-- error will goes here-->
13
+ </span>
14
+
15
+ <div class="wp-gmap-properties">
16
+ <table style="width: 100% !important;" class="gmap_properties">
17
+ <tr>
18
+ <td>
19
+ <label for="wpgmap_title"><b>Map Title</b></label><br/>
20
+ <input id="wpgmap_title" name="wpgmap_title" value="<?php echo esc_attr($wpgmap_single->wpgmap_title); ?>"
21
+ type="text"
22
+ class="regular-text">
23
+ <br/>
24
+
25
+ <input type="checkbox" value="1" name="wpgmap_show_heading"
26
+ id="wpgmap_show_heading" <?php echo ($wpgmap_single->wpgmap_show_heading == 1) ? 'checked' : ''; ?>>
27
+ <label for="wpgmap_show_heading">Show as map title</label>
28
+ </td>
29
+ </tr>
30
+ <tr>
31
+ <td>
32
+ <label for="wpgmap_latlng"><b>Latitude, Longitude</b></label><br/>
33
+ <input id="wpgmap_latlng" name="wpgmap_latlng" value="<?php echo esc_attr($wpgmap_single->wpgmap_latlng); ?>"
34
+ type="text"
35
+ class="regular-text">
36
+ </td>
37
+ </tr>
38
+
39
+ <tr>
40
+ <td>
41
+ <label for="wpgmap_map_zoom"><b>Zoom</b></label><br/>
42
+ <input id="wpgmap_map_zoom" name="wpgmap_map_zoom"
43
+ value="<?php echo esc_attr($wpgmap_single->wpgmap_map_zoom); ?>" type="text"
44
+ class="regular-text">
45
+ </td>
46
+ </tr>
47
+
48
+ <tr>
49
+ <td>
50
+ <label for="wpgmap_map_width"><b>Width (%)</b></label><br/>
51
+ <input id="wpgmap_map_width" name="wpgmap_map_width"
52
+ value="<?php echo esc_attr($wpgmap_single->wpgmap_map_width); ?>"
53
+ type="text" class="regular-text">
54
+ </td>
55
+ </tr>
56
+
57
+ <tr>
58
+ <td>
59
+ <label for="wpgmap_map_height"><b>Height (px)</b></label><br/>
60
+ <input id="wpgmap_map_height" name="wpgmap_map_height"
61
+ value="<?php echo esc_attr($wpgmap_single->wpgmap_map_height); ?>"
62
+ type="text" class="regular-text">
63
+ </td>
64
+ </tr>
65
+
66
+ <tr>
67
+ <td>
68
+ <label><b>Map Type</b></label><br/>
69
+ <select id="wpgmap_map_type" class="regular-text" style="width:25em;">
70
+ <option <?php echo $wpgmap_single->wpgmap_map_type == 'ROADMAP' ? 'selected' : ''; ?>>ROADMAP
71
+ </option>
72
+ <option <?php echo $wpgmap_single->wpgmap_map_type == 'SATELLITE' ? 'selected' : ''; ?>>
73
+ SATELLITE
74
+ </option>
75
+ <option <?php echo $wpgmap_single->wpgmap_map_type == 'HYBRID' ? 'selected' : ''; ?>>HYBRID
76
+ </option>
77
+ <option <?php echo $wpgmap_single->wpgmap_map_type == 'TERRAIN' ? 'selected' : ''; ?>>TERRAIN
78
+ </option>
79
+ </select>
80
+ </td>
81
+ </tr>
82
+
83
+ <tr>
84
+ <td>
85
+ <label for="wpgmap_map_address"><b>Location Address</b></label><br/>
86
+ <textarea id="wpgmap_map_address" style="width:25em;" name="wpgmap_map_address" class="regular-text"
87
+ rows="3"><?php echo esc_attr(trim($wpgmap_single->wpgmap_map_address)); ?></textarea>
88
+
89
+ <br/>
90
+
91
+ <label for="wpgmap_show_infowindow"><input type="checkbox" value="1"
92
+ name="wpgmap_show_infowindow"
93
+ id="wpgmap_show_infowindow" <?php echo ($wpgmap_single->wpgmap_show_infowindow == 1) ? 'checked' : ''; ?>>
94
+ Show in marker infowindow</label>
95
+ </td>
96
+ </tr>
97
+
98
+ </table>
99
+ </div>
100
+
101
+ <div class="wp-gmap-preview">
102
+ <input id="pac-input" class="controls" type="text" placeholder="Search Box"/>
103
+ <div id="map" style="height: 415px;"></div>
104
+ </div>
105
+ <script>
106
+ (function ($) {
107
+ $(function () {
108
+ google.maps.event.addDomListener(window, 'load',
109
+ initAutocomplete('map', 'pac-input',<?php echo $wpgmap_lat;?>,<?php echo $wpgmap_lng;?>, 'roadmap',<?php echo $wpgmap_single->wpgmap_map_zoom;?>)
110
+ );
111
+ });
112
+ })(jQuery);
113
+ </script>
114
+
115
+ </div>
116
+
117
+ <div class="media-frame-toolbar">
118
+ <div class="media-toolbar">
119
+ <div class="media-toolbar-secondary"
120
+ style="text-align: right;float: right;margin-top:10px;">
121
+ <span class="spinner" style="margin: 0px !important;float:left;"></span>
122
+ <button class="button button-primary" id="wp-gmap-embed-update">Update</button>
123
+ </div>
124
+ </div>
125
+ </div>
includes/wpgmap_list.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('ABSPATH')) exit; ?>
2
+ <div data-columns="8">
3
+
4
+ <span class="wpgmap_msg_error" style="width:80%;">
5
+
6
+ </span>
7
+ <!--all map tab-->
8
+ <div class="wp-gmap-list">
9
+
10
+ <div id="wpgmapembed_lialoy to...st">
11
+ <?php
12
+ $this->load_wpgmapembed_list();
13
+ ?>
14
+ </div>
15
+
16
+ </div>
17
+ </div>
includes/wpgmap_popup_content.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit;
3
+ //this button will show a popup that contains inline content
4
+ add_action('media_buttons_context', 'add_srm_gmap_embed_custom_button');
5
+
6
+ //This will be shown in the inline modal
7
+ add_action('admin_footer', 'srm_add_inline_popup_content');
8
+
9
+ //action to add a custom button to the content editor
10
+ function add_srm_gmap_embed_custom_button($context)
11
+ {
12
+
13
+ //path to my icon
14
+ $img = plugins_url('../gmap_icon_18.png', __FILE__);
15
+
16
+ //the id of the container I want to show in the popup
17
+ $container_id = 'wp_gmap_popup_container';
18
+
19
+ //our popup's title
20
+ $title = 'Select your map properties to insert into post';
21
+
22
+ //append the icon
23
+ $context .= "<a class='button thickbox' title='{$title}'
24
+ href='#TB_inline?width=700&height=450&inlineId={$container_id}'>
25
+ " . '<span class="wp-media-buttons-icon" style="background: url(' . $img . '); background-repeat: no-repeat; background-position: left bottom;"></span>' . "Embed Google Map</a>";
26
+
27
+ return $context;
28
+ }
29
+
30
+ function srm_add_inline_popup_content()
31
+ {
32
+ ?>
33
+
34
+ <div id="wp_gmap_popup_container" style="display:none;">
35
+ <!--modal contents-->
36
+
37
+ <div id="wp-gmap-tabs">
38
+
39
+ <!---------------------------new map tab-------------->
40
+ <div class="wp-gmap-tab-content active" id="wp-gmap-all">
41
+
42
+
43
+
44
+ <span class="wpgmap_msg_error" style="width:80%;">
45
+
46
+ </span>
47
+ <!--all map tab-->
48
+ <div class="wp-gmap-list">
49
+
50
+ <a href="<?php echo esc_url(admin_url() . 'admin.php?page=wpgmapembed&amp;tag=new'); ?>"
51
+ data-id="wp-gmap-new" class="media-menu-item" style="float:right;">Create New
52
+ Map</a>
53
+ <span class="spinner is-active"
54
+ style="margin: 0px !important;float:left;"></span>
55
+
56
+ <div id="wpgmapembed_list"></div>
57
+
58
+ </div>
59
+ </div>
60
+ </div>
61
+
62
+ </div>
63
+ <?php
64
+ }
65
+
66
+ ?>
readme.txt ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Google Map ===
2
+ Contributors: milonfci
3
+ Donate link: http://www.srmilon.com/
4
+ Tags: Google Map Embed, Google Map, gmap, google map embed, wp map, wp map embed, map embed, best google maps, best maps, bing maps, cross browser, custom google map, custom google maps, map direction, easy map, geo, geocoder, gmaps, google earth, google map plugin, google map shortcode, google map widget, google maps v3, googlemaps, gprs, gps, gpx, kml, latitude, Longitude, location, loaction by address, map, map directions, map markers, map plugin, map shortcode, map styles, maps google, post map, map point, polygons, roads, routes, store locator, street view, wp google map, contact page map, google map wordpress, google maps wordpress, google maps for wordpress, simple google map, simple google map plugin, wp google maps,maps
5
+ Requires at least: 2.9
6
+ Tested up to: 4.6.1
7
+ Stable tag: 1.0.1
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Very Simple, light-weight and Easy to use Google Map Embed plugin help's to embed Google Custom Map with markers in Posts, Pages as shortcode and sidebar as widget.
12
+
13
+ == Description ==
14
+
15
+ Google Map Embed is awesome plugin to add Google Custom map in website.It is fully customizable and can be use as shortcode.
16
+
17
+
18
+ ### Features of Google Map Embed Plugin:
19
+
20
+ * **User friendly and easy to use.**
21
+ * **Importing the shortcode by Embed Google Map Button upon Editor**
22
+ * **Fully Customizable.**
23
+ * **Automatic google map location identification**
24
+ * **Tested with other popular plugins.**
25
+ * **Ability to change Latitude, Longitude, Address by Dragging Marker.**
26
+ * **Ability to change zoom level(1-15)**
27
+ * **Easy to add as widget (By Shortcode)**
28
+ * **Ability to use as shortcode in post and Single page**
29
+ * **It can be use in single page, single post, sidebar, footer etc**
30
+
31
+ Feel free to ask me, if you faces any problem with installation or else in my email address: milonfci@gmail.com
32
+
33
+ == Installation ==
34
+
35
+ ### It's simple:
36
+
37
+ 1. [Download](https://plugins.svn.wordpress.org/gmap-embed/) Google Map Embed Plugin.
38
+ 2. Upload that zip folder plugins directory "wp-content/plugins"
39
+ 3. Activate the Google Map Embed plugin from Admin panel.
40
+ 4. Add Google Map Embed widget to your sidebar with Shortcode.
41
+ 5. Add Google Map Embed in posts/pages using shortcode.
42
+
43
+ Upgrade Google Map Embed Plugin from [here](https://plugins.svn.wordpress.org/gmap-embed/) to get updated features.
44
+
45
+ == Frequently Asked Questions ==
46
+
47
+ Our Google Map Embed Plugin is user friendly plugin, but here you can see some frequently asked questions that will help you.
48
+
49
+ = How can i create new map? =
50
+ After install the plugin, Click on Google Map SRM in the left side bar. Then click on = Create New map =
51
+
52
+ = How can i see created Maps list? =
53
+ Click on Google Map SRM in the left side bar, here Created Maps list will apper.
54
+
55
+ = How to add Google Map in Post =
56
+ Go to =Posts=->=Add New= then you will see a button named "Embed Google Map" beside media button. Click on it and insert your desired map by click ing on Insert Button, then save post and the map will appear in your desired post. Enjoy!
57
+
58
+
59
+ = How to add Google Map in Pages =
60
+ Go to =Pages=->=Add New= then you will see a button named "Embed Google Map" beside media button. Click on it and insert your desired map by click ing on Insert Button, then save post and the map will appear in your desired post. Enjoy!
61
+
62
+
63
+ = How to add Google Map as widget =
64
+ Go to =Appearence=->=Widget= then you will see a widget named "Google Map SRM". Drag it to any widget area and enter Google Map Shortcode then save it and the map will appear in your sidebar or footer whatever you selected. Enjoy!
65
+
66
+ == Screenshots ==
67
+
68
+ 1. Google Map SRM menu in left sidebar
69
+ 2. To create New Map
70
+ 3. To Allow Locatoin Sharing
71
+ 4. Creating New Map and Saving
72
+ 5. Map List with Shortcode
73
+ 6. To Embed Shortcode in Pages, Posts and Widgets
74
+ 7. Maps list going to insert
75
+ 8. Using as Widget
76
+
77
+ == Changelog ==
78
+
79
+ = 1.0.0 =
80
+
81
+ * Initial version of Google Map Embed Plugin.
82
+
83
+ = 1.0.1 =
84
+
85
+ * Updated screenshots with FAQ to make easier.
srm_gmap_embed.php ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Google Map Embed
4
+ Plugin URI: http://www.srmilon.com
5
+ Description: The plugin will help to google map Embed in post and pages also in sidebar with widget.
6
+ Author: SRMILON
7
+ Author URI: http://www.srmilon.com
8
+ Version: 1.0.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ if (!class_exists('srm_gmap_embed_main')):
14
+
15
+ class srm_gmap_embed_main
16
+ {
17
+
18
+ private $plugin_name = 'Google Map SRM';
19
+
20
+ /**
21
+ * constructor function
22
+ */
23
+ function __construct()
24
+ {
25
+ add_action('wp_enqueue_scripts', array($this, 'gmap_enqueue_scripts'));
26
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_gmap_scripts'));
27
+ add_action('admin_menu', array($this, 'gmap_create_menu'));
28
+ add_action('admin_init', array($this, 'gmap_register_fields'));
29
+ add_action('wp_ajax_wpgmapembed_save_map_data', array($this, 'save_wpgmapembed_data'));
30
+ add_action('wp_ajax_wpgmapembed_load_map_data', array($this, 'load_wpgmapembed_list'));
31
+ add_action('wp_ajax_wpgmapembed_popup_load_map_data', array($this, 'load_popup_wpgmapembed_list'));
32
+ add_action('wp_ajax_wpgmapembed_get_wpgmap_data', array($this, 'get_wpgmapembed_data'));
33
+ add_action('wp_ajax_wpgmapembed_remove_wpgmap', array($this, 'remove_wpgmapembed_data'));
34
+ }
35
+
36
+ /**
37
+ * To enqueue scripts for front-end
38
+ */
39
+ public function gmap_enqueue_scripts()
40
+ {
41
+ //including map library
42
+ wp_enqueue_script('srm_gmap_api', 'http://maps.googleapis.com/maps/api/js?key=AIzaSyBcVcz5OZ6eNBi5d7CFYHIdtsEI5BQlm68&libraries=places', array('jquery'));
43
+ }
44
+
45
+ function enqueue_admin_gmap_scripts()
46
+ {
47
+ global $pagenow;
48
+ if ($pagenow == 'post.php' || $pagenow == 'post-new.php' || @$_GET['page'] == 'wpgmapembed') {
49
+ wp_enqueue_script('wp-gmap-api', 'https://maps.google.com/maps/api/js?key=AIzaSyBcVcz5OZ6eNBi5d7CFYHIdtsEI5BQlm68&libraries=places', array('jquery'), '20161019', true);
50
+ wp_enqueue_script('wp-gmap-custom-js', plugins_url('assets/js/custom.js', __FILE__), array('wp-gmap-api'), '20161019', false);
51
+ wp_enqueue_style('wp-gmap-embed-css', plugins_url('assets/css/wp-gmap-style.css', __FILE__));
52
+ }
53
+ }
54
+
55
+
56
+ /**
57
+ * To create menu in admin panel
58
+ */
59
+ public function gmap_create_menu()
60
+ {
61
+
62
+ //create new top-level menu
63
+ add_menu_page($this->plugin_name, $this->plugin_name, 'administrator', 'wpgmapembed', array($this, 'srm_gmap_main'), 'dashicons-location');
64
+ }
65
+
66
+ public function gmap_register_fields()
67
+ {
68
+ //register fields
69
+ register_setting('gmap_settings_group', 'gmap_title');
70
+ register_setting('gmap_settings_group', 'gmap_lat');
71
+ register_setting('gmap_settings_group', 'gmap_long');
72
+ register_setting('gmap_settings_group', 'gmap_width');
73
+ register_setting('gmap_settings_group', 'gmap_height');
74
+ register_setting('gmap_settings_group', 'gmap_zoom');
75
+ register_setting('gmap_settings_group', 'gmap_type');
76
+ }
77
+
78
+ /**
79
+ * Google Map Embed Mail Page
80
+ */
81
+ public function srm_gmap_main()
82
+ {
83
+ require plugin_dir_path(__FILE__) . '/includes/gmap.php';
84
+ }
85
+
86
+ /*
87
+ * To update post meta data
88
+ */
89
+
90
+ public function __update_post_meta($post_id, $field_name, $value = '')
91
+ {
92
+ if (!get_post_meta($post_id, $field_name)) {
93
+ add_post_meta($post_id, $field_name, $value);
94
+ } else {
95
+ update_post_meta($post_id, $field_name, $value);
96
+ }
97
+ }
98
+
99
+ /**
100
+ * To save New Map Data
101
+ */
102
+
103
+ public function save_wpgmapembed_data()
104
+ {
105
+ $error = '';
106
+ // Getting ajax fileds value
107
+ $meta_data = array(
108
+ 'wpgmap_title' => sanitize_text_field(esc_html($_POST['map_data']['wpgmap_title'])),
109
+ 'wpgmap_show_heading' => sanitize_text_field(esc_html($_POST['map_data']['wpgmap_show_heading'])),
110
+ 'wpgmap_latlng' => sanitize_text_field(esc_html($_POST['map_data']['wpgmap_latlng'])),
111
+ 'wpgmap_map_zoom' => sanitize_text_field(esc_html($_POST['map_data']['wpgmap_map_zoom'])),
112
+ 'wpgmap_map_width' => sanitize_text_field(esc_html($_POST['map_data']['wpgmap_map_width'])),
113
+ 'wpgmap_map_height' => sanitize_text_field(esc_html($_POST['map_data']['wpgmap_map_height'])),
114
+ 'wpgmap_map_type' => sanitize_text_field(esc_html($_POST['map_data']['wpgmap_map_type'])),
115
+ 'wpgmap_map_address' => sanitize_text_field(esc_html($_POST['map_data']['wpgmap_map_address'])),
116
+ 'wpgmap_show_infowindow' => sanitize_text_field($_POST['map_data']['wpgmap_show_infowindow'])
117
+ );
118
+ $action_type = sanitize_text_field(esc_html($_POST['map_data']['action_type']));
119
+ if ($meta_data['wpgmap_latlng'] == '') {
120
+ $error = "Please input Latitude and Longitude";
121
+ }
122
+ if (strlen($error) > 0) {
123
+ echo json_encode(array(
124
+ 'responseCode' => 0,
125
+ 'message' => $error
126
+ ));
127
+ exit;
128
+ } else {
129
+
130
+ if ($action_type == 'save') {
131
+ // saving post array
132
+ $post_array = array(
133
+ 'post_type' => 'wpgmapembed'
134
+ );
135
+ $post_id = wp_insert_post($post_array);
136
+
137
+ } elseif ($action_type == 'update') {
138
+ $post_id = intval($_POST['map_data']['post_id']);
139
+ }
140
+
141
+ // Updating post meta
142
+ foreach ($meta_data as $key => $value) {
143
+ $this->__update_post_meta($post_id, $key, $value);
144
+ }
145
+ $returnArray = array(
146
+ 'responseCode' => 1,
147
+ 'post_id' => $post_id
148
+ );
149
+ if ($action_type == 'save') {
150
+ $returnArray['message'] = 'Created Successfully.';
151
+ } elseif ($action_type == 'update') {
152
+ $returnArray['message'] = 'Updated Successfully.';
153
+ }
154
+ echo json_encode($returnArray);
155
+ exit;
156
+ }
157
+ }
158
+
159
+ public function load_wpgmapembed_list()
160
+ {
161
+ $content = '';
162
+ $args = array(
163
+ 'post_type' => 'wpgmapembed'
164
+ );
165
+ $mapsList = new WP_Query($args);
166
+
167
+ if ($mapsList->have_posts()) {
168
+ while ($mapsList->have_posts()) {
169
+ $mapsList->the_post();
170
+ $title = get_post_meta(get_the_ID(), 'wpgmap_title', true);
171
+ $content .= '<div class="wp-gmap-single">
172
+ <div class="wp-gmap-single-left">
173
+ <div class="wp-gmap-single-title">
174
+ ' . $title . '
175
+ </div>
176
+ <div class="wp-gmap-single-shortcode">
177
+ <input class="wpgmap-shortcode regular-text" type="text" value="'.esc_attr('[gmap-embed id=&quot;' . get_the_ID() . '&quot;]').'"
178
+ onclick="this.select()"/>
179
+ </div>
180
+ </div>
181
+ <div class="wp-gmap-single-action">
182
+ <a href="?page=wpgmapembed&tag=edit&id=' . get_the_ID() . '" class="button media-button button-primary button-large wpgmap-edit" data-id="' . get_the_ID() . '">
183
+ Change
184
+ </a>
185
+ <button type="button"
186
+ class="button media-button button-danger button-large wpgmap-insert-delete" data-id="' . get_the_ID() . '" style="background-color: red;color: white;opacity:0.7;">
187
+ X
188
+ </button>
189
+ </div>
190
+ </div>';
191
+ }
192
+ } else {
193
+ $content = "You have not created any Map yet. ";
194
+ $content .= '<a href="' . esc_url(admin_url()) . 'admin.php?page=wpgmapembed&amp;tag=new"
195
+ data-id="wp-gmap-new" class="media-menu-item">Create New
196
+ Map</a>';
197
+ }
198
+
199
+ echo $content;
200
+
201
+
202
+ }
203
+
204
+ public function load_popup_wpgmapembed_list()
205
+ {
206
+ $content = '';
207
+ $args = array(
208
+ 'post_type' => 'wpgmapembed'
209
+ );
210
+ $mapsList = new WP_Query($args);
211
+
212
+ while ($mapsList->have_posts()) {
213
+ $mapsList->the_post();
214
+ $title = get_post_meta(get_the_ID(), 'wpgmap_title', true);
215
+ $content .= '<div class="wp-gmap-single">
216
+ <div class="wp-gmap-single-left">
217
+ <div class="wp-gmap-single-title">
218
+ ' . $title . '
219
+ </div>
220
+ <div class="wp-gmap-single-shortcode">
221
+ <input class="wpgmap-shortcode regular-text" type="text" value="[gmap-embed id=&quot;' . get_the_ID() . '&quot;]"
222
+ onclick="this.select()"/>
223
+ </div>
224
+ </div>
225
+ <div class="wp-gmap-single-action">
226
+ <button type="button"
227
+ class="button media-button button-primary button-large wpgmap-insert-shortcode">
228
+ Insert
229
+ </button>
230
+ </div>
231
+ </div>';
232
+ }
233
+ echo $content;
234
+ exit;
235
+
236
+
237
+ }
238
+
239
+ public function get_wpgmapembed_data($gmap_id = '')
240
+ {
241
+ if ($gmap_id == '') {
242
+ $gmap_id = intval($_POST['wpgmap_id']);
243
+ }
244
+
245
+ $gmap_data = array(
246
+ 'wpgmap_title' => get_post_meta($gmap_id, 'wpgmap_title', true),
247
+ 'wpgmap_show_heading' => get_post_meta($gmap_id, 'wpgmap_show_heading', true),
248
+ 'wpgmap_latlng' => get_post_meta($gmap_id, 'wpgmap_latlng', true),
249
+ 'wpgmap_map_zoom' => get_post_meta($gmap_id, 'wpgmap_map_zoom', true),
250
+ 'wpgmap_map_width' => get_post_meta($gmap_id, 'wpgmap_map_width', true),
251
+ 'wpgmap_map_height' => get_post_meta($gmap_id, 'wpgmap_map_height', true),
252
+ 'wpgmap_map_type' => get_post_meta($gmap_id, 'wpgmap_map_type', true),
253
+ 'wpgmap_map_address' => get_post_meta($gmap_id, 'wpgmap_map_address', true),
254
+ 'wpgmap_show_infowindow' => get_post_meta($gmap_id, 'wpgmap_show_infowindow', true)
255
+ );
256
+
257
+ return json_encode($gmap_data);
258
+ }
259
+
260
+ public function remove_wpgmapembed_data()
261
+ {
262
+
263
+ $meta_data = array(
264
+ 'wpgmap_title',
265
+ 'wpgmap_show_heading',
266
+ 'wpgmap_latlng',
267
+ 'wpgmap_map_zoom',
268
+ 'wpgmap_map_width',
269
+ 'wpgmap_map_height',
270
+ 'wpgmap_map_type',
271
+ 'wpgmap_map_address',
272
+ 'wpgmap_show_infowindow'
273
+ );
274
+
275
+ $post_id = intval($_POST['post_id']);
276
+ wp_delete_post($post_id);
277
+ foreach ($meta_data as $field_name => $value) {
278
+ delete_post_meta($post_id, $field_name, $value);
279
+ }
280
+ $returnArray = array(
281
+ 'responseCode' => 1,
282
+ 'message' => "Deleted Successfully."
283
+ );
284
+ echo json_encode($returnArray);
285
+ exit;
286
+ }
287
+
288
+ }
289
+
290
+ endif;
291
+ new srm_gmap_embed_main();
292
+ // including requird files
293
+ require_once plugin_dir_path(__FILE__) . '/includes/widget.php';
294
+ require_once plugin_dir_path(__FILE__) . '/includes/shortcodes.php';
295
+
296
+ if ($pagenow == 'post.php' || $pagenow == 'post-new.php') {
297
+ require_once plugin_dir_path(__FILE__) . '/includes/wpgmap_popup_content.php';
298
+ }