API KEY for Google Maps - Version 1.2.2

Version Description

  • Compatibility checked with WordPress 6.0 - CHECKED
  • Now tries to add api key even if no key param is found - CHANGED
  • Now only users with "manage_options" ability can update the API key - SECURITY
Download this release

Release Info

Developer stiofansisland
Plugin Icon 128x128 API KEY for Google Maps
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

api-key-for-google-maps.php CHANGED
@@ -17,7 +17,7 @@
17
  * Text Domain: gmaps-api-key
18
  * Domain Path: /languages
19
  * Requires at least: 3.1
20
- * Tested up to: 5.9
21
  */
22
 
23
  // If this file is called directly, abort.
@@ -30,7 +30,7 @@ if ( ! defined( 'WPINC' ) ) {
30
  *
31
  * @since 1.0.0
32
  */
33
- define( "GMAPIKEY_VERSION", "1.2.1" );
34
 
35
 
36
  add_action( 'plugins_loaded', 'rgmk_load_textdomain' );
@@ -48,14 +48,14 @@ add_filter( 'clean_url', 'rgmk_find_add_key', 99, 3 );
48
  /**
49
  * Clean url.
50
  *
51
- * @since 1.0.0
52
- * @package GMAPIKEY
53
- *
54
- * @param string $url Url.
55
  * @param string $original_url Original url.
56
- * @param string $_context Context.
57
  *
58
  * @return string Modified url.
 
 
 
59
  */
60
  function rgmk_find_add_key( $url, $original_url, $_context ) {
61
  $key = get_option( 'rgmk_google_map_api_key' );
@@ -66,10 +66,14 @@ function rgmk_find_add_key( $url, $original_url, $_context ) {
66
  }
67
 
68
  if ( strstr( $url, "maps.google.com/maps/api/js" ) !== false || strstr( $url, "maps.googleapis.com/maps/api/js" ) !== false ) {// it's a Google maps url
69
-
70
  if ( strstr( $url, "key=" ) === false ) {// it needs a key
71
  $url = add_query_arg( 'key', $key, $url );
72
  $url = str_replace( "&", "&", $url ); // or $url = $original_url
 
 
 
 
73
  }
74
 
75
  }
@@ -97,45 +101,58 @@ function rgmk_add_admin_menu() {
97
  * @package GMAPIKEY
98
  */
99
  function rgmk_add_admin_menu_html() {
100
- add_thickbox();
101
  $updated = false;
102
- if ( isset( $_POST['rgmk_google_map_api_key'] ) ) {
103
- $key = esc_attr( $_POST['rgmk_google_map_api_key'] );
 
104
  $updated = update_option( 'rgmk_google_map_api_key', $key );
105
  }
106
 
107
  if ( $updated ) {
108
  echo '<div class="updated fade"><p><strong>' . __( 'Key Updated!', 'gmaps-api-key' ) . '</strong></p></div>';
109
-
110
  }
111
  ?>
112
- <div class="wrap">
113
 
114
- <h2><?php _e( 'Retro Add Google Maps API KEY', 'gmaps-api-key' ); ?></h2>
115
- <p><?php _e( 'This plugin will attempt to add your Google API KEY to any Google Maps JS file that has properly been enqueued.', 'gmaps-api-key' ); ?></p>
116
- <p>
117
- <?php $gm_api_url = 'https://console.developers.google.com/henhouse/?pb=["hh-1","maps_backend",null,[],"https://developers.google.com",null,["static_maps_backend","street_view_image_backend","maps_embed_backend","places_backend","geocoding_backend","directions_backend","distance_matrix_backend","geolocation","elevation_backend","timezone_backend","maps_backend"],null]';?>
118
- <a id="gd-api-key" onclick='window.open("<?php echo wp_slash($gm_api_url);?>", "newwindow", "width=600, height=400"); return false;' href='<?php echo $gm_api_url;?>' class="button-primary" name="<?php _e('Generate API Key - ( MUST be logged in to your Google account )','gmaps-api-key');?>" ><?php _e('Generate API Key','gmaps-api-key');?></a>
 
 
 
119
 
120
  <?php echo sprintf( __( 'or %sclick here%s to Get a Google Maps API KEY - ( MUST be logged in to your Google account )', 'gmaps-api-key' ), '<a target="_blank" href=\'https://console.developers.google.com/flows/enableapi?apiid=static_maps_backend,street_view_image_backend,maps_embed_backend,places_backend,geocoding_backend,directions_backend,distance_matrix_backend,geolocation,elevation_backend,timezone_backend,maps_backend&keyType=CLIENT_SIDE&reusekey=true\'>', '</a>' ) ?>
121
- </p>
122
 
123
- <form method="post" action="options-general.php?page=gmaps-api-key">
124
- <label for="rgmk_google_map_api_key"><?php _e( 'Enter Google Maps API KEY', 'gmaps-api-key' ); ?></label>
125
- <input title="<?php _e( 'Add Google Maps API KEY', 'gmaps-api-key' ); ?>" type="text"
126
- name="rgmk_google_map_api_key" id="rgmk_google_map_api_key"
127
- placeholder="<?php _e( 'Enter your API KEY here', 'gmaps-api-key' ); ?>"
128
- style="padding: 6px; width:50%; display: block;"
129
- value="<?php echo esc_attr( get_option( 'rgmk_google_map_api_key' ) ); ?>"/>
130
 
131
  <?php
132
 
 
 
133
  submit_button();
134
 
135
  ?>
136
- </form>
 
 
137
 
138
- </div><!-- /.wrap -->
 
 
 
 
 
 
139
  <?php
140
  }
141
 
@@ -148,15 +165,16 @@ function rgmk_add_admin_menu_html() {
148
  function rgmk_show_geodirectory_offer() {
149
  if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'gmaps-api-key' ) {
150
 
151
- if ( defined( 'GEODIRECTORY_VERSION' ) || get_option( 'geodirectory_db_version' ) ) {
152
- return;
 
 
 
 
 
 
 
153
  }
154
- ?>
155
- <div class="notice notice-info is-dismissible rgmk-offer-notice">
156
- <img src="<?php echo plugin_dir_url( __FILE__ ) . '/gd_banner.jpg'; ?>"/>
157
- <p><?php echo sprintf( __( 'API KEY for Google Maps was created for free by %sGeoDirectory%s - The WordPress directory pluign. Discount Code: APIKEY25OFF', 'sample-text-domain' ), '<a target="_blank" href="https://wpgeodirectory.com/" >', '</a>' ); ?></p>
158
- </div>
159
- <?php
160
  }
161
  }
162
 
17
  * Text Domain: gmaps-api-key
18
  * Domain Path: /languages
19
  * Requires at least: 3.1
20
+ * Tested up to: 6.0
21
  */
22
 
23
  // If this file is called directly, abort.
30
  *
31
  * @since 1.0.0
32
  */
33
+ define( "GMAPIKEY_VERSION", "1.2.2" );
34
 
35
 
36
  add_action( 'plugins_loaded', 'rgmk_load_textdomain' );
48
  /**
49
  * Clean url.
50
  *
51
+ * @param string $url Url.
 
 
 
52
  * @param string $original_url Original url.
53
+ * @param string $_context Context.
54
  *
55
  * @return string Modified url.
56
+ * @since 1.0.0
57
+ * @package GMAPIKEY
58
+ *
59
  */
60
  function rgmk_find_add_key( $url, $original_url, $_context ) {
61
  $key = get_option( 'rgmk_google_map_api_key' );
66
  }
67
 
68
  if ( strstr( $url, "maps.google.com/maps/api/js" ) !== false || strstr( $url, "maps.googleapis.com/maps/api/js" ) !== false ) {// it's a Google maps url
69
+ $key = esc_attr( $key );
70
  if ( strstr( $url, "key=" ) === false ) {// it needs a key
71
  $url = add_query_arg( 'key', $key, $url );
72
  $url = str_replace( "&#038;", "&amp;", $url ); // or $url = $original_url
73
+ } else {
74
+ $url = remove_query_arg( 'key', $url );
75
+ $url = add_query_arg( 'key', $key, $url );
76
+ $url = str_replace( "&#038;", "&amp;", $url ); // or $url = $original_url
77
  }
78
 
79
  }
101
  * @package GMAPIKEY
102
  */
103
  function rgmk_add_admin_menu_html() {
104
+
105
  $updated = false;
106
+
107
+ if ( isset( $_POST['rgmk_google_map_api_key'] ) && ! empty( $_POST['rgmk_nonce'] ) && wp_verify_nonce( $_POST['rgmk_nonce'], 'rgmk_save' ) && current_user_can( 'manage_options' ) ) {
108
+ $key = sanitize_text_field( $_POST['rgmk_google_map_api_key'] );
109
  $updated = update_option( 'rgmk_google_map_api_key', $key );
110
  }
111
 
112
  if ( $updated ) {
113
  echo '<div class="updated fade"><p><strong>' . __( 'Key Updated!', 'gmaps-api-key' ) . '</strong></p></div>';
 
114
  }
115
  ?>
116
+ <div class="wrap">
117
 
118
+ <h2><?php _e( 'Retro Add Google Maps API KEY', 'gmaps-api-key' ); ?></h2>
119
+ <p><?php _e( 'This plugin will attempt to add your Google API KEY to any Google Maps JS file that has properly been enqueued.', 'gmaps-api-key' ); ?></p>
120
+ <p>
121
+ <?php $gm_api_url = 'https://console.developers.google.com/henhouse/?pb=["hh-1","maps_backend",null,[],"https://developers.google.com",null,["static_maps_backend","street_view_image_backend","maps_embed_backend","places_backend","geocoding_backend","directions_backend","distance_matrix_backend","geolocation","elevation_backend","timezone_backend","maps_backend"],null]'; ?>
122
+ <a id="gd-api-key"
123
+ onclick='window.open("<?php echo wp_slash( $gm_api_url ); ?>", "newwindow", "width=600, height=400"); return false;'
124
+ href='<?php echo $gm_api_url; ?>' class="button-primary"
125
+ name="<?php _e( 'Generate API Key - ( MUST be logged in to your Google account )', 'gmaps-api-key' ); ?>"><?php _e( 'Generate API Key', 'gmaps-api-key' ); ?></a>
126
 
127
  <?php echo sprintf( __( 'or %sclick here%s to Get a Google Maps API KEY - ( MUST be logged in to your Google account )', 'gmaps-api-key' ), '<a target="_blank" href=\'https://console.developers.google.com/flows/enableapi?apiid=static_maps_backend,street_view_image_backend,maps_embed_backend,places_backend,geocoding_backend,directions_backend,distance_matrix_backend,geolocation,elevation_backend,timezone_backend,maps_backend&keyType=CLIENT_SIDE&reusekey=true\'>', '</a>' ) ?>
128
+ </p>
129
 
130
+ <form method="post" action="options-general.php?page=gmaps-api-key">
131
+ <label for="rgmk_google_map_api_key"><?php _e( 'Enter Google Maps API KEY', 'gmaps-api-key' ); ?></label>
132
+ <input title="<?php _e( 'Add Google Maps API KEY', 'gmaps-api-key' ); ?>" type="text"
133
+ name="rgmk_google_map_api_key" id="rgmk_google_map_api_key"
134
+ placeholder="<?php _e( 'Enter your API KEY here', 'gmaps-api-key' ); ?>"
135
+ style="padding: 6px; width:50%; display: block;"
136
+ value="<?php echo esc_attr( wp_unslash( get_option( 'rgmk_google_map_api_key' ) ) ); ?>"/>
137
 
138
  <?php
139
 
140
+ wp_nonce_field( 'rgmk_save', 'rgmk_nonce' );
141
+
142
  submit_button();
143
 
144
  ?>
145
+ </form>
146
+
147
+ </div><!-- /.wrap -->
148
 
149
+ <div class="">
150
+ <hr/>
151
+ <br>
152
+ <a target="_blank" href="https://mapfix.dev/"
153
+ class="button button-primary button-hero"><?php _e( 'Check for API key errors', 'gmaps-api-key' ); ?> <span
154
+ class="dashicons dashicons-external" style="line-height: 2;"></span></a>
155
+ </div>
156
  <?php
157
  }
158
 
165
  function rgmk_show_geodirectory_offer() {
166
  if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'gmaps-api-key' ) {
167
 
168
+ if ( defined( 'GEODIRECTORY_VERSION' ) ) {
169
+ // do nothing
170
+ } else {
171
+ ?>
172
+ <div class="notice notice-info is-dismissible rgmk-offer-notice">
173
+ <img src="<?php echo plugin_dir_url( __FILE__ ) . '/gd_banner.jpg'; ?>"/>
174
+ <p><?php echo sprintf( __( 'API KEY for Google Maps was created for free by %sGeoDirectory%s - The WordPress directory pluign. Discount Code: APIKEY25OFF', 'gmaps-api-key' ), '<a target="_blank" href="https://wpgeodirectory.com/" >', '</a>' ); ?></p>
175
+ </div>
176
+ <?php
177
  }
 
 
 
 
 
 
178
  }
179
  }
180
 
languages/gmaps-api-key.mo CHANGED
Binary file
languages/gmaps-api-key.po CHANGED
@@ -1,9 +1,9 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Google Maps API KEY 1.2.0\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2018-06-25 11:10+0100\n"
6
- "PO-Revision-Date: 2018-06-25 11:10+0100\n"
7
  "Last-Translator: \n"
8
  "Language-Team: GeoDirectory <info@ayecode.io>\n"
9
  "Language: en_US\n"
@@ -15,53 +15,57 @@ msgstr ""
15
  "X-Poedit-Basepath: ..\n"
16
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
18
- "X-Generator: Poedit 1.8.7.1\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
 
21
- #: api-key-for-google-maps.php:108
22
  msgid "Key Updated!"
23
  msgstr ""
24
 
25
- #: api-key-for-google-maps.php:114
26
  msgid "Retro Add Google Maps API KEY"
27
  msgstr ""
28
 
29
- #: api-key-for-google-maps.php:115
30
  msgid ""
31
  "This plugin will attempt to add your Google API KEY to any Google Maps JS "
32
  "file that has properly been enqueued."
33
  msgstr ""
34
 
35
- #: api-key-for-google-maps.php:118
36
  msgid "Generate API Key - ( MUST be logged in to your Google account )"
37
  msgstr ""
38
 
39
- #: api-key-for-google-maps.php:118
40
  msgid "Generate API Key"
41
  msgstr ""
42
 
43
- #: api-key-for-google-maps.php:120
44
  #, php-format
45
  msgid ""
46
  "or %sclick here%s to Get a Google Maps API KEY - ( MUST be logged in to your "
47
  "Google account )"
48
  msgstr ""
49
 
50
- #: api-key-for-google-maps.php:124
51
  msgid "Enter Google Maps API KEY"
52
  msgstr ""
53
 
54
- #: api-key-for-google-maps.php:125
55
  msgid "Add Google Maps API KEY"
56
  msgstr ""
57
 
58
- #: api-key-for-google-maps.php:127
59
  msgid "Enter your API KEY here"
60
  msgstr ""
61
 
62
- #: api-key-for-google-maps.php:157
 
 
 
 
63
  #, php-format
64
  msgid ""
65
- "API KEY for Google Maps was created for free by %sGeoDirecotry%s - The "
66
  "WordPress directory pluign. Discount Code: APIKEY25OFF"
67
  msgstr ""
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: Google Maps API KEY 1.2.2\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2022-05-27 09:48+0100\n"
6
+ "PO-Revision-Date: 2022-05-27 09:48+0100\n"
7
  "Last-Translator: \n"
8
  "Language-Team: GeoDirectory <info@ayecode.io>\n"
9
  "Language: en_US\n"
15
  "X-Poedit-Basepath: ..\n"
16
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Generator: Poedit 2.3\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
 
21
+ #: api-key-for-google-maps.php:113
22
  msgid "Key Updated!"
23
  msgstr ""
24
 
25
+ #: api-key-for-google-maps.php:118
26
  msgid "Retro Add Google Maps API KEY"
27
  msgstr ""
28
 
29
+ #: api-key-for-google-maps.php:119
30
  msgid ""
31
  "This plugin will attempt to add your Google API KEY to any Google Maps JS "
32
  "file that has properly been enqueued."
33
  msgstr ""
34
 
35
+ #: api-key-for-google-maps.php:125
36
  msgid "Generate API Key - ( MUST be logged in to your Google account )"
37
  msgstr ""
38
 
39
+ #: api-key-for-google-maps.php:125
40
  msgid "Generate API Key"
41
  msgstr ""
42
 
43
+ #: api-key-for-google-maps.php:127
44
  #, php-format
45
  msgid ""
46
  "or %sclick here%s to Get a Google Maps API KEY - ( MUST be logged in to your "
47
  "Google account )"
48
  msgstr ""
49
 
50
+ #: api-key-for-google-maps.php:131
51
  msgid "Enter Google Maps API KEY"
52
  msgstr ""
53
 
54
+ #: api-key-for-google-maps.php:132
55
  msgid "Add Google Maps API KEY"
56
  msgstr ""
57
 
58
+ #: api-key-for-google-maps.php:134
59
  msgid "Enter your API KEY here"
60
  msgstr ""
61
 
62
+ #: api-key-for-google-maps.php:153
63
+ msgid "Check for API key errors"
64
+ msgstr ""
65
+
66
+ #: api-key-for-google-maps.php:174
67
  #, php-format
68
  msgid ""
69
+ "API KEY for Google Maps was created for free by %sGeoDirectory%s - The "
70
  "WordPress directory pluign. Discount Code: APIKEY25OFF"
71
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: stiofansisland, paoltaia
3
  Tags: Google Maps, Google Maps KEY, Google Maps API KEY
4
  Donate link: https://wpgeodirectory.com
5
  Requires at least: 3.1
6
- Tested up to: 5.9
7
- Stable tag: 1.2.1
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -54,6 +54,11 @@ Ask and they shall be answered
54
 
55
  == Changelog ==
56
 
 
 
 
 
 
57
  = 1.2.1 =
58
  * Compatibility checked with WordPress 5.9
59
 
3
  Tags: Google Maps, Google Maps KEY, Google Maps API KEY
4
  Donate link: https://wpgeodirectory.com
5
  Requires at least: 3.1
6
+ Tested up to: 6.0
7
+ Stable tag: 1.2.2
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
54
 
55
  == Changelog ==
56
 
57
+ = 1.2.2 =
58
+ * Compatibility checked with WordPress 6.0 - CHECKED
59
+ * Now tries to add api key even if no key param is found - CHANGED
60
+ * Now only users with "manage_options" ability can update the API key - SECURITY
61
+
62
  = 1.2.1 =
63
  * Compatibility checked with WordPress 5.9
64