Google Reviews Widget - Version 2.0.4

Version Description

  • Bugfix: duplicate reviews for empty language
  • Style fixes
Download this release

Release Info

Developer richplugins
Plugin Icon 128x128 Google Reviews Widget
Version 2.0.4
Comparing to
See all releases

Code changes from version 2.0.3 to 2.0.4

assets/js/admin-main.js CHANGED
@@ -1,6 +1,6 @@
1
  jQuery(document).ready(function(a){a(".grw-admin-page a.nav-tab").on("click",function(c){var b=a(this),d=b.attr("href");a(d).show().siblings(".tab-content").hide();b.addClass("nav-tab-active").siblings().removeClass("nav-tab-active");c.preventDefault()})});
2
  var HTML_CONTENT='<div class="grw-builder-platforms grw-builder-inside"><div class="grw-toggle grw-builder-connect grw-connect-google">Connect Google</div><div class="grw-connect-google-inside" style="display:none"><div class="grw-builder-option"><input type="text" class="grw-connect-id" value="" placeholder="Place ID" /><span class="grw-quest grw-toggle" title="Click to help">?</span><div class="grw-quest-help">The standard way to find your Google Place ID is to go to <a href="https://developers.google.com/places/place-id" target="_blank">https://developers.google.com/places/place-id</a> and search for your company name.<br><br>But sometimes it may not work, in this case please see <a href="'+GRW_VARS.supportUrl+
3
- '&grw_tab=fig#place_id" target="_blank">how to find any Google Place ID</a>.</div></div><div class="grw-builder-option"><select class="grw-connect-lang"><option value="ar">Arabic</option><option value="bg">Bulgarian</option><option value="bn">Bengali</option><option value="ca">Catalan</option><option value="cs">Czech</option><option value="da">Danish</option><option value="de">German</option><option value="el">Greek</option><option value="en" selected="selected">English</option><option value="es">Spanish</option><option value="eu">Basque</option><option value="eu">Basque</option><option value="fa">Farsi</option><option value="fi">Finnish</option><option value="fil">Filipino</option><option value="fr">French</option><option value="gl">Galician</option><option value="gu">Gujarati</option><option value="hi">Hindi</option><option value="hr">Croatian</option><option value="hu">Hungarian</option><option value="id">Indonesian</option><option value="it">Italian</option><option value="iw">Hebrew</option><option value="ja">Japanese</option><option value="kn">Kannada</option><option value="ko">Korean</option><option value="lt">Lithuanian</option><option value="lv">Latvian</option><option value="ml">Malayalam</option><option value="mr">Marathi</option><option value="nl">Dutch</option><option value="no">Norwegian</option><option value="pl">Polish</option><option value="pt">Portuguese</option><option value="pt-BR">Portuguese (Brazil)</option><option value="pt-PT">Portuguese (Portugal)</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="sk">Slovak</option><option value="sl">Slovenian</option><option value="sr">Serbian</option><option value="sv">Swedish</option><option value="ta">Tamil</option><option value="te">Telugu</option><option value="th">Thai</option><option value="tl">Tagalog</option><option value="tr">Turkish</option><option value="uk">Ukrainian</option><option value="vi">Vietnamese</option><option value="zh-CN">Chinese (Simplified)</option><option value="zh-TW">Chinese (Traditional)</option></select></div><div class="grw-builder-option"><button class="grw-connect-btn">Connect Google</button><small class="grw-connect-error"></small></div></div><div class="grw-connections"></div></div><div class="grw-connect-options"><div class="grw-builder-inside"><div class="grw-builder-option">Pagination<input type="text" name="pagination" value=""></div><div class="grw-builder-option">Maximum characters before \'read more\' link<input type="text" name="text_size" value=""></div><div class="grw-builder-option">Maximum width<input type="text" name="max_width" value="" placeholder="for instance: 300px"></div><div class="grw-builder-option">Maximum height<input type="text" name="max_height" value="" placeholder="for instance: 500px"></div><div class="grw-builder-option"><label><input type="checkbox" name="hide_based_on" value="">Hide \'Based on ... reviews\'</label></div><div class="grw-builder-option"><label><input type="checkbox" name="hide_reviews" value="">Hide reviews, leave only rating header</label></div><div class="grw-builder-option"><label><input type="checkbox" name="centered" value="">Place by center (only if Width is set)</label></div><div class="grw-builder-option"><label><input type="checkbox" name="dark_theme">Dark background</label></div></div><div class="grw-builder-top grw-toggle">Advance Options</div><div class="grw-builder-inside" style="display:none"><div class="grw-builder-option"><label><input type="checkbox" name="lazy_load_img" checked>Lazy load images</label></div><div class="grw-builder-option"><label><input type="checkbox" name="google_def_rev_link">Use default Google reviews link</label><span class="grw-quest grw-quest-top grw-toggle" title="Click to help">?</span><div class="grw-quest-help" style="display:none;">If the direct link to all reviews <b>https://search.google.com/local/reviews?placeid=&lt;PLACE_ID&gt;</b> does not work with your Google place (leads to 404), please use this option to use the default reviews link to Google map.</div></div><div class="grw-builder-option"><label><input type="checkbox" name="open_link" checked>Open links in new Window</label></div><div class="grw-builder-option"><label><input type="checkbox" name="nofollow_link" checked>Use no follow links</label></div><div class="grw-builder-option">Reviewer avatar size<select name="reviewer_avatar_size"><option value="56" selected="selected">Small: 56px</option><option value="128">Medium: 128px</option><option value="256">Large: 256px</option></select></div><div class="grw-builder-option">Cache data<select name="cache"><option value="1">1 Hour</option><option value="3">3 Hours</option><option value="6">6 Hours</option><option value="12" selected="selected">12 Hours</option><option value="24">1 Day</option><option value="48">2 Days</option><option value="168">1 Week</option><option value="">Disable (NOT recommended)</option></select></div><div class="grw-builder-option">Reviews limit<input type="text" name="reviews_limit" value=""></div></div></div>';
4
  function grw_builder_init(a,c){var b=document.querySelector(c.el);if(b){b.innerHTML=HTML_CONTENT;c.conns&&grw_deserialize_connections(a,b,c.conns,c.opts);var d=b.querySelector(".grw-connect-google-inside");grw_connection(a,d,"google",c.authcode);a('.grw-connect-options input[type="text"],.grw-connect-options textarea').keyup(function(){grw_serialize_connections()});a('.grw-connect-options input[type="checkbox"],.grw-connect-options select').change(function(){grw_serialize_connections()});a(".grw-toggle",
5
  b).unbind("click").click(function(){a(this).toggleClass("toggled");a(this).next().slideToggle()});a(".grw-connections").sortable&&(a(".grw-connections").sortable({stop:function(a,b){grw_serialize_connections()}}),a(".grw-connections").disableSelection());a(".wp-review-hide").click(function(){grw_review_hide(a(this));return!1});a("#grw_save").click(function(){grw_feed_save_ajax();return!1})}}
6
  function grw_feed_save_ajax(a){if(!window.grw_title.value)return window.grw_title.focus(),!1;window.grw_save.innerText="Auto save, wait";window.grw_save.disabled=!0;jQuery.post(ajaxurl,{post_id:window.grw_post_id.value,title:window.grw_title.value,content:document.getElementById("grw-builder-connection").value,action:"grw_feed_save_ajax"},function(a){for(var b=document.querySelectorAll(".wp-gr"),c=0;c<b.length;c++)b[c].parentNode.removeChild(b[c]);window.grw_collection_preview.innerHTML=a;jQuery(".wp-review-hide").unbind("click").click(function(){grw_review_hide(jQuery(this));
1
  jQuery(document).ready(function(a){a(".grw-admin-page a.nav-tab").on("click",function(c){var b=a(this),d=b.attr("href");a(d).show().siblings(".tab-content").hide();b.addClass("nav-tab-active").siblings().removeClass("nav-tab-active");c.preventDefault()})});
2
  var HTML_CONTENT='<div class="grw-builder-platforms grw-builder-inside"><div class="grw-toggle grw-builder-connect grw-connect-google">Connect Google</div><div class="grw-connect-google-inside" style="display:none"><div class="grw-builder-option"><input type="text" class="grw-connect-id" value="" placeholder="Place ID" /><span class="grw-quest grw-toggle" title="Click to help">?</span><div class="grw-quest-help">The standard way to find your Google Place ID is to go to <a href="https://developers.google.com/places/place-id" target="_blank">https://developers.google.com/places/place-id</a> and search for your company name.<br><br>But sometimes it may not work, in this case please see <a href="'+GRW_VARS.supportUrl+
3
+ '&grw_tab=fig#place_id" target="_blank">how to find any Google Place ID</a>.</div></div><div class="grw-builder-option"><select class="grw-connect-lang"><option value="" selected="selected">Choose language or use default</option><option value="ar">Arabic</option><option value="bg">Bulgarian</option><option value="bn">Bengali</option><option value="ca">Catalan</option><option value="cs">Czech</option><option value="da">Danish</option><option value="de">German</option><option value="el">Greek</option><option value="en">English</option><option value="es">Spanish</option><option value="eu">Basque</option><option value="eu">Basque</option><option value="fa">Farsi</option><option value="fi">Finnish</option><option value="fil">Filipino</option><option value="fr">French</option><option value="gl">Galician</option><option value="gu">Gujarati</option><option value="hi">Hindi</option><option value="hr">Croatian</option><option value="hu">Hungarian</option><option value="id">Indonesian</option><option value="it">Italian</option><option value="iw">Hebrew</option><option value="ja">Japanese</option><option value="kn">Kannada</option><option value="ko">Korean</option><option value="lt">Lithuanian</option><option value="lv">Latvian</option><option value="ml">Malayalam</option><option value="mr">Marathi</option><option value="nl">Dutch</option><option value="no">Norwegian</option><option value="pl">Polish</option><option value="pt">Portuguese</option><option value="pt-BR">Portuguese (Brazil)</option><option value="pt-PT">Portuguese (Portugal)</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="sk">Slovak</option><option value="sl">Slovenian</option><option value="sr">Serbian</option><option value="sv">Swedish</option><option value="ta">Tamil</option><option value="te">Telugu</option><option value="th">Thai</option><option value="tl">Tagalog</option><option value="tr">Turkish</option><option value="uk">Ukrainian</option><option value="vi">Vietnamese</option><option value="zh-CN">Chinese (Simplified)</option><option value="zh-TW">Chinese (Traditional)</option></select></div><div class="grw-builder-option"><button class="grw-connect-btn">Connect Google</button><small class="grw-connect-error"></small></div></div><div class="grw-connections"></div></div><div class="grw-connect-options"><div class="grw-builder-inside"><div class="grw-builder-option">Pagination<input type="text" name="pagination" value=""></div><div class="grw-builder-option">Maximum characters before \'read more\' link<input type="text" name="text_size" value=""></div><div class="grw-builder-option">Maximum width<input type="text" name="max_width" value="" placeholder="for instance: 300px"></div><div class="grw-builder-option">Maximum height<input type="text" name="max_height" value="" placeholder="for instance: 500px"></div><div class="grw-builder-option"><label><input type="checkbox" name="hide_based_on" value="">Hide \'Based on ... reviews\'</label></div><div class="grw-builder-option"><label><input type="checkbox" name="hide_reviews" value="">Hide reviews, leave only rating header</label></div><div class="grw-builder-option"><label><input type="checkbox" name="centered" value="">Place by center (only if Width is set)</label></div><div class="grw-builder-option"><label><input type="checkbox" name="dark_theme">Dark background</label></div></div><div class="grw-builder-top grw-toggle">Advance Options</div><div class="grw-builder-inside" style="display:none"><div class="grw-builder-option"><label><input type="checkbox" name="lazy_load_img" checked>Lazy load images</label></div><div class="grw-builder-option"><label><input type="checkbox" name="google_def_rev_link">Use default Google reviews link</label><span class="grw-quest grw-quest-top grw-toggle" title="Click to help">?</span><div class="grw-quest-help" style="display:none;">If the direct link to all reviews <b>https://search.google.com/local/reviews?placeid=&lt;PLACE_ID&gt;</b> does not work with your Google place (leads to 404), please use this option to use the default reviews link to Google map.</div></div><div class="grw-builder-option"><label><input type="checkbox" name="open_link" checked>Open links in new Window</label></div><div class="grw-builder-option"><label><input type="checkbox" name="nofollow_link" checked>Use no follow links</label></div><div class="grw-builder-option">Reviewer avatar size<select name="reviewer_avatar_size"><option value="56" selected="selected">Small: 56px</option><option value="128">Medium: 128px</option><option value="256">Large: 256px</option></select></div><div class="grw-builder-option">Cache data<select name="cache"><option value="1">1 Hour</option><option value="3">3 Hours</option><option value="6">6 Hours</option><option value="12" selected="selected">12 Hours</option><option value="24">1 Day</option><option value="48">2 Days</option><option value="168">1 Week</option><option value="">Disable (NOT recommended)</option></select></div><div class="grw-builder-option">Reviews limit<input type="text" name="reviews_limit" value=""></div></div></div>';
4
  function grw_builder_init(a,c){var b=document.querySelector(c.el);if(b){b.innerHTML=HTML_CONTENT;c.conns&&grw_deserialize_connections(a,b,c.conns,c.opts);var d=b.querySelector(".grw-connect-google-inside");grw_connection(a,d,"google",c.authcode);a('.grw-connect-options input[type="text"],.grw-connect-options textarea').keyup(function(){grw_serialize_connections()});a('.grw-connect-options input[type="checkbox"],.grw-connect-options select').change(function(){grw_serialize_connections()});a(".grw-toggle",
5
  b).unbind("click").click(function(){a(this).toggleClass("toggled");a(this).next().slideToggle()});a(".grw-connections").sortable&&(a(".grw-connections").sortable({stop:function(a,b){grw_serialize_connections()}}),a(".grw-connections").disableSelection());a(".wp-review-hide").click(function(){grw_review_hide(a(this));return!1});a("#grw_save").click(function(){grw_feed_save_ajax();return!1})}}
6
  function grw_feed_save_ajax(a){if(!window.grw_title.value)return window.grw_title.focus(),!1;window.grw_save.innerText="Auto save, wait";window.grw_save.disabled=!0;jQuery.post(ajaxurl,{post_id:window.grw_post_id.value,title:window.grw_title.value,content:document.getElementById("grw-builder-connection").value,action:"grw_feed_save_ajax"},function(a){for(var b=document.querySelectorAll(".wp-gr"),c=0;c<b.length;c++)b[c].parentNode.removeChild(b[c]);window.grw_collection_preview.innerHTML=a;jQuery(".wp-review-hide").unbind("click").click(function(){grw_review_hide(jQuery(this));
assets/src/js/admin-builder.js CHANGED
@@ -16,6 +16,7 @@ var HTML_CONTENT = '' +
16
  '</div>' +
17
  '<div class="grw-builder-option">' +
18
  '<select class="grw-connect-lang">' +
 
19
  '<option value="ar">Arabic</option>' +
20
  '<option value="bg">Bulgarian</option>' +
21
  '<option value="bn">Bengali</option>' +
@@ -24,7 +25,7 @@ var HTML_CONTENT = '' +
24
  '<option value="da">Danish</option>' +
25
  '<option value="de">German</option>' +
26
  '<option value="el">Greek</option>' +
27
- '<option value="en" selected="selected">English</option>' +
28
  '<option value="es">Spanish</option>' +
29
  '<option value="eu">Basque</option>' +
30
  '<option value="eu">Basque</option>' +
@@ -406,11 +407,16 @@ function grw_connect_ajax($, el, params, platform, authcode, attempt) {
406
  break;
407
 
408
  default:
409
- error_el.innerHTML = '<b>Error</b>: ' + res.result.error_message;
410
- if (res.result.status == 'OVER_QUERY_LIMIT') {
411
- error_el.innerHTML += '<br><br>More recently, Google has limited the API to 1 request per day for new users, try to create new <a href="https://developers.google.com/places/web-service/get-api-key#get_an_api_key" target="_blank">Google API key</a>, save in the setting and Connect Google again.';
 
 
 
 
 
 
412
  }
413
-
414
  }
415
  }
416
 
16
  '</div>' +
17
  '<div class="grw-builder-option">' +
18
  '<select class="grw-connect-lang">' +
19
+ '<option value="" selected="selected">Choose language if required</option>' +
20
  '<option value="ar">Arabic</option>' +
21
  '<option value="bg">Bulgarian</option>' +
22
  '<option value="bn">Bengali</option>' +
25
  '<option value="da">Danish</option>' +
26
  '<option value="de">German</option>' +
27
  '<option value="el">Greek</option>' +
28
+ '<option value="en">English</option>' +
29
  '<option value="es">Spanish</option>' +
30
  '<option value="eu">Basque</option>' +
31
  '<option value="eu">Basque</option>' +
407
  break;
408
 
409
  default:
410
+ if (res.result.error_message.indexOf('The provided Place ID is no longer valid') >= 0) {
411
+ error_el.innerHTML = 'It seems Google place which you are trying to connect ' +
412
+ 'does not have a physical address (it\'s virtual or service area), ' +
413
+ 'unfortunately, Google Places API does not support such locations, it\'s a limitation of Google, not the plugin.<br><br>' +
414
+ 'However, you can try to connect your Google reviews in our new cloud service ' +
415
+ '<a href="https://trust.reviews" target="_blank">Trust.Reviews</a> ' +
416
+ 'and show it on your WordPress site through universal <b>HTML/JavaScript</b> code.';
417
+ } else {
418
+ error_el.innerHTML = '<b>Error</b>: ' + res.result.error_message;
419
  }
 
420
  }
421
  }
422
 
grw.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Widget for Google Reviews
4
  Plugin URI: https://richplugins.com/business-reviews-bundle-wordpress-plugin
5
  Description: Instantly Google Places Reviews on your website to increase user confidence and SEO.
6
- Version: 2.0.3
7
  Author: RichPlugins <support@richplugins.com>
8
  Author URI: https://richplugins.com
9
  Text Domain: widget-google-reviews
@@ -18,7 +18,7 @@ if (!defined('ABSPATH')) {
18
 
19
  require(ABSPATH . 'wp-includes/version.php');
20
 
21
- define('GRW_VERSION' , '2.0.3');
22
  define('GRW_PLUGIN_FILE' , __FILE__);
23
  define('GRW_PLUGIN_URL' , plugins_url(basename(plugin_dir_path(__FILE__ )), basename(__FILE__)));
24
  define('GRW_ASSETS_URL' , GRW_PLUGIN_URL . '/assets/');
3
  Plugin Name: Widget for Google Reviews
4
  Plugin URI: https://richplugins.com/business-reviews-bundle-wordpress-plugin
5
  Description: Instantly Google Places Reviews on your website to increase user confidence and SEO.
6
+ Version: 2.0.4
7
  Author: RichPlugins <support@richplugins.com>
8
  Author URI: https://richplugins.com
9
  Text Domain: widget-google-reviews
18
 
19
  require(ABSPATH . 'wp-includes/version.php');
20
 
21
+ define('GRW_VERSION' , '2.0.4');
22
  define('GRW_PLUGIN_FILE' , __FILE__);
23
  define('GRW_PLUGIN_URL' , plugins_url(basename(plugin_dir_path(__FILE__ )), basename(__FILE__)));
24
  define('GRW_ASSETS_URL' , GRW_PLUGIN_URL . '/assets/');
includes/core/class-connect-google.php CHANGED
@@ -227,22 +227,28 @@ class Connect_Google {
227
  foreach ($reviews as $review) {
228
  $google_review_id = 0;
229
  if (isset($review->author_url) && strlen($review->author_url) > 0) {
230
- $review_lang = ($review->language == 'en-US' ? 'en' : $review->language);
231
- $google_review_id = $wpdb->get_var(
232
- $wpdb->prepare(
233
- "SELECT id FROM " . $wpdb->prefix . Database::REVIEW_TABLE .
234
- " WHERE author_url = %s AND language = %s", $review->author_url, $review_lang
235
- )
236
- );
237
  } else {
238
- $google_review_id = $wpdb->get_var(
239
- $wpdb->prepare(
240
- "SELECT id FROM " . $wpdb->prefix . Database::REVIEW_TABLE .
241
- " WHERE time = %s", $review->time
242
- )
243
- );
244
  }
245
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  if ($google_review_id) {
247
  $update_params = array(
248
  'rating' => $review->rating,
227
  foreach ($reviews as $review) {
228
  $google_review_id = 0;
229
  if (isset($review->author_url) && strlen($review->author_url) > 0) {
230
+ $where = " WHERE author_url = %s";
231
+ $where_array = array($review->author_url);
232
+ } elseif (isset($review->author_name) && strlen($review->author_name) > 0) {
233
+ $where = " WHERE author_name = %s";
234
+ $where_array = array($review->author_name);
 
 
235
  } else {
236
+ $where = " WHERE time = %s";
237
+ $where_array = array($review->time);
 
 
 
 
238
  }
239
 
240
+ $review_lang = ($review->language == 'en-US' ? 'en' : $review->language);
241
+ if (strlen($review_lang) > 0) {
242
+ $where = $where . " AND language = %s";
243
+ array_push($where_array, $review_lang);
244
+ }
245
+
246
+ $google_review_id = $wpdb->get_var(
247
+ $wpdb->prepare(
248
+ "SELECT id FROM " . $wpdb->prefix . Database::REVIEW_TABLE . $where, $where_array
249
+ )
250
+ );
251
+
252
  if ($google_review_id) {
253
  $update_params = array(
254
  'rating' => $review->rating,
readme.txt CHANGED
@@ -4,11 +4,11 @@ Donate link: https://richplugins.com/business-reviews-bundle-wordpress-plugin
4
  Tags: google, google reviews, reviews, rating, widget, google business, testimonial, testimonials, google places reviews, map reviews, google my business
5
  Requires at least: 2.8
6
  Tested up to: 5.8
7
- Stable tag: 2.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Official way to show Google Reviews on your WordPress website without Google crawling and other unofficial methods. Show Google Rating to increase user trust and sales.
12
 
13
  == Description ==
14
 
@@ -83,6 +83,10 @@ Why limit your reviews to just Google Reviews? Check out our other free reviews
83
 
84
  == Changelog ==
85
 
 
 
 
 
86
  = 2.0.3 =
87
  * Ajax auto-save for widgets
88
  * Small bug fixes
4
  Tags: google, google reviews, reviews, rating, widget, google business, testimonial, testimonials, google places reviews, map reviews, google my business
5
  Requires at least: 2.8
6
  Tested up to: 5.8
7
+ Stable tag: 2.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Official way to show Google Reviews on your WordPress site without Google crawling and other unofficial methods. Show Google Rating to boost user trust and sales.
12
 
13
  == Description ==
14
 
83
 
84
  == Changelog ==
85
 
86
+ = 2.0.4 =
87
+ * Bugfix: duplicate reviews for empty language
88
+ * Style fixes
89
+
90
  = 2.0.3 =
91
  * Ajax auto-save for widgets
92
  * Small bug fixes