Google Reviews Widget - Version 2.0.3

Version Description

  • Ajax auto-save for widgets
  • Small bug fixes
Download this release

Release Info

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

Code changes from version 2.0.2 to 2.0.3

assets/js/admin-main.js CHANGED
@@ -2,9 +2,11 @@ jQuery(document).ready(function(a){a(".grw-admin-page a.nav-tab").on("click",fun
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(){var b=a(this);a.post(GRW_VARS.handlerUrl+"&cf_action=grw_hide_review",{id:b.attr("data-id"),feed_id:a('input[name="grw_feed[post_id]"]').val(),grw_wpnonce:a("#grw_nonce").val()},function(a){var c=b.parent().parent();
6
- a.hide?(b.text("show review"),c.addClass("wp-review-hidden")):(b.text("hide review"),c.removeClass("wp-review-hidden"))},"json");return!1});a("#grw_save").click(function(){return grw_feed_save()})}}
 
7
  function grw_feed_save(){if(!window.grw_title.value)return window.grw_title.focus(),!1;var a=document.getElementById("grw-builder-connection").value;if(a&&(a=JSON.parse(a))&&a.connections&&a.connections.length)return!0;alert("Please click 'CONNECT GOOGLE' and connect your Google reviews then save this widget");return!1}
 
8
  function grw_connection(a,c,b,d){var e=c.querySelector(".grw-connect-btn");a(e).click(function(){var f=c.querySelector(".grw-connect-id");if(!f.value)return f.focus(),!1;f="yelp"==b?/.+\/biz\/(.*?)(\?|\/|$)/.exec(f.value)[1]:f.value;var g=c.querySelector(".grw-connect-lang").value;e.innerHTML="Please wait...";e.disabled=!0;grw_connect_ajax(a,c,{id:f,lang:g},b,d,1);return!1})}
9
  function grw_connect_ajax(a,c,b,d,e,f){var g=c.querySelector(".grw-connect-btn"),k=GRW_VARS.handlerUrl+"&cf_action=grw_connect_"+d+"&v="+(new Date).getTime();a.post(k,{id:decodeURIComponent(b.id),lang:b.lang,grw_wpnonce:a("#grw_nonce").val()},function(h){console.log("grw_connect_debug:",h);g.innerHTML="Connect "+(d.charAt(0).toUpperCase()+d.slice(1));g.disabled=!1;var k=c.querySelector(".grw-connect-error");if("success"==h.status)k.innerHTML="",grw_connection_add(a,c,{id:h.result.id,lang:b.lang,name:h.result.name,
10
  photo:h.result.photo,refresh:!0,platform:d,props:{default_photo:h.result.photo}}),grw_serialize_connections();else switch(h.result.error_message){case "usage_limit":a("#dialog").dialog({width:"50%",maxWidth:"600px"});break;case "bot_check":if(1<f)break;grw_popup("https://gpaw.widgetpack.com/botcheck?authcode="+e,640,480,function(){grw_connect_ajax(a,c,b,d,e,f+1)});break;default:k.innerHTML="<b>Error</b>: "+h.result.error_message,"OVER_QUERY_LIMIT"==h.result.status&&(k.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.')}},
@@ -20,7 +22,7 @@ a.name+'" /></div>'+(void 0!=a.website?'<div class="grw-builder-option"><input t
20
  "")+("yelp"==a.platform?"The plugin uses the Yelp API to get your reviews. <b>The API only returns the 3 most helpful reviews without sorting possibility.</b> When Yelp changes the 3 most helpful the plugin will automatically add the new one to your database. Thus slowly building up a database of reviews.":"")+"</div></div>":"")+'<div class="grw-builder-option"><button class="grw-connect-delete">Delete business</button></div></div>'}
21
  function grw_serialize_connections(){var a=[],c=document.querySelectorAll(".grw-connection");for(h in c)if(Object.prototype.hasOwnProperty.call(c,h)){var b=c[h].querySelector(".grw-connect-select");if(!b||grw_is_hidden(b)||b.checked){var d={};b=c[h].getAttribute("data-lang");var e=c[h].getAttribute("data-platform"),f=c[h].querySelectorAll("input");void 0!=b&&(d.lang=b);for(var g in f)if(Object.prototype.hasOwnProperty.call(f,g)){b=f[g];var k=b.getAttribute("name");k&&("grw-connect-prop"==b.className?
22
  (d.props=d.props||{},d.props[k]=b.value):d[k]="checkbox"==b.type?b.checked:b.value)}d.platform=e;a.push(d)}}c={};var h=document.querySelector(".grw-connect-options").querySelectorAll("input[name],select,textarea");for(var l in h)Object.prototype.hasOwnProperty.call(h,l)&&(b=h[l],k=b.getAttribute("name"),"checkbox"==b.type?c[k]=b.checked:void 0!=b.value&&(c[k]="textarea"==b.type||"word_filter"==k||"word_exclude"==k?encodeURIComponent(b.value):b.value));GRW_VARS.wordpress?document.getElementById("grw-builder-connection").value=
23
- JSON.stringify({connections:a,options:c}):(document.getElementById("grw-builder-connections").value=JSON.stringify(a),document.getElementById("grw-builder-options").value=JSON.stringify(c))}
24
  function grw_deserialize_connections(a,c,b,d){if(GRW_VARS.wordpress)if(d=b.options,Array.isArray(b.connections))b=b.connections;else{var e=[];if(Array.isArray(b.google)){for(var f=0;f<b.google.length;f++)b.google[f].platform="google";e=e.concat(b.google)}if(Array.isArray(b.facebook)){for(f=0;f<b.facebook.length;f++)b.facebook[f].platform="facebook";e=e.concat(b.facebook)}if(Array.isArray(b.yelp)){for(f=0;f<b.yelp.length;f++)b.yelp[f].platform="yelp";e=e.concat(b.yelp)}b=e}else b=JSON.parse(b),d=JSON.parse(d);
25
  for(e=0;e<b.length;e++)grw_connection_add(a,c.querySelector(".grw-builder-platforms"),b[e],!0);for(var g in d)Object.prototype.hasOwnProperty.call(d,g)&&(a=c.querySelector('input[name="'+g+'"],select[name="'+g+'"],textarea[name="'+g+'"]'))&&(b=a.getAttribute("name"),"boolean"===typeof d[g]?a.checked=d[g]:(a.value="textarea"==a.type||"word_filter"==b||"word_exclude"==b?decodeURIComponent(d[g]):d[g],-1<g.indexOf("_photo")&&a.value&&(a.parentNode.querySelector("img").src=a.value)))}
26
  function grw_upload_photo(a,c,b){if(GRW_VARS.wordpress)c||(c=wp.media.frames.file_frame=wp.media({title:jQuery(this).data("uploader_title"),button:{text:jQuery(this).data("uploader_button_text")},multiple:!1}),c.on("select",function(){var d=c.state().get("selection").first().toJSON();grw_change_photo(a,d.url);b&&b(d.url)})),c.open();else return a.querySelector('input[type="file"]').click(),!1}
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));
7
+ return!1});window.grw_post_id.value||(a=document.querySelector(".wp-gr").getAttribute("data-id"),window.grw_post_id.value=a,window.location.href=window.location.href+"&grw_feed_id="+a);window.grw_save.innerText="Save & Refresh";window.grw_save.disabled=!1})}
8
  function grw_feed_save(){if(!window.grw_title.value)return window.grw_title.focus(),!1;var a=document.getElementById("grw-builder-connection").value;if(a&&(a=JSON.parse(a))&&a.connections&&a.connections.length)return!0;alert("Please click 'CONNECT GOOGLE' and connect your Google reviews then save this widget");return!1}
9
+ function grw_review_hide(a){jQuery.post(GRW_VARS.handlerUrl+"&cf_action=grw_hide_review",{id:a.attr("data-id"),feed_id:jQuery('input[name="grw_feed[post_id]"]').val(),grw_wpnonce:jQuery("#grw_nonce").val()},function(c){var b=a.parent().parent();c.hide?(a.text("show review"),b.addClass("wp-review-hidden")):(a.text("hide review"),b.removeClass("wp-review-hidden"))},"json")}
10
  function grw_connection(a,c,b,d){var e=c.querySelector(".grw-connect-btn");a(e).click(function(){var f=c.querySelector(".grw-connect-id");if(!f.value)return f.focus(),!1;f="yelp"==b?/.+\/biz\/(.*?)(\?|\/|$)/.exec(f.value)[1]:f.value;var g=c.querySelector(".grw-connect-lang").value;e.innerHTML="Please wait...";e.disabled=!0;grw_connect_ajax(a,c,{id:f,lang:g},b,d,1);return!1})}
11
  function grw_connect_ajax(a,c,b,d,e,f){var g=c.querySelector(".grw-connect-btn"),k=GRW_VARS.handlerUrl+"&cf_action=grw_connect_"+d+"&v="+(new Date).getTime();a.post(k,{id:decodeURIComponent(b.id),lang:b.lang,grw_wpnonce:a("#grw_nonce").val()},function(h){console.log("grw_connect_debug:",h);g.innerHTML="Connect "+(d.charAt(0).toUpperCase()+d.slice(1));g.disabled=!1;var k=c.querySelector(".grw-connect-error");if("success"==h.status)k.innerHTML="",grw_connection_add(a,c,{id:h.result.id,lang:b.lang,name:h.result.name,
12
  photo:h.result.photo,refresh:!0,platform:d,props:{default_photo:h.result.photo}}),grw_serialize_connections();else switch(h.result.error_message){case "usage_limit":a("#dialog").dialog({width:"50%",maxWidth:"600px"});break;case "bot_check":if(1<f)break;grw_popup("https://gpaw.widgetpack.com/botcheck?authcode="+e,640,480,function(){grw_connect_ajax(a,c,b,d,e,f+1)});break;default:k.innerHTML="<b>Error</b>: "+h.result.error_message,"OVER_QUERY_LIMIT"==h.result.status&&(k.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.')}},
22
  "")+("yelp"==a.platform?"The plugin uses the Yelp API to get your reviews. <b>The API only returns the 3 most helpful reviews without sorting possibility.</b> When Yelp changes the 3 most helpful the plugin will automatically add the new one to your database. Thus slowly building up a database of reviews.":"")+"</div></div>":"")+'<div class="grw-builder-option"><button class="grw-connect-delete">Delete business</button></div></div>'}
23
  function grw_serialize_connections(){var a=[],c=document.querySelectorAll(".grw-connection");for(h in c)if(Object.prototype.hasOwnProperty.call(c,h)){var b=c[h].querySelector(".grw-connect-select");if(!b||grw_is_hidden(b)||b.checked){var d={};b=c[h].getAttribute("data-lang");var e=c[h].getAttribute("data-platform"),f=c[h].querySelectorAll("input");void 0!=b&&(d.lang=b);for(var g in f)if(Object.prototype.hasOwnProperty.call(f,g)){b=f[g];var k=b.getAttribute("name");k&&("grw-connect-prop"==b.className?
24
  (d.props=d.props||{},d.props[k]=b.value):d[k]="checkbox"==b.type?b.checked:b.value)}d.platform=e;a.push(d)}}c={};var h=document.querySelector(".grw-connect-options").querySelectorAll("input[name],select,textarea");for(var l in h)Object.prototype.hasOwnProperty.call(h,l)&&(b=h[l],k=b.getAttribute("name"),"checkbox"==b.type?c[k]=b.checked:void 0!=b.value&&(c[k]="textarea"==b.type||"word_filter"==k||"word_exclude"==k?encodeURIComponent(b.value):b.value));GRW_VARS.wordpress?document.getElementById("grw-builder-connection").value=
25
+ JSON.stringify({connections:a,options:c}):(document.getElementById("grw-builder-connections").value=JSON.stringify(a),document.getElementById("grw-builder-options").value=JSON.stringify(c));a.length&&(a=a[0],window.grw_title.value||(window.grw_title.value=a.name),grw_feed_save_ajax())}
26
  function grw_deserialize_connections(a,c,b,d){if(GRW_VARS.wordpress)if(d=b.options,Array.isArray(b.connections))b=b.connections;else{var e=[];if(Array.isArray(b.google)){for(var f=0;f<b.google.length;f++)b.google[f].platform="google";e=e.concat(b.google)}if(Array.isArray(b.facebook)){for(f=0;f<b.facebook.length;f++)b.facebook[f].platform="facebook";e=e.concat(b.facebook)}if(Array.isArray(b.yelp)){for(f=0;f<b.yelp.length;f++)b.yelp[f].platform="yelp";e=e.concat(b.yelp)}b=e}else b=JSON.parse(b),d=JSON.parse(d);
27
  for(e=0;e<b.length;e++)grw_connection_add(a,c.querySelector(".grw-builder-platforms"),b[e],!0);for(var g in d)Object.prototype.hasOwnProperty.call(d,g)&&(a=c.querySelector('input[name="'+g+'"],select[name="'+g+'"],textarea[name="'+g+'"]'))&&(b=a.getAttribute("name"),"boolean"===typeof d[g]?a.checked=d[g]:(a.value="textarea"==a.type||"word_filter"==b||"word_exclude"==b?decodeURIComponent(d[g]):d[g],-1<g.indexOf("_photo")&&a.value&&(a.parentNode.querySelector("img").src=a.value)))}
28
  function grw_upload_photo(a,c,b){if(GRW_VARS.wordpress)c||(c=wp.media.frames.file_frame=wp.media({title:jQuery(this).data("uploader_title"),button:{text:jQuery(this).data("uploader_button_text")},multiple:!1}),c.on("select",function(){var d=c.state().get("selection").first().toJSON();grw_change_photo(a,d.url);b&&b(d.url)})),c.open();else return a.querySelector('input[type="file"]').click(),!1}
assets/src/js/admin-builder.js CHANGED
@@ -235,26 +235,54 @@ function grw_builder_init($, data) {
235
  }
236
 
237
  $('.wp-review-hide').click(function() {
238
- var $this = $(this);
239
- $.post(GRW_VARS.handlerUrl + '&cf_action=grw_hide_review', {
240
- id : $this.attr('data-id'),
241
- feed_id : $('input[name="grw_feed[post_id]"]').val(),
242
- grw_wpnonce : $('#grw_nonce').val()
243
- }, function(res) {
244
- var parent = $this.parent().parent();
245
- if (res.hide) {
246
- $this.text('show review');
247
- parent.addClass('wp-review-hidden');
248
- } else {
249
- $this.text('hide review');
250
- parent.removeClass('wp-review-hidden');
251
- }
252
- }, 'json');
253
  return false;
254
  });
255
 
256
  $('#grw_save').click(function() {
257
- return grw_feed_save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  });
259
  }
260
 
@@ -278,6 +306,23 @@ function grw_feed_save() {
278
  return false;
279
  }
280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  function grw_connection($, el, platform, authcode) {
282
  var connect_btn = el.querySelector('.grw-connect-btn');
283
  $(connect_btn).click(function() {
@@ -581,6 +626,16 @@ function grw_serialize_connections() {
581
  document.getElementById('grw-builder-connections').value = JSON.stringify(connections);
582
  document.getElementById('grw-builder-options').value = JSON.stringify(options);
583
  }
 
 
 
 
 
 
 
 
 
 
584
  }
585
 
586
  function grw_deserialize_connections($, el, connections, options) {
235
  }
236
 
237
  $('.wp-review-hide').click(function() {
238
+ grw_review_hide($(this));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  return false;
240
  });
241
 
242
  $('#grw_save').click(function() {
243
+ grw_feed_save_ajax();
244
+ return false;
245
+ });
246
+ }
247
+
248
+ function grw_feed_save_ajax($) {
249
+ if (!window.grw_title.value) {
250
+ window.grw_title.focus();
251
+ return false;
252
+ }
253
+
254
+ window.grw_save.innerText = 'Auto save, wait';
255
+ window.grw_save.disabled = true;
256
+
257
+ jQuery.post(ajaxurl, {
258
+
259
+ post_id : window.grw_post_id.value,
260
+ title : window.grw_title.value,
261
+ content : document.getElementById('grw-builder-connection').value,
262
+ action : 'grw_feed_save_ajax'
263
+
264
+ }, function(res) {
265
+
266
+ var wpgr = document.querySelectorAll('.wp-gr');
267
+ for (var i = 0; i < wpgr.length; i++) {
268
+ wpgr[i].parentNode.removeChild(wpgr[i]);
269
+ }
270
+
271
+ window.grw_collection_preview.innerHTML = res;
272
+
273
+ jQuery('.wp-review-hide').unbind('click').click(function() {
274
+ grw_review_hide(jQuery(this));
275
+ return false;
276
+ });
277
+
278
+ if (!window.grw_post_id.value) {
279
+ var post_id = document.querySelector('.wp-gr').getAttribute('data-id');
280
+ window.grw_post_id.value = post_id;
281
+ window.location.href = window.location.href + '&grw_feed_id=' + post_id;
282
+ }
283
+
284
+ window.grw_save.innerText = 'Save & Refresh';
285
+ window.grw_save.disabled = false;
286
  });
287
  }
288
 
306
  return false;
307
  }
308
 
309
+ function grw_review_hide($this) {
310
+ jQuery.post(GRW_VARS.handlerUrl + '&cf_action=grw_hide_review', {
311
+ id : $this.attr('data-id'),
312
+ feed_id : jQuery('input[name="grw_feed[post_id]"]').val(),
313
+ grw_wpnonce : jQuery('#grw_nonce').val()
314
+ }, function(res) {
315
+ var parent = $this.parent().parent();
316
+ if (res.hide) {
317
+ $this.text('show review');
318
+ parent.addClass('wp-review-hidden');
319
+ } else {
320
+ $this.text('hide review');
321
+ parent.removeClass('wp-review-hidden');
322
+ }
323
+ }, 'json');
324
+ }
325
+
326
  function grw_connection($, el, platform, authcode) {
327
  var connect_btn = el.querySelector('.grw-connect-btn');
328
  $(connect_btn).click(function() {
626
  document.getElementById('grw-builder-connections').value = JSON.stringify(connections);
627
  document.getElementById('grw-builder-options').value = JSON.stringify(options);
628
  }
629
+
630
+ if (connections.length) {
631
+ var first = connections[0],
632
+ title = window.grw_title.value;
633
+
634
+ if (!title) {
635
+ window.grw_title.value = first.name;
636
+ }
637
+ grw_feed_save_ajax();
638
+ }
639
  }
640
 
641
  function grw_deserialize_connections($, el, connections, options) {
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.2
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.2');
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.3
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.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/');
includes/class-assets.php CHANGED
@@ -101,10 +101,17 @@ class Assets {
101
  }
102
 
103
  public function enqueue_public_styles() {
 
 
 
104
  wp_enqueue_style('grw-public-main-css');
105
  }
106
 
107
  public function enqueue_public_scripts() {
 
 
 
 
108
  wp_enqueue_script('grw-public-main-js');
109
  }
110
 
101
  }
102
 
103
  public function enqueue_public_styles() {
104
+ if ($this->debug) {
105
+ wp_enqueue_style('grw-public-clean-css');
106
+ }
107
  wp_enqueue_style('grw-public-main-css');
108
  }
109
 
110
  public function enqueue_public_scripts() {
111
+ if ($this->debug) {
112
+ wp_enqueue_script('grw-public-time-js');
113
+ wp_enqueue_script('grw-public-blazy-js');
114
+ }
115
  wp_enqueue_script('grw-public-main-js');
116
  }
117
 
includes/class-builder-page.php CHANGED
@@ -65,8 +65,8 @@ class Builder_Page {
65
  ?>
66
  <div class="grw-builder">
67
  <form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=' . Post_Types::FEED_POST_TYPE . '_save')); ?>">
68
- <input type="hidden" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[post_id]" value="<?php echo esc_attr($feed_id); ?>">
69
- <input type="hidden" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[current_url]" value="<?php echo home_url($_SERVER['REQUEST_URI']); ?>">
70
  <div class="grw-builder-workspace">
71
  <div class="grw-toolbar">
72
  <div class="grw-toolbar-title">
@@ -87,6 +87,7 @@ class Builder_Page {
87
  </div>
88
  <div class="grw-builder-preview">
89
  <textarea id="grw-builder-connection" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[content]" style="display:none"><?php echo $feed_content; ?></textarea>
 
90
  <?php
91
  if ($feed_inited) {
92
  echo $this->view->render($feed_id, $businesses, $reviews, $options, true);
@@ -95,6 +96,7 @@ class Builder_Page {
95
  '<b>Save & Update</b>' button. Then you can use this created widget on a sidebar or through a shortcode.<?php
96
  }
97
  ?>
 
98
  </div>
99
  </div>
100
  <div id="grw-builder-option" class="grw-builder-options"></div>
65
  ?>
66
  <div class="grw-builder">
67
  <form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=' . Post_Types::FEED_POST_TYPE . '_save')); ?>">
68
+ <input type="hidden" id="grw_post_id" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[post_id]" value="<?php echo esc_attr($feed_id); ?>">
69
+ <input type="hidden" id="grw_current_url" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[current_url]" value="<?php echo home_url($_SERVER['REQUEST_URI']); ?>">
70
  <div class="grw-builder-workspace">
71
  <div class="grw-toolbar">
72
  <div class="grw-toolbar-title">
87
  </div>
88
  <div class="grw-builder-preview">
89
  <textarea id="grw-builder-connection" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[content]" style="display:none"><?php echo $feed_content; ?></textarea>
90
+ <div id="grw_collection_preview">
91
  <?php
92
  if ($feed_inited) {
93
  echo $this->view->render($feed_id, $businesses, $reviews, $options, true);
96
  '<b>Save & Update</b>' button. Then you can use this created widget on a sidebar or through a shortcode.<?php
97
  }
98
  ?>
99
+ </div>
100
  </div>
101
  </div>
102
  <div id="grw-builder-option" class="grw-builder-options"></div>
includes/class-feed-serializer-ajax.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WP_Rplg_Google_Reviews\Includes;
4
+
5
+ use WP_Rplg_Google_Reviews\Includes\Core\Core;
6
+
7
+ class Feed_Serializer_Ajax {
8
+
9
+ public function __construct(Feed_Deserializer $feed_deserializer, Core $core, View $view) {
10
+ $this->feed_deserializer = $feed_deserializer;
11
+ $this->core = $core;
12
+ $this->view = $view;
13
+
14
+ add_action('wp_ajax_grw_feed_save_ajax', array($this, 'save_ajax'));
15
+ }
16
+
17
+ public function save_ajax() {
18
+
19
+ $post_id = wp_insert_post(array(
20
+ 'ID' => $_POST['post_id'],
21
+ 'post_title' => $_POST['title'],
22
+ 'post_content' => $_POST['content'],
23
+ 'post_type' => Post_Types::FEED_POST_TYPE,
24
+ 'post_status' => 'publish',
25
+ ));
26
+
27
+ if (isset($post_id)) {
28
+ $feed = $this->feed_deserializer->get_feed($post_id);
29
+
30
+ $data = $this->core->get_reviews($feed, true);
31
+ $businesses = $data['businesses'];
32
+ $reviews = $data['reviews'];
33
+ $options = $data['options'];
34
+
35
+ echo $this->view->render($feed->ID, $businesses, $reviews, $options, true);
36
+ }
37
+
38
+ wp_die();
39
+ }
40
+
41
+ }
includes/class-plugin.php CHANGED
@@ -76,6 +76,7 @@ final class Plugin {
76
 
77
  if (is_admin()) {
78
  $feed_serializer = new Feed_Serializer();
 
79
 
80
  $admin_notice = new Admin_Notice();
81
  $admin_notice->register();
76
 
77
  if (is_admin()) {
78
  $feed_serializer = new Feed_Serializer();
79
+ $feed_serializer_ajax = new Feed_Serializer_Ajax($feed_deserializer, $core, $view);
80
 
81
  $admin_notice = new Admin_Notice();
82
  $admin_notice->register();
includes/class-view.php CHANGED
@@ -32,7 +32,7 @@ class View {
32
  }
33
 
34
  ?>
35
- <div class="wp-gr wpac"<?php if ($style) { ?> style="<?php echo $style;?>"<?php } ?>>
36
  <?php
37
  switch ($options->view_mode) {
38
  case 'badge':
32
  }
33
 
34
  ?>
35
+ <div class="wp-gr wpac"<?php if ($style) { ?> style="<?php echo $style;?>"<?php } ?> data-id="<?php echo $feed_id; ?>">
36
  <?php
37
  switch ($options->view_mode) {
38
  case 'badge':
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.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Widget and shortcode for Google reviews! Shows Google reviews on your WordPress website to increase user confidence and SEO.
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.2 =
87
  * Improve instantly Google reviews connection
88
  * Separated assets to dist and src for speed up the loading
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
 
84
  == Changelog ==
85
 
86
+ = 2.0.3 =
87
+ * Ajax auto-save for widgets
88
+ * Small bug fixes
89
+
90
  = 2.0.2 =
91
  * Improve instantly Google reviews connection
92
  * Separated assets to dist and src for speed up the loading