Google Reviews Widget - Version 1.6.4

Version Description

  • Important note: Google Places API now returns reviews with anonymous authors, we added support of this
  • Improve: widget works in any page builders (SiteOrigin, Elementor, Beaver Builder and etc.)
Download this release

Release Info

Developer widgetpack
Plugin Icon 128x128 Google Reviews Widget
Version 1.6.4
Comparing to
See all releases

Code changes from version 1.6.3 to 1.6.4

Files changed (5) hide show
  1. grw-setting.php +1 -1
  2. grw-widget.php +35 -0
  3. grw.php +32 -27
  4. readme.txt +5 -1
  5. static/js/grw-finder.js +1 -0
grw-setting.php CHANGED
@@ -339,7 +339,7 @@ $grw_language = get_option('grw_language');
339
  <form method="POST" action="?page=grw&amp;grw_active=<?php echo (string)((int)($grw_enabled != true)); ?>">
340
  <?php wp_nonce_field('grw-wpnonce_grw_active', 'grw-form_nonce_grw_active'); ?>
341
  <span class="status">
342
- <?php echo grw_i('Google Reviews Widget are currently '). '<b>' .($grw_enabled ? grw_i('enable') : grw_i('disable')). '</b>'; ?>
343
  </span>
344
  <input type="submit" name="grw_active" class="button" value="<?php echo $grw_enabled ? grw_i('Disable') : grw_i('Enable'); ?>" />
345
  </form>
339
  <form method="POST" action="?page=grw&amp;grw_active=<?php echo (string)((int)($grw_enabled != true)); ?>">
340
  <?php wp_nonce_field('grw-wpnonce_grw_active', 'grw-form_nonce_grw_active'); ?>
341
  <span class="status">
342
+ <?php echo grw_i('Google Reviews Widget is currently '). '<b>' .($grw_enabled ? grw_i('enabled') : grw_i('disabled')). '</b>'; ?>
343
  </span>
344
  <input type="submit" name="grw_active" class="button" value="<?php echo $grw_enabled ? grw_i('Disable') : grw_i('Enable'); ?>" />
345
  </form>
grw-widget.php CHANGED
@@ -182,6 +182,41 @@ class Goog_Reviews_Widget extends WP_Widget {
182
  </script>
183
  <?php
184
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
  }
187
  ?>
182
  </script>
183
  <?php
184
  }
185
+ ?>
186
+ <script type="text/javascript">
187
+ function grw_load_js(src, cb) {
188
+ var script = document.createElement('script');
189
+ script.type = 'text/javascript';
190
+ script.src = src;
191
+ script.async = 'true';
192
+ if (cb) {
193
+ script.addEventListener('load', function (e) { cb(null, e); }, false);
194
+ }
195
+ document.getElementsByTagName('head')[0].appendChild(script);
196
+ }
197
+
198
+ function grw_load_css(href) {
199
+ var link = document.createElement('link');
200
+ link.rel = 'stylesheet';
201
+ link.href = href;
202
+ document.getElementsByTagName('head')[0].appendChild(link);
203
+ }
204
+
205
+ if (!window.grw_init) {
206
+ grw_load_css('<?php echo plugins_url('/static/css/rplg-wp.css', __FILE__); ?>');
207
+ grw_load_js('<?php echo plugins_url('/static/js/wpac.js', __FILE__); ?>', function() {
208
+ window.grwVars = {
209
+ GOOGLE_AVATAR : '<?php echo GRW_GOOGLE_AVATAR; ?>',
210
+ handlerUrl : '<?php echo admin_url('options-general.php?page=grw'); ?>',
211
+ actionPrefix : 'grw'
212
+ };
213
+ grw_load_js('<?php echo plugins_url('/static/js/grw-finder.js', __FILE__); ?>', function() {
214
+ grw_init({widgetId: '<?php echo $this->id; ?>'});
215
+ });
216
+ });
217
+ }
218
+ </script>
219
+ <?php
220
  }
221
  }
222
  ?>
grw.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google Reviews Widget
4
  Plugin URI: https://richplugins.com/google-reviews-pro-wordpress-plugin
5
  Description: Instantly Google Places Reviews on your website to increase user confidence and SEO.
6
  Author: RichPlugins <support@richplugins.com>
7
- Version: 1.6.3
8
  Author URI: https://richplugins.com
9
  */
10
 
@@ -13,7 +13,7 @@ require(ABSPATH . 'wp-includes/version.php');
13
  include_once(dirname(__FILE__) . '/api/urlopen.php');
14
  include_once(dirname(__FILE__) . '/helper/debug.php');
15
 
16
- define('GRW_VERSION', '1.6.3');
17
  define('GRW_GOOGLE_PLACE_API', 'https://maps.googleapis.com/maps/api/place/');
18
  define('GRW_GOOGLE_AVATAR', 'https://lh3.googleusercontent.com/-8hepWJzFXpE/AAAAAAAAAAI/AAAAAAAAAAA/I80WzYfIxCQ/s64-c/114307615494839964028.jpg');
19
  define('GRW_PLUGIN_URL', plugins_url(basename(plugin_dir_path(__FILE__ )), basename(__FILE__)));
@@ -316,20 +316,20 @@ function grw_save_reviews($place, $min_filter = 0) {
316
  $google_place_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $wpdb->prefix . "grp_google_place WHERE place_id = %s", $place->place_id));
317
  if ($google_place_id) {
318
  $wpdb->update($wpdb->prefix . 'grp_google_place', array(
319
- 'name' => $place->name,
320
- 'photo' => $place->business_photo,
321
- 'rating' => $place->rating
322
- ), array('ID' => $google_place_id));
323
  } else {
324
  $wpdb->insert($wpdb->prefix . 'grp_google_place', array(
325
  'place_id' => $place->place_id,
326
- 'name' => $place->name,
327
- 'photo' => $place->business_photo,
328
- 'icon' => $place->icon,
329
- 'address' => $place->formatted_address,
330
- 'rating' => isset($place->rating) ? $place->rating : null,
331
- 'url' => isset($place->url) ? $place->url : null,
332
- 'website' => isset($place->website) ? $place->website : null
333
  ));
334
  $google_place_id = $wpdb->insert_id;
335
  }
@@ -340,21 +340,26 @@ function grw_save_reviews($place, $min_filter = 0) {
340
  if ($min_filter > 0 && $min_filter > $review->rating) {
341
  continue;
342
  }
343
- if (!isset($review->author_url) || strlen($review->author_url) < 1) {
344
- continue;
345
- }
346
- $hash = sha1($place->place_id . $review->author_url);
347
- $google_review_hash = $wpdb->get_var($wpdb->prepare("SELECT hash FROM " . $wpdb->prefix . "grp_google_review WHERE hash = %s", $hash));
348
- if (!$google_review_hash) {
349
- $wpdb->insert($wpdb->prefix . 'grp_google_review', array(
350
- 'google_place_id' => $google_place_id,
351
- 'hash' => $hash,
352
  'rating' => $review->rating,
353
- 'text' => $review->text,
354
- 'time' => $review->time,
355
- 'language' => $review->language,
356
- 'author_name' => $review->author_name,
357
- 'author_url' => $review->author_url,
 
 
 
 
 
 
 
 
 
 
358
  'profile_photo_url' => isset($review->profile_photo_url) ? $review->profile_photo_url : null
359
  ));
360
  }
4
  Plugin URI: https://richplugins.com/google-reviews-pro-wordpress-plugin
5
  Description: Instantly Google Places Reviews on your website to increase user confidence and SEO.
6
  Author: RichPlugins <support@richplugins.com>
7
+ Version: 1.6.4
8
  Author URI: https://richplugins.com
9
  */
10
 
13
  include_once(dirname(__FILE__) . '/api/urlopen.php');
14
  include_once(dirname(__FILE__) . '/helper/debug.php');
15
 
16
+ define('GRW_VERSION', '1.6.4');
17
  define('GRW_GOOGLE_PLACE_API', 'https://maps.googleapis.com/maps/api/place/');
18
  define('GRW_GOOGLE_AVATAR', 'https://lh3.googleusercontent.com/-8hepWJzFXpE/AAAAAAAAAAI/AAAAAAAAAAA/I80WzYfIxCQ/s64-c/114307615494839964028.jpg');
19
  define('GRW_PLUGIN_URL', plugins_url(basename(plugin_dir_path(__FILE__ )), basename(__FILE__)));
316
  $google_place_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $wpdb->prefix . "grp_google_place WHERE place_id = %s", $place->place_id));
317
  if ($google_place_id) {
318
  $wpdb->update($wpdb->prefix . 'grp_google_place', array(
319
+ 'name' => $place->name,
320
+ 'photo' => $place->business_photo,
321
+ 'rating' => $place->rating
322
+ ), array('ID' => $google_place_id));
323
  } else {
324
  $wpdb->insert($wpdb->prefix . 'grp_google_place', array(
325
  'place_id' => $place->place_id,
326
+ 'name' => $place->name,
327
+ 'photo' => $place->business_photo,
328
+ 'icon' => $place->icon,
329
+ 'address' => $place->formatted_address,
330
+ 'rating' => isset($place->rating) ? $place->rating : null,
331
+ 'url' => isset($place->url) ? $place->url : null,
332
+ 'website' => isset($place->website) ? $place->website : null
333
  ));
334
  $google_place_id = $wpdb->insert_id;
335
  }
340
  if ($min_filter > 0 && $min_filter > $review->rating) {
341
  continue;
342
  }
343
+
344
+ $google_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $wpdb->prefix . "grp_google_review WHERE time = %s", $review->time));
345
+ if ($google_review_id) {
346
+ $update_params = array(
 
 
 
 
 
347
  'rating' => $review->rating,
348
+ 'text' => $review->text
349
+ );
350
+ if (isset($review->profile_photo_url)) {
351
+ $update_params['profile_photo_url'] = $review->profile_photo_url;
352
+ }
353
+ $wpdb->update($wpdb->prefix . 'grp_google_review', $update_params, array('id' => $google_review_id));
354
+ } else {
355
+ $wpdb->insert($wpdb->prefix . 'grp_google_review', array(
356
+ 'google_place_id' => $google_place_id,
357
+ 'rating' => $review->rating,
358
+ 'text' => $review->text,
359
+ 'time' => $review->time,
360
+ 'language' => $review->language,
361
+ 'author_name' => $review->author_name,
362
+ 'author_url' => isset($review->author_url) ? $review->author_url : null,
363
  'profile_photo_url' => isset($review->profile_photo_url) ? $review->profile_photo_url : null
364
  ));
365
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://richplugins.com/google-reviews-pro-wordpress-plugin
4
  Tags: google, reviews, google reviews, google places, google places reviews, testimonials, google review widget, google business reviews, slider, google review, review, google place review, google map reviews, google reviews pro, facebook reviews, facebook page reviews, yelp reviews, yelp business reviews
5
  Requires at least: 2.8
6
  Tested up to: 4.9
7
- Stable tag: 1.6.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -74,6 +74,10 @@ Why limit your reviews to just Google Reviews? Check out our other free business
74
 
75
  == Changelog ==
76
 
 
 
 
 
77
  = 1.6.3 =
78
  * Important note: Google has changed the Places API and now this is limited to 1 request per day for new accounts, we have changed the plugin according to this limitation
79
  * Improve: added feature to upload custom place photo
4
  Tags: google, reviews, google reviews, google places, google places reviews, testimonials, google review widget, google business reviews, slider, google review, review, google place review, google map reviews, google reviews pro, facebook reviews, facebook page reviews, yelp reviews, yelp business reviews
5
  Requires at least: 2.8
6
  Tested up to: 4.9
7
+ Stable tag: 1.6.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
74
 
75
  == Changelog ==
76
 
77
+ = 1.6.4 =
78
+ * Important note: Google Places API now returns reviews with anonymous authors, we added support of this
79
+ * Improve: widget works in any page builders (SiteOrigin, Elementor, Beaver Builder and etc.)
80
+
81
  = 1.6.3 =
82
  * Important note: Google has changed the Places API and now this is limited to 1 request per day for new accounts, we have changed the plugin according to this limitation
83
  * Improve: added feature to upload custom place photo
static/js/grw-finder.js CHANGED
@@ -52,6 +52,7 @@ function grw_init(data) {
52
  errorEl.innerHTML = '';
53
  } else {
54
  errorEl.innerHTML = 'Place ID is incorrect, it should like ChIJ...';
 
55
  }
56
 
57
  connectBtn.innerHTML = 'Please wait...';
52
  errorEl.innerHTML = '';
53
  } else {
54
  errorEl.innerHTML = 'Place ID is incorrect, it should like ChIJ...';
55
+ return false;
56
  }
57
 
58
  connectBtn.innerHTML = 'Please wait...';