Yasr – Yet Another Stars Rating - Version 2.8.0

Version Description

  • FIXED: if blogPosting itemType is selected, and a non valid url image is is supplied in the rich snippets settings, a php warning is returned
  • TWEAKED: The ajax method yasr_stats_visitors_votes now returns only json data, instead of HTML
  • TWEAKED: Ajax error responses are now json_encoded
  • TWEAKED: stats tooltip in yasr_visitor_votes works now with flexbox
  • TWEAKED: minor changes
Download this release

Release Info

Developer Dudo
Plugin Icon 128x128 Yasr – Yet Another Stars Rating
Version 2.8.0
Comparing to
See all releases

Code changes from version 2.7.9 to 2.8.0

admin/editor/YasrOnSavePost.php CHANGED
@@ -216,7 +216,7 @@ class YasrOnSavePost {
216
  }
217
 
218
  if (!wp_verify_nonce($nonce, 'yasr_nonce_save_multi_values_action')) {
219
- die('Security check');
220
  }
221
 
222
  $i = 0;
216
  }
217
 
218
  if (!wp_verify_nonce($nonce, 'yasr_nonce_save_multi_values_action')) {
219
+ return;
220
  }
221
 
222
  $i = 0;
admin/js/src/yasr-admin-functions.js CHANGED
@@ -1,4 +1,4 @@
1
- copyToClipboard = string => {
2
  const el = document.createElement('textarea');
3
  el.value = string;
4
  el.setAttribute('readonly', '');
1
+ export const copyToClipboard = string => {
2
  const el = document.createElement('textarea');
3
  el.value = string;
4
  el.setAttribute('readonly', '');
admin/js/src/yasr-settings-rankings.js CHANGED
@@ -1,4 +1,5 @@
1
  import {yasrDrawRankings} from "../../../includes/js/src/ranking";
 
2
  const { __ } = wp.i18n; // Import __() from wp.i18n
3
 
4
  let activeTab;
1
  import {yasrDrawRankings} from "../../../includes/js/src/ranking";
2
+ import {copyToClipboard} from "./yasr-admin-functions";
3
  const { __ } = wp.i18n; // Import __() from wp.i18n
4
 
5
  let activeTab;
admin/js/yasr-admin.js CHANGED
@@ -1 +1 @@
1
- !function(e){var a={};function o(t){if(a[t])return a[t].exports;var r=a[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=a,o.d=function(e,a,t){o.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:t})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,a){if(1&a&&(e=o(e)),8&a)return e;if(4&a&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&a&&"string"!=typeof e)for(var r in e)o.d(t,r,function(a){return e[a]}.bind(null,r));return t},o.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(a,"a",a),a},o.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},o.p="",o(o.s=0)}([function(e,a,o){o(1),e.exports=o(2)},function(e,a){copyToClipboard=e=>{const a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"})},function(e,a){jQuery(document).ready((function(){jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,a,o){var t=!0;void 0!==o.data&&(t=o.data.search("action=yasr_change_log_page")),-1!==t&&jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-log-container").html(e)}))}))}))})),jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,a,o){void 0!==o.data&&-1!==o.data.search("action=yasr_change_user_log_page")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-user-log-container").html(e)}))}))}))}))}]);
1
+ !function(e){var t={};function o(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,o),a.l=!0,a.exports}o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)o.d(r,a,function(t){return e[t]}.bind(null,a));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){o(1),e.exports=o(2)},function(e,t,o){"use strict";o.r(t),o.d(t,"copyToClipboard",(function(){return r}));const r=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)};tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"})},function(e,t){jQuery(document).ready((function(){jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,o){var r=!0;void 0!==o.data&&(r=o.data.search("action=yasr_change_log_page")),-1!==r&&jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-log-container").html(e)}))}))}))})),jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,o){void 0!==o.data&&-1!==o.data.search("action=yasr_change_user_log_page")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-user-log-container").html(e)}))}))}))}))}]);
admin/js/yasr-settings.js CHANGED
@@ -1 +1 @@
1
- !function(t){var e={};function a(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=t,a.c=e,a.d=function(t,e,r){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=0)}([function(t,e,a){a(1),t.exports=a(2)},function(t,e){var a;if(document.getElementsByClassName("nav-tab-active").length>0&&(a=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===a){var r=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===r&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===a&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===a){var s=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===s){var o=jQuery("#yasr-edit-form-number-elements").attr("value");o++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(o>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+o+' <input type="text" name="edit-multi-set-element-'+o+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),o++}))}else s>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===a&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,a){"use strict";var r,n;a.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},d=[],u=0;u<256;++u)d.push((u+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(d[t[e+0]]+d[t[e+1]]+d[t[e+2]]+d[t[e+3]]+"-"+d[t[e+4]]+d[t[e+5]]+"-"+d[t[e+6]]+d[t[e+7]]+"-"+d[t[e+8]]+d[t[e+9]]+"-"+d[t[e+10]]+d[t[e+11]]+d[t[e+12]]+d[t[e+13]]+d[t[e+14]]+d[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a};for(var y=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return c(r)},m=wp.i18n.__,g=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],p=0;p<g.length;p++)v(g[p]);function v(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;f(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=_(n),s=_(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),d=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),c=a.getAttribute("data-issingular"),y="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,v="yasr-vv-loader-"+l,f=document.getElementById(y),b=document.getElementById(g),E=document.getElementById(p),k=document.getElementById(v);if("yes"===yasrCommonData.ajaxEnabled){null!==k&&(k.innerHTML=yasrCommonData.loaderHtml);var I={action:"yasr_load_vv",post_id:o,nonce_visitor:u};jQuery.get(yasrCommonData.ajaxurl,I).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),h(d,r,o,e,i,l,u,c,f,b,k,E),!0!==n&&(null!==f&&(f.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==b&&(b.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==E&&(E.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,E.style.display=""))})).fail((function(t,e,a,y){console.info(m("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(d,r,o,s,i,l,u,c,f,b,k,E),!0!==n&&(E.style.display="")}))}else h(d,r,o,s,i,l,u,c,f,b,k,E)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a)&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=_(o);f(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(a)}))}))}(e)}}function f(t,e){var a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:s,rating:o,rateCallback:i})}function h(t,e,a,r,n,s,o,i,l,d,u,c){e=parseFloat(e),r=_(r);var y=document.getElementById(n);null!==u&&(u.innerHTML="");f(t,n,y,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==d&&(d.innerHTML=t.average_rating),null!==c&&(c.innerHTML=t.rating_saved_text,c.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function _(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function b(t){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,r=B(t);if(e){var n=B(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return w(this,a)}}function w(t,e){return!e||"object"!==b(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}M();var j=wp.i18n.__,R=wp.element.render;function x(t){var e="yasr-ranking-element-"+y(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return f(a,e,!1,.1,!0,t.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",j("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",j("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function L(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function T(t){var e="after",a=j("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:a}),React.createElement(x,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(x,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:a}))}function Q(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(L,{colClass:e,post:t.post}),React.createElement(T,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(Q,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var H=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}(s,React.Component);var e,a,r,n=I(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(j("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(j("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(j(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(j(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:j("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},j("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},j("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},j("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},j("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,j("Order By","yet-another-stars-rating-pro"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(S,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",d=new URLSearchParams(r);return null!==d.get("view")&&(o=d.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(a,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:i,source:a}),React.createElement(S,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:l,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,j("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,a),r&&E(e,r),s}();function M(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);R(React.createElement(H,{source:r,tableId:a,params:n,nonce:s}),o)}}var O,P=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(O=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===O){var N,A=function(t){var e=G.value,a=document.getElementById("yasr-builder-shortcode").textContent,r=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];r=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",r),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+a).then((function(t){return!0===t.ok?t.json():(console.info(P("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,Y.childNodes.length>0?Y.replaceChild(e,Y.childNodes[0]):Y.appendChild(e)}})).then((function(t){r.forEach((function(t){e===t&&M()}))}))},D=function(t,e,a,r,n,s,o,i,l){t.style.display="",e.style.display="",s.style.display="",l.style.display="",a.style.display="none",r.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},F=function(t,e,a,r,n,s,o,i,l){a.style.display="",r.style.display="",e.style.display="",s.style.display="",l.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,a,r,n,s,o,i,l){n.style.display="",l.style.display="none",t.style.display="none",a.style.display="none",r.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},J=function(t,e,a,r,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(Z.className="",Z.classList.add("yasr-settings-row-24"),a.style.display="",r.style.display="",t.style.display="none"):(a.style.display="none",r.style.display="none",t.style.display=""),s.style.display="",e.style.display="",d.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),jQuery(".yasr-builder-elements-parents").find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var U=[],q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};N=q.name,document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]");var V=document.getElementById("yasr-builder-button-preview"),K=document.getElementById("yasr-builder-copy-shortcode"),Y=document.getElementById("yasr-builder-preview"),G=document.getElementById("yasr-ranking-source"),$=document.getElementById("yasr-ranking-multiset-select"),W=document.getElementById("yasr-builder-datepicker-start"),X=document.getElementById("yasr-builder-datepicker-end"),Z=document.getElementById("yasr-builder-params-container"),tt=document.getElementById("builder-vv-default-view"),et=document.getElementById("builder-vv-required-votes"),at=document.getElementById("builder-stars-size"),rt=document.getElementById("builder-overall-text"),nt=document.getElementById("builder-username-options"),st=document.getElementById("builder-category"),ot=document.getElementById("builder-cpt"),it=document.getElementById("yasr-ranking-multiset"),lt=document.getElementById("yasr-builder-datepicker"),dt=G.value,ut=!1;W.value="",X.value="","yasr_ov_ranking"===dt?D(rt,at,tt,et,nt,st,ot,it,lt):"yasr_most_active_users"===dt||"yasr_top_reviewers"===dt?z(rt,at,tt,et,nt,st,ot,it,lt):"yasr_multi_set_ranking"===dt?J(rt,at,tt,et,nt,st,ot,it,!1,lt):"yasr_visitor_multi_set_ranking"===dt?J(rt,at,tt,et,nt,st,ot,it,!0,lt):F(rt,at,tt,et,nt,st,ot,it,lt),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)Z.className="",Z.classList.add("yasr-settings-row-33"),Y.innerHTML="",W.value="",X.value="",q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(rt,at,tt,et,nt,st,ot,it,lt):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(rt,at,tt,et,nt,st,ot,it,lt):"yasr_multi_set_ranking"===t.target.value?(J(rt,at,tt,et,nt,st,ot,it,!1,lt),q.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(J(rt,at,tt,et,nt,st,ot,it,!0,lt),q.setid=" setid="+$[0].value):F(rt,at,tt,et,nt,st,ot,it,lt),q.name=t.target.value,N=q.name+q.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(q.setid=" setid="+t.target.value),U=wp.hooks.applyFilters("yasrBuilderFilterShortcode",q);for(var e=2;q.length;e++)U.hasOwnProperty(q[e])&&(q[e]=U[e]);N=q.name+q.setid+q.rows+q.view+q.minvotesmost+q.minvoteshg+q.size+q.txtPosition+q.txt+q.display+q.start_date+q.end_date+q.category+q.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]"),!0===ut&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&A()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){A(),ut=!0}}}]);
1
+ !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(2)},function(t,e){var r;if(document.getElementsByClassName("nav-tab-active").length>0&&(r=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===r){var a=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===a&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===r&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===r){var s=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===s){var o=jQuery("#yasr-edit-form-number-elements").attr("value");o++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(o>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+o+' <input type="text" name="edit-multi-set-element-'+o+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),o++}))}else s>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===r&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,r){"use strict";var a,n;r.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},d=[],u=0;u<256;++u)d.push((u+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(d[t[e+0]]+d[t[e+1]]+d[t[e+2]]+d[t[e+3]]+"-"+d[t[e+4]]+d[t[e+5]]+"-"+d[t[e+6]]+d[t[e+7]]+"-"+d[t[e+8]]+d[t[e+9]]+"-"+d[t[e+10]]+d[t[e+11]]+d[t[e+12]]+d[t[e+13]]+d[t[e+14]]+d[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};for(var y=function(t,e,r){var a=(t=t||{}).random||(t.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return c(a)},m=wp.i18n.__,g=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],p=0;p<g.length;p++)v(g[p]);function v(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;h(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),s=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=b(n),s=b(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),d=parseInt(r.getAttribute("data-rater-starsize")),u=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),y="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,v="yasr-vv-loader-"+l,f=document.getElementById(y),h=document.getElementById(g),E=document.getElementById(p),k=document.getElementById(v);if("yes"===yasrCommonData.ajaxEnabled){null!==k&&(k.innerHTML=yasrCommonData.loaderHtml);var w={action:"yasr_load_vv",post_id:o,nonce_visitor:u};jQuery.get(yasrCommonData.ajaxurl,w).done((function(t){var e,r=JSON.parse(t);e=!0===n||r.yasr_visitor_votes.stars_attributes.read_only,a=(a=r.yasr_visitor_votes.number_of_votes>0?r.yasr_visitor_votes.sum_votes/r.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),_(d,a,o,e,i,l,u,c,f,h,k,E),!0!==n&&(null!==f&&(f.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==h&&(h.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==E&&(E.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,E.style.display=""))})).fail((function(t,e,r,y){console.info(m("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),_(d,a,o,s,i,l,u,c,f,h,k,E),!0!==n&&(E.style.display="")}))}else _(d,a,o,s,i,l,u,c,f,h,k,E)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e,r,a=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(r=window.getComputedStyle(e[0],null).getPropertyValue("color")),r)&&(document.getElementById(t.item(n).id).style.fill=r);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){s!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(f(e))}))},onHidden:function(){a=s}})}(n)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),s=n.id,o=n.getAttribute("data-rater-readonly");o=b(o);h(16,s,n,1,o,!1,(function(t,a){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){var a;a=(r=JSON.parse(r)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(a)}))}))}(e)}}function f(t){var e=t.medium_rating;delete t.medium_rating;for(var r=0,a=1;a<=5;a++)(1===a||t[a].n_of_votes>r)&&(r=t[a].n_of_votes);var n=Math.log(r)*Math.LOG10E+1|0,s="5%";n<=3&&(s="5%"),n>3&&n<=5&&(s="10%"),n>5&&(s="15%");var o='<div class="yasr-visitors-stats-tooltip">';o+='<span id="yasr-medium-rating-tooltip">'+e+" "+m("out of 5 stars","yet-another-stars-rating")+"</span>",o+='<div class="yasr-progress-bars-container">';for(var i=m("stars","yet-another-stars-rating"),l=0,d=0,u=5;u>0;u--)1===u&&(i=m("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,d=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:").concat(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(d,"</div>\n </div>");return o+="</div></div>"}function h(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:s,rating:o,rateCallback:i})}function _(t,e,r,a,n,s,o,i,l,d,u,c){e=parseFloat(e),a=b(a);var y=document.getElementById(n);null!==u&&(u.innerHTML="");h(t,n,y,1,a,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){var e,r,a;"success"===(t=JSON.parse(t)).status?(e=t.number_of_votes,r=t.average_rating,a=t.rating_saved_text,null!==l&&(l.innerHTML=e),null!==d&&(d.innerHTML=r)):a=t.text,null!==c&&(c.innerHTML=a,c.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function b(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function E(t){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function k(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function w(t,e){return(w=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=j(t);if(e){var n=j(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return B(this,r)}}function B(t,e){return!e||"object"!==E(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function j(t){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}O();var x=wp.i18n.__,R=wp.element.render;function C(t){var e="yasr-ranking-element-"+y(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return h(r,e,!1,.1,!0,t.rating)}})}function L(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",x("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",x("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function T(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function Q(t){var e="after",r=x("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(L,{post:t.post,tableId:t.tableId,text:r}),React.createElement(C,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(C,{rating:t.post.rating,tableId:t.tableId}),React.createElement(L,{post:t.post,tableId:t.tableId,text:r}))}function S(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(T,{colClass:e,post:t.post}),React.createElement(Q,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function H(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(S,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var M=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&w(t,e)}(s,React.Component);var e,r,a,n=I(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(x("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(x("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(x(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(x(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:x("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+r+n+a];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+r+n+o+a,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+r+n+i+a]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:a},x("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},x("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},x("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},x("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,x("Order By","yet-another-stars-rating-pro"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,s="most-rated-posts-"+r,o="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(H,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",d=new URLSearchParams(a);return null!==d.get("view")&&(o=d.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(H,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(H,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,x("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&k(e.prototype,r),a&&k(e,a),s}();function O(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(r);R(React.createElement(M,{source:a,tableId:r,params:n,nonce:s}),o)}}tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var P,N=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(P=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===P){var A,D=function(t){var e=$.value,r=document.getElementById("yasr-builder-shortcode").textContent,a=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];a=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",a),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+r).then((function(t){return!0===t.ok?t.json():(console.info(N("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,G.childNodes.length>0?G.replaceChild(e,G.childNodes[0]):G.appendChild(e)}})).then((function(t){a.forEach((function(t){e===t&&O()}))}))},F=function(t,e,r,a,n,s,o,i,l){t.style.display="",e.style.display="",s.style.display="",l.style.display="",r.style.display="none",a.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},J=function(t,e,r,a,n,s,o,i,l){r.style.display="",a.style.display="",e.style.display="",s.style.display="",l.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,r,a,n,s,o,i,l){n.style.display="",l.style.display="none",t.style.display="none",r.style.display="none",a.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},U=function(t,e,r,a,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(tt.className="",tt.classList.add("yasr-settings-row-24"),r.style.display="",a.style.display="",t.style.display="none"):(r.style.display="none",a.style.display="none",t.style.display=""),s.style.display="",e.style.display="",d.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),jQuery(".yasr-builder-elements-parents").find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var q=[],V={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};A=V.name,document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]");var K=document.getElementById("yasr-builder-button-preview"),Y=document.getElementById("yasr-builder-copy-shortcode"),G=document.getElementById("yasr-builder-preview"),$=document.getElementById("yasr-ranking-source"),W=document.getElementById("yasr-ranking-multiset-select"),X=document.getElementById("yasr-builder-datepicker-start"),Z=document.getElementById("yasr-builder-datepicker-end"),tt=document.getElementById("yasr-builder-params-container"),et=document.getElementById("builder-vv-default-view"),rt=document.getElementById("builder-vv-required-votes"),at=document.getElementById("builder-stars-size"),nt=document.getElementById("builder-overall-text"),st=document.getElementById("builder-username-options"),ot=document.getElementById("builder-category"),it=document.getElementById("builder-cpt"),lt=document.getElementById("yasr-ranking-multiset"),dt=document.getElementById("yasr-builder-datepicker"),ut=$.value,ct=!1;X.value="",Z.value="","yasr_ov_ranking"===ut?F(nt,at,et,rt,st,ot,it,lt,dt):"yasr_most_active_users"===ut||"yasr_top_reviewers"===ut?z(nt,at,et,rt,st,ot,it,lt,dt):"yasr_multi_set_ranking"===ut?U(nt,at,et,rt,st,ot,it,lt,!1,dt):"yasr_visitor_multi_set_ranking"===ut?U(nt,at,et,rt,st,ot,it,lt,!0,dt):J(nt,at,et,rt,st,ot,it,lt,dt),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)tt.className="",tt.classList.add("yasr-settings-row-33"),G.innerHTML="",X.value="",Z.value="",V={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?F(nt,at,et,rt,st,ot,it,lt,dt):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(nt,at,et,rt,st,ot,it,lt,dt):"yasr_multi_set_ranking"===t.target.value?(U(nt,at,et,rt,st,ot,it,lt,!1,dt),V.setid=" setid="+W[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(U(nt,at,et,rt,st,ot,it,lt,!0,dt),V.setid=" setid="+W[0].value):J(nt,at,et,rt,st,ot,it,lt,dt),V.name=t.target.value,A=V.name+V.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(V.setid=" setid="+t.target.value),q=wp.hooks.applyFilters("yasrBuilderFilterShortcode",V);for(var e=2;V.length;e++)q.hasOwnProperty(V[e])&&(V[e]=q[e]);A=V.name+V.setid+V.rows+V.view+V.minvotesmost+V.minvoteshg+V.size+V.txtPosition+V.txt+V.display+V.start_date+V.end_date+V.category+V.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]"),!0===ct&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&D()})),Y.onclick=function(t){!function(t){var e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="absolute",e.style.left="-9999px",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}(document.getElementById(t.target.id).getAttribute("data-shortcode"))},K.onclick=function(t){D(),ct=!0}}}]);
admin/settings/classes/YasrSettings.php CHANGED
@@ -777,7 +777,6 @@ class YasrSettings {
777
  } //End function
778
 
779
  public function sanitize($option) {
780
-
781
  //Array to return
782
  $output = array();
783
 
777
  } //End function
778
 
779
  public function sanitize($option) {
 
780
  //Array to return
781
  $output = array();
782
 
admin/settings/migrations/yasr-settings-migration-functions.php CHANGED
@@ -168,7 +168,7 @@ function yasr_import_ratemypost_callback() {
168
  exit();
169
  }
170
 
171
- if (!wp_verify_nonce( $nonce, 'yasr-import-ratemypost-action' ) ) {
172
  die('Error while checking nonce');
173
  }
174
 
168
  exit();
169
  }
170
 
171
+ if (!wp_verify_nonce($nonce, 'yasr-import-ratemypost-action')) {
172
  die('Error while checking nonce');
173
  }
174
 
includes/classes/YasrMultiSetData.php CHANGED
@@ -311,7 +311,10 @@ class YasrMultiSetData {
311
  *
312
  * @author Dario Curvino <@dudo>
313
  * @since 2.7.3
 
314
  * @param $array_post_id
 
 
315
  * @return array
316
  */
317
  public static function returnMultiAuthorAverageArray ($array_post_id, $set_id) {
311
  *
312
  * @author Dario Curvino <@dudo>
313
  * @since 2.7.3
314
+ *
315
  * @param $array_post_id
316
+ * @param $set_id
317
+ *
318
  * @return array
319
  */
320
  public static function returnMultiAuthorAverageArray ($array_post_id, $set_id) {
includes/css/yasr.css CHANGED
@@ -140,41 +140,28 @@ yasr_pro_comment_reviews_stats shortcode too***/
140
  font-size: 14px;
141
  }
142
 
143
- .yasr-progress-bars-container {
144
- width: 100% !important;
145
- }
146
-
147
  .yasr-progress-bar-row-container {
148
- padding-top: 2px !important;
149
- padding-left: 5px !important;
150
- padding-right: 5px !important;
151
- display: block !important;
 
152
  }
153
 
154
  .yasr-progress-bar-name {
155
- display: inline-block !important;
156
- float: left;
157
- width: 20% !important;
158
  font-size: 14px !important;
159
- line-height: 1.5 !important;
160
- text-align: center !important;
161
  }
162
 
163
  .yasr-single-progress-bar-container {
164
- width: 70% !important;;
165
- float: left;
166
  }
167
 
168
- .yasr-progress-bar {
169
- display: inline-block !important;
170
- }
171
-
172
-
173
  .yasr-progress-bar-votes-count {
174
- display: inline-block !important;
175
- width: 10%;
176
- float: right;
177
- text-align: right;
178
  font-size: 14px !important;
179
  }
180
 
@@ -185,7 +172,7 @@ yasr_pro_comment_reviews_stats shortcode too***/
185
  /*** Tooltip ***/
186
 
187
  .yasr-visitors-stats-tooltip {
188
- min-width:245px;
189
  text-align: center;
190
  background-color: white;
191
  color: #0a0a0a;
@@ -207,7 +194,6 @@ yasr_pro_comment_reviews_stats shortcode too***/
207
 
208
  /*** Tooltip ***/
209
 
210
- .yasr-w3-container:after,.yasr-w3-container:before{content:"";display:table;clear:both}
211
  .yasr-w3-border-0{border:0!important}.yasr-w3-border{border:1px solid #ccc!important; background: linear-gradient(to bottom,#eee,#f6f6f6);}
212
  .yasr-w3-border-top{border-top:1px solid #ccc!important}.yasr-w3-border-bottom{border-bottom:1px solid #ccc!important}
213
  .yasr-w3-border-left{border-left:1px solid #ccc!important}.yasr-w3-border-right{border-right:1px solid #ccc!important}
140
  font-size: 14px;
141
  }
142
 
 
 
 
 
143
  .yasr-progress-bar-row-container {
144
+ width: 100%;
145
+ display: flex;
146
+ align-items: center;
147
+ padding-top: 2px;
148
+ padding-bottom: 2px;
149
  }
150
 
151
  .yasr-progress-bar-name {
152
+ flex-grow: 1;
153
+ flex-basis: 12%;
 
154
  font-size: 14px !important;
 
 
155
  }
156
 
157
  .yasr-single-progress-bar-container {
158
+ flex-grow: 12;
 
159
  }
160
 
 
 
 
 
 
161
  .yasr-progress-bar-votes-count {
162
+ flex-grow: 1;
163
+ padding-left: 2px;
164
+ padding-right: 2px;
 
165
  font-size: 14px !important;
166
  }
167
 
172
  /*** Tooltip ***/
173
 
174
  .yasr-visitors-stats-tooltip {
175
+ min-width:300px;
176
  text-align: center;
177
  background-color: white;
178
  color: #0a0a0a;
194
 
195
  /*** Tooltip ***/
196
 
 
197
  .yasr-w3-border-0{border:0!important}.yasr-w3-border{border:1px solid #ccc!important; background: linear-gradient(to bottom,#eee,#f6f6f6);}
198
  .yasr-w3-border-top{border-top:1px solid #ccc!important}.yasr-w3-border-bottom{border-bottom:1px solid #ccc!important}
199
  .yasr-w3-border-left{border-left:1px solid #ccc!important}.yasr-w3-border-right{border-right:1px solid #ccc!important}
includes/js/src/ranking.js CHANGED
@@ -591,7 +591,6 @@ class YasrRanking extends React.Component {
591
  }
592
 
593
  export function yasrDrawRankings () {
594
-
595
  //check if there is some shortcode with class yasr-table-chart
596
  const yasrRankingsInDom = document.getElementsByClassName('yasr-stars-rankings');
597
 
@@ -606,5 +605,4 @@ export function yasrDrawRankings () {
606
  render(<YasrRanking source={source} tableId={tableId} params={params} nonce={nonce} />, rankingTable);
607
  }
608
  }
609
-
610
  }
591
  }
592
 
593
  export function yasrDrawRankings () {
 
594
  //check if there is some shortcode with class yasr-table-chart
595
  const yasrRankingsInDom = document.getElementsByClassName('yasr-stars-rankings');
596
 
605
  render(<YasrRanking source={source} tableId={tableId} params={params} nonce={nonce} />, rankingTable);
606
  }
607
  }
 
608
  }
includes/js/src/yasr-front.js CHANGED
@@ -34,7 +34,7 @@ export function yasrSearchStarsDom (starsClass) {
34
  if (yasrCommonData.visitorStatsEnabled === 'yes') {
35
  let yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
36
  if (yasrStatsInDom) {
37
- yasrDrawTipsProgress (yasrStatsInDom);
38
  }
39
  }
40
  }
@@ -48,7 +48,7 @@ export function yasrSearchStarsDom (starsClass) {
48
  /****** Tooltip function ******/
49
 
50
  //used in shortcode page and ajax page
51
- function yasrDrawTipsProgress (yasrStatsInDom) {
52
  //htmlcheckid declared false
53
  let htmlIdChecked = false;
54
 
@@ -86,9 +86,10 @@ function yasrDrawTipsProgress (yasrStatsInDom) {
86
  let initialContent = '<span style="color: #0a0a0a">Loading...</span>';
87
 
88
  tippy(htmlId, {
 
89
  content: initialContent,
90
  theme: 'yasr',
91
- arrow: 'true',
92
  arrowType: 'round',
93
 
94
  //When support for IE will be dropped out, this will become onShow(tip)
@@ -97,7 +98,7 @@ function yasrDrawTipsProgress (yasrStatsInDom) {
97
  //must be post or wont work
98
  jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
99
  response = JSON.parse(response);
100
- tip.setContent(response);
101
  });
102
  }
103
  },
@@ -112,6 +113,129 @@ function yasrDrawTipsProgress (yasrStatsInDom) {
112
 
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  /****** End tooltipfunction ******/
116
 
117
  //this is the function that print the overall rating shortcode, get overall rating and starsize
@@ -322,15 +446,30 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
322
  jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
323
  //decode json
324
  response = JSON.parse(response);
325
- //hide the loader
326
- if (containerVotesNumber !== null) {
327
- containerVotesNumber.innerHTML = response.number_of_votes;
328
- }
329
- if (containerAverageNumber !== null) {
330
- containerAverageNumber.innerHTML = response.average_rating;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  }
 
332
  if (bottomContainer !== null) {
333
- bottomContainer.innerHTML = response.rating_saved_text;
334
  //Be sure the bottom container is showed
335
  bottomContainer.style.display = '';
336
  }
@@ -420,7 +559,11 @@ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
420
 
421
  //Send value to the Server
422
  jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
423
- jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).text(response);
 
 
 
 
424
  });
425
 
426
  });
34
  if (yasrCommonData.visitorStatsEnabled === 'yes') {
35
  let yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
36
  if (yasrStatsInDom) {
37
+ yasrVvStats (yasrStatsInDom);
38
  }
39
  }
40
  }
48
  /****** Tooltip function ******/
49
 
50
  //used in shortcode page and ajax page
51
+ function yasrVvStats (yasrStatsInDom) {
52
  //htmlcheckid declared false
53
  let htmlIdChecked = false;
54
 
86
  let initialContent = '<span style="color: #0a0a0a">Loading...</span>';
87
 
88
  tippy(htmlId, {
89
+ allowHTML: true,
90
  content: initialContent,
91
  theme: 'yasr',
92
+ arrow: true,
93
  arrowType: 'round',
94
 
95
  //When support for IE will be dropped out, this will become onShow(tip)
98
  //must be post or wont work
99
  jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
100
  response = JSON.parse(response);
101
+ tip.setContent(yasrReturnToolbarStats(response));
102
  });
103
  }
104
  },
113
 
114
  }
115
 
116
+ /**
117
+ * Return the HTML with toolbars
118
+ *
119
+ * @param ratings MUST be an object
120
+ * with 6 params: 1 int and 5 suboject
121
+ * int: medium_rating
122
+ * subobject: each one must have:
123
+ * - progressbar
124
+ * - n_of_votes
125
+ * - votes (optional)
126
+ * e.g.
127
+ {
128
+ "1": {
129
+ "progressbar": "17.14%",
130
+ "n_of_votes": 6,
131
+ "vote": "1"
132
+ },
133
+ "2": {
134
+ "progressbar": "25.71%",
135
+ "n_of_votes": 9,
136
+ "vote": "2"
137
+ },
138
+ "3": {
139
+ "progressbar": "8.57%",
140
+ "n_of_votes": 3,
141
+ "vote": "3"
142
+ },
143
+ "4": {
144
+ "progressbar": "0%",
145
+ "n_of_votes": 0,
146
+ "vote": 4
147
+ },
148
+ "5": {
149
+ "progressbar": "48.57%",
150
+ "n_of_votes": 17,
151
+ "vote": "5"
152
+ }
153
+ }
154
+ *
155
+ */
156
+ function yasrReturnToolbarStats (ratings) {
157
+ //Get the medium rating
158
+ const mediumRating = ratings.medium_rating;
159
+
160
+ //remove medium rating from the object, so I can loop only the ratings later
161
+ delete ratings['medium_rating'];
162
+
163
+ let highestNumberOfVotes = 0;
164
+ //loop a first time the array to get the highest number of votes
165
+ for (let i = 1; i <= 5; i++) {
166
+ if(i === 1) {
167
+ highestNumberOfVotes = ratings[i].n_of_votes;
168
+ } else {
169
+ if (ratings[i].n_of_votes > highestNumberOfVotes) {
170
+ highestNumberOfVotes = ratings[i].n_of_votes;
171
+ }
172
+ }
173
+ }
174
+ //Later, I need to get the number of digits of the highest number
175
+ let lengthHighestNumberOfVotes = Math.log(highestNumberOfVotes) * Math.LOG10E + 1 | 0;
176
+
177
+ //Later, I've to calculate the flexbasis based on the lenght of the nummber
178
+ //default flexbasis is 5%
179
+ let flexbasis = '5%'
180
+
181
+ //if the length of the number is less or equal of 3 digits (999)
182
+ //flexbasis is 5%
183
+ if(lengthHighestNumberOfVotes <= 3) {
184
+ flexbasis = '5%';
185
+ }
186
+ //if the length of the number is major of 3 digits and less or equal of 5 digits (99999)
187
+ //flexbasis is 10%
188
+ if(lengthHighestNumberOfVotes > 3 && lengthHighestNumberOfVotes <= 5) {
189
+ flexbasis = '10%';
190
+ }
191
+ //if highest of 5 digits, flexbasis is 15 % (note that this will break into a newline when 8 digits are
192
+ //reached, but I think that a number of 9,999,999 is enough
193
+ if(lengthHighestNumberOfVotes > 5) {
194
+ flexbasis = '15%';
195
+ }
196
+
197
+ //prepare the html to return
198
+ let html_to_return = '<div class="yasr-visitors-stats-tooltip">';
199
+ html_to_return += '<span id="yasr-medium-rating-tooltip">'
200
+ + mediumRating
201
+ + ' '
202
+ + __('out of 5 stars', 'yet-another-stars-rating')
203
+ + '</span>';
204
+ html_to_return += '<div class="yasr-progress-bars-container">';
205
+
206
+ let stars_text = __('stars', 'yet-another-stars-rating'); //default is plural
207
+ let progressbar = 0; //default value for progressbar
208
+ let n_votes = 0; //default n_votes
209
+
210
+ //Do a for with 5 rows
211
+ for (let i = 5; i > 0; i--) {
212
+ if (i === 1) {
213
+ stars_text = __('star', 'yet-another-stars-rating'); //single form
214
+ }
215
+
216
+ //should never happen, just to be sage
217
+ if(typeof ratings[i] !== 'undefined') {
218
+ progressbar = ratings[i].progressbar;
219
+ n_votes = ratings[i].n_of_votes;
220
+ }
221
+
222
+ html_to_return += `<div class='yasr-progress-bar-row-container yasr-w3-container'>
223
+ <div class='yasr-progress-bar-name'>${i} ${stars_text}</div>
224
+ <div class='yasr-single-progress-bar-container'>
225
+ <div class='yasr-w3-border'>
226
+ <div class='yasr-w3-amber' style='height:17px;width:${progressbar}'></div>
227
+ </div>
228
+ </div>
229
+ <div class='yasr-progress-bar-votes-count' style="flex-basis:${flexbasis} ">${n_votes}</div>
230
+ </div>`;
231
+
232
+ } //End foreach
233
+
234
+ html_to_return += '</div></div>';
235
+
236
+ return html_to_return;
237
+ }
238
+
239
  /****** End tooltipfunction ******/
240
 
241
  //this is the function that print the overall rating shortcode, get overall rating and starsize
446
  jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
447
  //decode json
448
  response = JSON.parse(response);
449
+
450
+ let number_of_votes;
451
+ let average_rating;
452
+ let text;
453
+
454
+ if(response.status === 'success') {
455
+ number_of_votes = response.number_of_votes;
456
+ average_rating = response.average_rating;
457
+ text = response.rating_saved_text;
458
+
459
+ //Update the ratings only if response is success
460
+ if (containerVotesNumber !== null) {
461
+ containerVotesNumber.innerHTML = number_of_votes;
462
+ }
463
+ if (containerAverageNumber !== null) {
464
+ containerAverageNumber.innerHTML = average_rating;
465
+ }
466
+ } else {
467
+ //get response error
468
+ text = response.text;
469
  }
470
+
471
  if (bottomContainer !== null) {
472
+ bottomContainer.innerHTML = text;
473
  //Be sure the bottom container is showed
474
  bottomContainer.style.display = '';
475
  }
559
 
560
  //Send value to the Server
561
  jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
562
+ let responseText;
563
+ response = JSON.parse(response);
564
+ responseText = response.text
565
+
566
+ jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).text(responseText);
567
  });
568
 
569
  });
includes/js/yasr-front.js CHANGED
@@ -1 +1 @@
1
- !function(t){var e={};function a(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=t,a.c=e,a.d=function(t,e,r){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=0)}([function(t,e,a){t.exports=a(1)},function(t,e,a){"use strict";var r,n;a.r(e),a.d(e,"yasrSearchStarsDom",(function(){return L})),a.d(e,"yasrSetRaterValue",(function(){return B}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a};var m=function(t,e,a){var r=(t=t||{}).random||(t.rng||s)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return d(r)};function g(t){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function y(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,r=h(t);if(e){var n=h(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return v(this,a)}}function v(t,e){return!e||"object"!==g(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return B(a,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function k(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function I(t){var e="after",a=b("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:a}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:a}))}function w(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(k,{colClass:e,post:t.post}),React.createElement(I,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(o,React.Component);var e,a,r,n=p(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=o,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("start_date")&&"0"!==o.get("start_date")&&(n+="&start_date="+o.get("start_date")),null!==o.get("end_date")&&"0"!==o.get("end_date")&&(n+="&end_date="+o.get("end_date")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+s+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:r},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),":  ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,o="most-rated-posts-"+a,s="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(r);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(a,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:i,source:a}),React.createElement(C,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:l,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&y(e.prototype,a),r&&y(e,r),o}();for(var x=wp.i18n.__,j=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],T=0;T<j.length;T++)L(j[T]);function L(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;B(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),o=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(a.getAttribute("data-rater-starsize")),c=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,f="yasr-vv-loader-"+l,p=document.getElementById(m),v=document.getElementById(g),h=document.getElementById(y),b=document.getElementById(f);if("yes"===yasrCommonData.ajaxEnabled){null!==b&&(b.innerHTML=yasrCommonData.loaderHtml);var _={action:"yasr_load_vv",post_id:s,nonce_visitor:c};jQuery.get(yasrCommonData.ajaxurl,_).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),P(u,r,s,e,i,l,c,d,p,v,b,h),!0!==n&&(null!==p&&(p.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==v&&(v.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(t,e,a,m){console.info(x("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,r,s,o,i,l,c,d,p,v,b,h),!0!==n&&(h.style.display="")}))}else P(u,r,s,o,i,l,c,d,p,v,b,h)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var o="#"+t.item(n).id,s=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a)&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:s};tippy(o,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){o!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){r=o}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);B(16,o,n,1,s,!1,(function(t,r){var o=n.getAttribute("data-rater-postid"),s=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:o,setid:s,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(a)}))}))}(e)}}function B(t,e){var a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,a,r,n,o,s,i,l,u,c,d){e=parseFloat(e),r=O(r);var m=document.getElementById(n);null!==c&&(c.innerHTML="");B(t,n,m,1,r,e,(function(t,e){null!==c&&(c.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==d&&(d.innerHTML=t.rating_saved_text,d.style.display=""),null!==c&&(c.innerHTML="")})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=JSON.parse(t.item(e).dataset.rankingNonce),s=document.getElementById(a);_(React.createElement(S,{source:r,tableId:a,params:n,nonce:o}),s)}}()}]);
1
+ !function(t){var e={};function a(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=t,a.c=e,a.d=function(t,e,r){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=0)}([function(t,e,a){t.exports=a(1)},function(t,e,a){"use strict";var r,n;a.r(e),a.d(e,"yasrSearchStarsDom",(function(){return j})),a.d(e,"yasrSetRaterValue",(function(){return O}));var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a};var m=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return d(r)};function g(t){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function y(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function v(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,r=h(t);if(e){var n=h(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return p(this,a)}}function p(t,e){return!e||"object"!==g(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return O(a,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function k(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function I(t){var e="after",a=b("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:a}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:a}))}function w(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(k,{colClass:e,post:t.post}),React.createElement(I,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function x(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(s,React.Component);var e,a,r,n=v(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(x,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",c=new URLSearchParams(r);return null!==c.get("view")&&(o=c.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(a,o),React.createElement(x,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:i,source:a}),React.createElement(x,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:l,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&y(e.prototype,a),r&&y(e,r),s}();for(var C=wp.i18n.__,L=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],T=0;T<L.length;T++)j(L[T]);function j(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;O(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=M(n),s=M(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,f="yasr-vv-loader-"+l,v=document.getElementById(m),p=document.getElementById(g),h=document.getElementById(y),b=document.getElementById(f);if("yes"===yasrCommonData.ajaxEnabled){null!==b&&(b.innerHTML=yasrCommonData.loaderHtml);var _={action:"yasr_load_vv",post_id:o,nonce_visitor:u};jQuery.get(yasrCommonData.ajaxurl,_).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),P(c,r,o,e,i,l,u,d,v,p,b,h),!0!==n&&(null!==v&&(v.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==p&&(p.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(t,e,a,m){console.info(C("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(c,r,o,s,i,l,u,d,v,p,b,h),!0!==n&&(h.style.display="")}))}else P(c,r,o,s,i,l,u,d,v,p,b,h)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a)&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(B(e))}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=M(o);O(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){var r;r=(a=JSON.parse(a)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function B(t){var e=t.medium_rating;delete t.medium_rating;for(var a=0,r=1;r<=5;r++)(1===r||t[r].n_of_votes>a)&&(a=t[r].n_of_votes);var n=Math.log(a)*Math.LOG10E+1|0,s="5%";n<=3&&(s="5%"),n>3&&n<=5&&(s="10%"),n>5&&(s="15%");var o='<div class="yasr-visitors-stats-tooltip">';o+='<span id="yasr-medium-rating-tooltip">'+e+" "+C("out of 5 stars","yet-another-stars-rating")+"</span>",o+='<div class="yasr-progress-bars-container">';for(var i=C("stars","yet-another-stars-rating"),l=0,c=0,u=5;u>0;u--)1===u&&(i=C("star","yet-another-stars-rating")),void 0!==t[u]&&(l=t[u].progressbar,c=t[u].n_of_votes),o+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(i,"</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:").concat(l,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(s,' ">').concat(c,"</div>\n </div>");return o+="</div></div>"}function O(t,e){var a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:s,rating:o,rateCallback:i})}function P(t,e,a,r,n,s,o,i,l,c,u,d){e=parseFloat(e),r=M(r);var m=document.getElementById(n);null!==u&&(u.innerHTML="");O(t,n,m,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(function(t){var e,a,r;"success"===(t=JSON.parse(t)).status?(e=t.number_of_votes,a=t.average_rating,r=t.rating_saved_text,null!==l&&(l.innerHTML=e),null!==c&&(c.innerHTML=a)):r=t.text,null!==d&&(d.innerHTML=r,d.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function M(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);_(React.createElement(S,{source:r,tableId:a,params:n,nonce:s}),o)}}()}]);
includes/shortcodes/classes/YasrShortcodesAjax.php CHANGED
@@ -77,8 +77,9 @@ class YasrShortcodesAjax {
77
 
78
  do_action('yasr_action_on_visitor_vote', $array_action_visitor_vote);
79
 
80
- if (!wp_verify_nonce($nonce_visitor, 'yasr_nonce_vv')) {
81
- die('Security check');
 
82
  }
83
 
84
  if ($rating < 1) {
@@ -213,6 +214,7 @@ class YasrShortcodesAjax {
213
  . '</span>';
214
 
215
  return array(
 
216
  'number_of_votes' => $number_of_votes,
217
  'average_rating' => $medium_rating,
218
  'rating_saved_text' => $rating_saved_span
@@ -259,9 +261,6 @@ class YasrShortcodesAjax {
259
 
260
  //this means is an ajax call
261
  if (isset($_GET['action']) && $_GET['action'] === 'yasr_load_vv' && isset($_GET['nonce_visitor'])) {
262
- if (!wp_verify_nonce($_GET['nonce_visitor'], 'yasr_nonce_vv')) {
263
- die('Security check');
264
- }
265
  $array_to_echo['yasr_visitor_votes'] = $array_to_return;
266
  echo json_encode($array_to_echo);
267
  die();
@@ -296,8 +295,9 @@ class YasrShortcodesAjax {
296
  exit();
297
  }
298
 
299
- if (!wp_verify_nonce($nonce, 'yasr_nonce_insert_visitor_rating_multiset')) {
300
- die('Security Check');
 
301
  }
302
 
303
  $current_user_id = get_current_user_id();
@@ -368,7 +368,7 @@ class YasrShortcodesAjax {
368
  }
369
 
370
  //echo response
371
- echo $this->mvReturnResponse ($error_found, $post_id, $set_id);
372
 
373
  die();
374
 
@@ -447,11 +447,13 @@ class YasrShortcodesAjax {
447
 
448
  /**
449
  * @author Dario Curvino <@dudo>
450
- * @since 2.7.2
 
 
451
  * @param $post_id
452
  * @param $set_id
453
  *
454
- * @return string
455
  */
456
  public function mvReturnResponse ($error_found, $post_id, $set_id) {
457
  if (!$error_found) {
@@ -465,10 +467,18 @@ class YasrShortcodesAjax {
465
  yasr_setcookie($cookiename, $data_to_save);
466
 
467
  $rating_saved_text = __('Rating Saved', 'yet-another-stars-rating');
468
- return wp_kses_post(apply_filters('yasr_mv_saved_text', $rating_saved_text));
 
 
 
 
 
469
  }
470
 
471
- return(__('Rating not saved. Please Try again', 'yet-another-stars-rating'));
 
 
 
472
 
473
  }
474
 
@@ -552,12 +562,6 @@ class YasrShortcodesAjax {
552
 
553
  arsort($stats); //sort it by $votes[n_of_votes]
554
 
555
- $html_to_return = '<div class="yasr-visitors-stats-tooltip">';
556
- $html_to_return .= '<span id="yasr-medium-rating-tooltip">' . $medium_rating . ' ' . __(
557
- 'out of 5 stars', 'yet-another-stars-rating'
558
- ) . '</span>';
559
- $html_to_return .= '<div class="yasr-progress-bars-container">';
560
-
561
  if ($total_votes === 0) {
562
  $increase_bar_value = 0;
563
  }
@@ -567,28 +571,20 @@ class YasrShortcodesAjax {
567
 
568
  $i = 5;
569
 
570
- $stars_text = __('stars', 'yet-another-stars-rating');
 
 
571
 
572
  foreach ($stats as $logged_votes) {
573
-
574
  //cast int
575
- $logged_votes['n_of_votes'] = (int) $logged_votes['n_of_votes'];
576
-
577
- if ($i === 1) {
578
- $stars_text = __('star', 'yet-another-stars-rating');
579
- }
580
 
581
  $value_progressbar = $increase_bar_value * $logged_votes['n_of_votes']; //value of the single bar
582
  $value_progressbar = round($value_progressbar, 2) . '%'; //use only 2 decimal
583
 
584
- $html_to_return .= "<div class='yasr-progress-bar-row-container yasr-w3-container'>
585
- <div class='yasr-progress-bar-name'>$i $stars_text</div>
586
- <div class='yasr-single-progress-bar-container'>
587
- <div class='yasr-w3-border '>
588
- <div class='yasr-w3-amber' style='height:17px;width:$value_progressbar'></div>
589
- </div></div>
590
- <div class='yasr-progress-bar-votes-count'>" . $logged_votes['n_of_votes'] . "</div><br />
591
- </div>";
592
 
593
  $i--;
594
 
@@ -596,14 +592,35 @@ class YasrShortcodesAjax {
596
  if ($i < 1) {
597
  break;
598
  }
599
-
600
  } //End foreach
601
 
602
- $html_to_return .= '</div></div>';
603
- echo json_encode($html_to_return);
604
 
605
  die();
 
606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  }
608
 
609
 
@@ -621,9 +638,6 @@ class YasrShortcodesAjax {
621
  $is_ajax = false;
622
 
623
  if (isset($_GET['action']) && isset($_GET['source']) && isset($_GET['nonce_rankings'])) {
624
- if (!wp_verify_nonce($_GET['nonce_rankings'], 'yasr_nonce_rankings')) {
625
- die('Security check');
626
- }
627
  $request = $_GET;
628
  $source = (string)$_GET['source'];
629
  $is_ajax = true;
77
 
78
  do_action('yasr_action_on_visitor_vote', $array_action_visitor_vote);
79
 
80
+ $nonce_response = self::validNonce($nonce_visitor, 'yasr_nonce_vv');
81
+ if($nonce_response !== true) {
82
+ die ($nonce_response);
83
  }
84
 
85
  if ($rating < 1) {
214
  . '</span>';
215
 
216
  return array(
217
+ 'status' => 'success',
218
  'number_of_votes' => $number_of_votes,
219
  'average_rating' => $medium_rating,
220
  'rating_saved_text' => $rating_saved_span
261
 
262
  //this means is an ajax call
263
  if (isset($_GET['action']) && $_GET['action'] === 'yasr_load_vv' && isset($_GET['nonce_visitor'])) {
 
 
 
264
  $array_to_echo['yasr_visitor_votes'] = $array_to_return;
265
  echo json_encode($array_to_echo);
266
  die();
295
  exit();
296
  }
297
 
298
+ $nonce_response = self::validNonce($nonce, 'yasr_nonce_insert_visitor_rating_multiset');
299
+ if($nonce_response !== true) {
300
+ die ($nonce_response);
301
  }
302
 
303
  $current_user_id = get_current_user_id();
368
  }
369
 
370
  //echo response
371
+ echo json_encode($this->mvReturnResponse ($error_found, $post_id, $set_id));
372
 
373
  die();
374
 
447
 
448
  /**
449
  * @author Dario Curvino <@dudo>
450
+ * @since 2.7.2
451
+ *
452
+ * @param $error_found
453
  * @param $post_id
454
  * @param $set_id
455
  *
456
+ * @return array
457
  */
458
  public function mvReturnResponse ($error_found, $post_id, $set_id) {
459
  if (!$error_found) {
467
  yasr_setcookie($cookiename, $data_to_save);
468
 
469
  $rating_saved_text = __('Rating Saved', 'yet-another-stars-rating');
470
+ $rating_saved_text = wp_kses_post(apply_filters('yasr_mv_saved_text', $rating_saved_text));
471
+
472
+ return array(
473
+ 'status' => 'success',
474
+ 'text' => $rating_saved_text
475
+ );
476
  }
477
 
478
+ return array(
479
+ 'status' => 'error',
480
+ 'error' => __('Rating not saved. Please Try again', 'yet-another-stars-rating')
481
+ );
482
 
483
  }
484
 
562
 
563
  arsort($stats); //sort it by $votes[n_of_votes]
564
 
 
 
 
 
 
 
565
  if ($total_votes === 0) {
566
  $increase_bar_value = 0;
567
  }
571
 
572
  $i = 5;
573
 
574
+ $array_to_return = array(
575
+ 'medium_rating' => $medium_rating
576
+ );
577
 
578
  foreach ($stats as $logged_votes) {
 
579
  //cast int
580
+ $logged_votes['n_of_votes'] = (int)$logged_votes['n_of_votes'];
 
 
 
 
581
 
582
  $value_progressbar = $increase_bar_value * $logged_votes['n_of_votes']; //value of the single bar
583
  $value_progressbar = round($value_progressbar, 2) . '%'; //use only 2 decimal
584
 
585
+ $array_to_return[$i]['progressbar'] = $value_progressbar;
586
+ $array_to_return[$i]['n_of_votes'] = $logged_votes['n_of_votes'];
587
+ $array_to_return[$i]['vote'] = $logged_votes['vote'];
 
 
 
 
 
588
 
589
  $i--;
590
 
592
  if ($i < 1) {
593
  break;
594
  }
 
595
  } //End foreach
596
 
597
+ echo json_encode($array_to_return);
 
598
 
599
  die();
600
+ }
601
 
602
+ /**
603
+ * @author Dario Curvino <@dudo>
604
+ * @since 2.8.0
605
+ * @param $nonce
606
+ * @param $action_name
607
+ * @param string $error
608
+ * @return string|bool;
609
+ */
610
+ public static function validNonce($nonce, $action_name, $error=false) {
611
+ if (!wp_verify_nonce($nonce, $action_name)) {
612
+ if(!$error) {
613
+ $error = __('Wrong nonce. Rating can\'t be updated', 'yet-another-stars-rating');
614
+ } else {
615
+ $error = sanitize_text_field($error);
616
+ }
617
+ $error_nonce = array(
618
+ 'status' => 'error',
619
+ 'text' => $error
620
+ );
621
+ return json_encode($error_nonce);
622
+ }
623
+ return true;
624
  }
625
 
626
 
638
  $is_ajax = false;
639
 
640
  if (isset($_GET['action']) && isset($_GET['source']) && isset($_GET['nonce_rankings'])) {
 
 
 
641
  $request = $_GET;
642
  $source = (string)$_GET['source'];
643
  $is_ajax = true;
includes/yasr-includes-init.php CHANGED
@@ -158,10 +158,11 @@ if (isset($yasr_stored_options['publisher_name'])) {
158
  define('YASR_PUBLISHER_NAME', get_bloginfo('name'));
159
  }
160
 
161
- if (isset($yasr_stored_options['publisher_logo'])) {
162
- if (filter_var($yasr_stored_options['publisher_logo'], FILTER_VALIDATE_URL) !== false) {
163
- define('YASR_PUBLISHER_LOGO', $yasr_stored_options['publisher_logo']);
164
- }
 
165
  }
166
 
167
  if (isset($yasr_stored_options['enable_ajax'])) {
158
  define('YASR_PUBLISHER_NAME', get_bloginfo('name'));
159
  }
160
 
161
+ if (isset($yasr_stored_options['publisher_logo'])
162
+ && (filter_var($yasr_stored_options['publisher_logo'], FILTER_VALIDATE_URL) !== false)) {
163
+ define('YASR_PUBLISHER_LOGO', $yasr_stored_options['publisher_logo']);
164
+ } else {
165
+ define('YASR_PUBLISHER_LOGO', get_site_icon_url());
166
  }
167
 
168
  if (isset($yasr_stored_options['enable_ajax'])) {
public/classes/YasrPublicFilters.php CHANGED
@@ -19,8 +19,6 @@ class YasrPublicFilters {
19
  add_filter('the_content', array($this, 'autoInsert'));
20
  }
21
 
22
- add_filter('the_content', array($this, 'addSchema'));
23
-
24
  //stars next to the title
25
  if (YASR_STARS_TITLE === 'yes') {
26
  add_filter('the_title', array($this, 'filterTitle'));
@@ -146,225 +144,6 @@ class YasrPublicFilters {
146
  } //End function yasr_auto_insert_shortcode_callback
147
 
148
 
149
- /**
150
- * @param $content
151
- *
152
- * @return string
153
- */
154
- public static function addSchema($content) {
155
-
156
- //Add buddypress compatibility
157
- //If this is a page, return $content without adding schema.
158
- if (function_exists('bp_is_active') && is_page()) {
159
- return $content;
160
- }
161
-
162
- if (is_404() || did_action('get_footer') || (!is_singular() && is_main_query())) {
163
- return $content;
164
- }
165
-
166
- $post_id = get_the_ID();
167
- $overall_rating = YasrDatabaseRatings::getOverallRating();
168
- $visitor_votes = YasrDatabaseRatings::getVisitorVotes();
169
-
170
- if (!$overall_rating && !$visitor_votes['number_of_votes'] && !$visitor_votes['sum_votes']) {
171
- return $content;
172
- }
173
-
174
- //can't be between 0.1 and 1
175
- if ($overall_rating > 0 && $overall_rating < 1) {
176
- $overall_rating = 1;
177
- }
178
-
179
- $is_post_a_review = get_post_meta($post_id, 'yasr_post_is_review', true);
180
-
181
- $script_type = '<script type="application/ld+json">';
182
- $end_script_type = '</script>';
183
-
184
- $review_choosen = yasr_get_itemType();
185
-
186
- //Use this hook to write your custom microdata from scratch
187
- //if doesn't exists a filter for yasr_filter_schema_jsonld
188
- // $review_chosen value is assigned to $filtered_schema.
189
- $filtered_schema = apply_filters('yasr_filter_schema_jsonld', $review_choosen);
190
-
191
- //So check here if $schema != $review_choosen
192
- if ($filtered_schema !== $review_choosen) {
193
- return $content . $script_type . $filtered_schema . $end_script_type;
194
- }
195
-
196
- //YASR adds microdata only if is_singular() && is_main_query() && !is_404()
197
- if (is_singular() && is_main_query() && !is_404()) {
198
- $rich_snippet['@context'] = 'https://schema.org/';
199
-
200
- $author = get_the_author();
201
-
202
- //use this hook to change the itemType name
203
- $review_name = wp_strip_all_tags(apply_filters('yasr_filter_schema_title', $post_id));
204
-
205
- $date = get_the_date('c');
206
- $date_modified = get_the_modified_date('c');
207
-
208
- $post_image_url = ''; //avoid undefined
209
- $logo_image_url = ''; //avoid undefined
210
-
211
- if (defined('YASR_PUBLISHER_LOGO')) {
212
- $logo_image_url = YASR_PUBLISHER_LOGO;
213
- $post_image_url = $logo_image_url; //this will be overwritten if has_post_thumbnail is true
214
-
215
- $logo_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url(YASR_PUBLISHER_LOGO, PHP_URL_PATH);
216
-
217
- $post_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
218
- $logo_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
219
- }
220
- else {
221
- $post_image_size[0] = 0;
222
- $post_image_size[1] = 0;
223
- $logo_image_size[0] = 0;
224
- $logo_image_size[1] = 0;
225
- }
226
-
227
- //if exists featuread image get the url and overwrite the variable
228
- if (has_post_thumbnail()) {
229
- $post_image_url = wp_get_attachment_url(get_post_thumbnail_id());
230
- $post_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url($post_image_url, PHP_URL_PATH);
231
- $post_image_size = @getimagesize(
232
- $post_image_url_absolute
233
- ); //the @ should be useless, just to be safe
234
- }
235
-
236
- $rich_snippet['@type'] = $review_choosen;
237
- $rich_snippet['name'] = $review_name;
238
- $cleaned_content = wp_strip_all_tags(strip_shortcodes($content));
239
-
240
- $rich_snippet['description'] = wp_trim_words($cleaned_content, 55, '...');
241
-
242
- $rich_snippet['image'] = array(
243
- '@type' => 'ImageObject',
244
- 'url' => $post_image_url,
245
- 'width' => $post_image_size[0],
246
- 'height' => $post_image_size[1]
247
- );
248
-
249
- $publisher_image_index = 'logo';
250
- if (YASR_PUBLISHER_TYPE === 'Person') {
251
- $publisher_image_index = 'image';
252
- }
253
-
254
- elseif ($review_choosen === 'BlogPosting') {
255
- $rich_snippet['datePublished'] = $date;
256
- $rich_snippet['headline'] = $review_name;
257
- $rich_snippet['mainEntityOfPage'] = array(
258
- '@type' => 'WebPage',
259
- '@id' => get_permalink()
260
- );
261
- $rich_snippet['author'] = array(
262
- '@type' => 'Person',
263
- 'name' => $author
264
- );
265
- $rich_snippet['publisher'] = array(
266
- '@type' => 'Organization',
267
- 'name' => wp_strip_all_tags(YASR_PUBLISHER_NAME),
268
- //already sanitized in the settings, just to be safe
269
- 'logo' => array(
270
- '@type' => 'ImageObject',
271
- 'url' => $logo_image_url,
272
- 'width' => $logo_image_size[0],
273
- 'height' => $logo_image_size[1]
274
- ),
275
- );
276
-
277
- $rich_snippet['dateModified'] = $date_modified;
278
-
279
- $rich_snippet['image'] = array(
280
- '@type' => 'ImageObject',
281
- 'url' => $post_image_url,
282
- 'width' => $post_image_size[0],
283
- 'height' => $post_image_size[1]
284
- );
285
-
286
- }
287
-
288
- //Add everywhere except for blogPosting
289
- if ($review_choosen !== 'BlogPosting') {
290
- if ($overall_rating) {
291
- $rich_snippet['Review'] = array(
292
- '@type' => 'Review',
293
- 'name' => $review_name,
294
- 'reviewBody' => $cleaned_content,
295
- 'author' => array(
296
- '@type' => 'Person',
297
- 'name' => $author
298
- ),
299
- 'datePublished' => $date,
300
- 'dateModified' => $date_modified,
301
- 'reviewRating' => array(
302
- '@type' => 'Rating',
303
- 'ratingValue' => $overall_rating,
304
- 'bestRating' => 5,
305
- 'worstRating' => 1
306
- ),
307
- );
308
- }
309
-
310
- //if both are included, google will index AggregateRating instead of Review.
311
- //So, is post is selected as review, exclude AggregateRating
312
- if ($is_post_a_review !== 'yes') {
313
- if ($visitor_votes) {
314
- if ($visitor_votes['sum_votes'] !== 0 && $visitor_votes['number_of_votes'] !== 0) {
315
- $average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
316
- $average_rating = round($average_rating, 1);
317
-
318
- $rich_snippet['aggregateRating'] = array(
319
- '@type' => 'AggregateRating',
320
- 'ratingValue' => $average_rating,
321
- 'ratingCount' => $visitor_votes['number_of_votes'],
322
- 'bestRating' => 5,
323
- 'worstRating' => 1,
324
- );
325
- }
326
- }
327
- }
328
- }
329
-
330
- if (isset($rich_snippet['Review']) || $review_choosen === 'BlogPosting') {
331
- $publisher = array(
332
- '@type' => YASR_PUBLISHER_TYPE,
333
- 'name' => wp_strip_all_tags(YASR_PUBLISHER_NAME),
334
- //already sanitized in the settings, just to be safe
335
- $publisher_image_index => array(
336
- '@type' => 'ImageObject',
337
- 'url' => $logo_image_url,
338
- 'width' => $logo_image_size[0],
339
- 'height' => $logo_image_size[1]
340
- ),
341
- );
342
-
343
- /** @noinspection NotOptimalIfConditionsInspection */
344
- if (isset($rich_snippet['Review'])) {
345
- $rich_snippet['Review']['publisher'] = $publisher;
346
- }
347
- else {
348
- $rich_snippet['publisher'] = $publisher;
349
- }
350
- }
351
-
352
- //Use this hook to add additional schema
353
- //if doesn't exists a filter for yasr_filter_existing_schema, put $rich_snippet into $more_rich_snippet
354
- $more_rich_snippet = apply_filters('yasr_filter_existing_schema', $rich_snippet);
355
-
356
- if ($more_rich_snippet !== $rich_snippet && is_array($more_rich_snippet)) {
357
- $rich_snippet = $more_rich_snippet;
358
- }
359
-
360
- return $content . $script_type . json_encode($rich_snippet) . $end_script_type;
361
- }
362
-
363
- return $content;
364
-
365
- } //End function
366
-
367
-
368
  /**
369
  * @since 2.4.3
370
  * Filter the_title to show stars next it
19
  add_filter('the_content', array($this, 'autoInsert'));
20
  }
21
 
 
 
22
  //stars next to the title
23
  if (YASR_STARS_TITLE === 'yes') {
24
  add_filter('the_title', array($this, 'filterTitle'));
144
  } //End function yasr_auto_insert_shortcode_callback
145
 
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  /**
148
  * @since 2.4.3
149
  * Filter the_title to show stars next it
public/classes/YasrRichSnippetAdditionalFields.php DELETED
@@ -1,240 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * This class hook to yasr_filter_existing_schema, get the post meta
5
- * yasr_schema_additional_fields, and depending of the itemType selected
6
- * returns the schema info
7
- *
8
- * Class YasrRichSnippetAdditionalFields
9
- */
10
- class YasrRichSnippetAdditionalFields {
11
-
12
- public function addFilters() {
13
- add_filter('yasr_filter_schema_title', array($this, 'filter_title'));
14
- add_filter('yasr_filter_existing_schema', array($this, 'additional_schema'));
15
- }
16
-
17
- /**
18
- * Filter the title that will be used in the rich snippets
19
- * Use a user defined title if found, or the post title otherwise
20
- * @author Dario Curvino <@dudo>
21
- *
22
- * @param $post_id
23
- *
24
- * @return mixed|string
25
- */
26
- public function filter_title($post_id) {
27
- $saved_data = $this->saved_data();
28
-
29
- //if is not empty, overwrite the title with custom itemType name
30
- if(!empty($saved_data['yasr_schema_title'])) {
31
- $schema_title = $saved_data['yasr_schema_title'];
32
- } else {
33
- //Here I don't use get_the_title because it run after filters are applied.
34
- //This causes that stars near title will appear in schema title
35
- //https://wordpress.stackexchange.com/questions/257499/get-title-without-filterthe-title
36
- $schema_title = get_post_field('post_title', $post_id, 'raw');
37
- }
38
- return $schema_title;
39
- }
40
-
41
- public function additional_schema($rich_snippet) {
42
- $saved_data = $this->saved_data();
43
-
44
- //avoid undefined
45
- $more_rich_snippet = array();
46
-
47
- //get the select itemType
48
- $review_choosen = yasr_get_itemType();
49
-
50
- if($review_choosen === 'Product') {
51
- $more_rich_snippet = $this->itemProduct($saved_data);
52
- }
53
- if($review_choosen === 'LocalBusiness') {
54
- $more_rich_snippet = $this->localBusiness($saved_data);
55
- }
56
- if($review_choosen === 'Recipe') {
57
- $more_rich_snippet = $this->recipe($saved_data);
58
- }
59
-
60
- if($review_choosen === 'SoftwareApplication') {
61
- $more_rich_snippet = $this->softwareApplication($saved_data);
62
- }
63
-
64
- if($review_choosen === 'Book') {
65
- $more_rich_snippet = $this->book($saved_data);
66
- }
67
-
68
- if($review_choosen === 'Movie') {
69
- $more_rich_snippet = $this->movie($saved_data);
70
- }
71
-
72
- return array_merge($rich_snippet, $more_rich_snippet);
73
-
74
- }
75
-
76
- private function itemProduct($saved_data) {
77
- $global_identifer_name = $saved_data['yasr_product_global_identifier_select'];
78
-
79
- $rich_snippet['brand'] = $saved_data['yasr_product_brand'];
80
- $rich_snippet['sku'] = $saved_data['yasr_product_sku'];
81
- $rich_snippet[$global_identifer_name] = $saved_data['yasr_product_global_identifier_value'];
82
-
83
- if(!empty($saved_data['yasr_product_price'])) {
84
- $rich_snippet['offers'] = array(
85
- '@type' => 'Offer',
86
- 'price' => $saved_data['yasr_product_price'],
87
- 'priceCurrency' => $saved_data['yasr_product_price_currency'],
88
- 'priceValidUntil' => $saved_data['yasr_product_price_valid_until'],
89
- 'availability' => $saved_data['yasr_product_price_availability'],
90
- 'url' => $saved_data['yasr_product_price_url'],
91
- );
92
-
93
- }
94
- return $rich_snippet;
95
- }
96
-
97
- private function localBusiness($saved_data) {
98
- $rich_snippet['address'] = $saved_data['yasr_localbusiness_address'];
99
- $rich_snippet['priceRange'] = $saved_data['yasr_localbusiness_pricerange'];
100
- $rich_snippet['telephone'] = $saved_data['yasr_localbusiness_telephone'];
101
-
102
- return $rich_snippet;
103
- }
104
-
105
- private function recipe($saved_data) {
106
- $instruction_array_clean = array();
107
- $ingredient_array = array();
108
-
109
- if(!empty($saved_data['yasr_recipe_recipeinstructions'])) {
110
- $instruction_array = explode(PHP_EOL, $saved_data['yasr_recipe_recipeinstructions']);
111
- $i=0;
112
- foreach ($instruction_array as $instrunction) {
113
- $instruction_array_clean[$i]['@type'] = "HowToStep";
114
- $instruction_array_clean[$i]['text'] = $instrunction;
115
- $i++;
116
- }
117
- }
118
-
119
- if(!empty($saved_data['yasr_recipe_recipeingredient'])) {
120
- $ingredient_array = explode(PHP_EOL, $saved_data['yasr_recipe_recipeingredient']);
121
- }
122
-
123
- if(!empty($saved_data['yasr_recipe_nutrition'])) {
124
- $rich_snippet['nutrition'] = array(
125
- "@type" => "NutritionInformation",
126
- "calories" => $saved_data['yasr_recipe_nutrition'] . " calories",
127
- );
128
-
129
- }
130
-
131
- $rich_snippet['author'] = array(
132
- '@type' => 'Person',
133
- 'name' => get_the_author()
134
- );
135
-
136
- $rich_snippet['cookTime'] = $saved_data['yasr_recipe_cooktime'];
137
- $rich_snippet['description'] = $saved_data['yasr_recipe_description'];
138
- $rich_snippet['keywords'] = $saved_data['yasr_recipe_keywords'];
139
- $rich_snippet['prepTime'] = $saved_data['yasr_recipe_preptime'];
140
- $rich_snippet['recipeCategory'] = $saved_data['yasr_recipe_recipecategory'];
141
- $rich_snippet['recipeCuisine'] = $saved_data['yasr_recipe_recipecuisine'];
142
- $rich_snippet['recipeIngredient'] = $ingredient_array;
143
- $rich_snippet['recipeInstructions'] = $instruction_array_clean;
144
- $rich_snippet['video'] = $saved_data['yasr_recipe_video'];
145
-
146
- return $rich_snippet;
147
- }
148
-
149
- private function softwareApplication($saved_data) {
150
-
151
- $rich_snippet['applicationCategory'] = $saved_data['yasr_software_application'];
152
- $rich_snippet['operatingSystem'] = $saved_data['yasr_software_os'];
153
-
154
- if(!empty($saved_data['yasr_software_price'])) {
155
- $rich_snippet['offers'] = array(
156
- '@type' => 'Offer',
157
- 'price' => $saved_data['yasr_software_price'],
158
- 'priceCurrency' => $saved_data['yasr_software_price_currency'],
159
- 'priceValidUntil' => $saved_data['yasr_software_price_valid_until'],
160
- 'availability' => $saved_data['yasr_software_price_availability'],
161
- 'url' => $saved_data['yasr_software_price_url'],
162
- );
163
-
164
- }
165
- return $rich_snippet;
166
- }
167
-
168
- private function book($saved_data) {
169
-
170
- if(!empty($saved_data['yasr_book_author'])) {
171
- $rich_snippet['author'] = array(
172
- '@type' => 'Person',
173
- 'name' => $saved_data['yasr_book_author'],
174
- );
175
- }
176
-
177
- $rich_snippet['bookEdition'] = $saved_data['yasr_book_bookedition'];
178
- $rich_snippet['bookFormat'] = $saved_data['yasr_book_bookformat'];
179
- $rich_snippet['isbn'] = $saved_data['yasr_book_isbn'];
180
- $rich_snippet['numberOfPages'] = $saved_data['yasr_book_number_of_pages'];
181
-
182
- return $rich_snippet;
183
- }
184
-
185
- private function movie($saved_data) {
186
-
187
- $actors_array_clean = array();
188
- $director_array_clean = array();
189
-
190
- if(!empty($saved_data['yasr_movie_actor'])) {
191
- $actors_array = explode(PHP_EOL, $saved_data['yasr_movie_actor']);
192
- $i=0;
193
- foreach ($actors_array as $actor) {
194
- $actors_array_clean[$i]['@type'] = "Person";
195
- $actors_array_clean[$i]['name'] = $actor;
196
-
197
- $i++;
198
- }
199
- }
200
-
201
- $rich_snippet['actor'] = $actors_array_clean;
202
-
203
- if(!empty($saved_data['yasr_movie_director'])) {
204
- $director_array = explode(PHP_EOL, $saved_data['yasr_movie_director']);
205
- $i=0;
206
- foreach ($director_array as $director) {
207
- $director_array_clean[$i]['@type'] = "Person";
208
- $director_array_clean[$i]['name'] = $director;
209
-
210
- $i++;
211
- }
212
- }
213
-
214
- $rich_snippet['director'] = $director_array_clean;
215
-
216
- $rich_snippet['duration'] = $saved_data['yasr_movie_duration'];
217
- $rich_snippet['dateCreated'] = $saved_data['yasr_movie_datecreated'];
218
-
219
- return $rich_snippet;
220
- }
221
-
222
- private function saved_data() {
223
- $saved_data = get_post_meta(get_the_ID(), 'yasr_schema_additional_fields', true);
224
- //avoid undefined
225
- if(!is_array($saved_data)) {
226
- $saved_data = array();
227
- }
228
-
229
- $array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true);
230
-
231
- foreach ($array_item_type_info as $item_type) {
232
- //avoid undefined
233
- if(!isset($saved_data[$item_type])) {
234
- $saved_data[$item_type] = '';
235
- }
236
- }
237
-
238
- return $saved_data;
239
- }
240
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
public/classes/YasrRichSnippets.php ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This class hook to yasr_filter_existing_schema, get the post meta
5
+ * yasr_schema_additional_fields, and depending of the itemType selected
6
+ * returns the schema info
7
+ *
8
+ * Class YasrRichSnippetAdditionalFields
9
+ */
10
+ class YasrRichSnippets {
11
+
12
+ public function addFilters() {
13
+ add_filter('the_content', array($this, 'addSchema'));
14
+ add_filter('yasr_filter_schema_title', array($this, 'filter_title'));
15
+ add_filter('yasr_filter_existing_schema', array($this, 'additional_schema'), 10, 2);
16
+ }
17
+
18
+ /**
19
+ * @param $content
20
+ *
21
+ * @return string
22
+ */
23
+ public function addSchema($content) {
24
+ //Add buddypress compatibility
25
+ //If this is a page, return $content without adding schema.
26
+ if (function_exists('bp_is_active') && is_page()) {
27
+ return $content;
28
+ }
29
+
30
+ if (is_404() || did_action('get_footer') || (!is_singular() && is_main_query())) {
31
+ return $content;
32
+ }
33
+
34
+ $post_id = get_the_ID();
35
+ $overall_rating = YasrDatabaseRatings::getOverallRating();
36
+ $visitor_votes = YasrDatabaseRatings::getVisitorVotes();
37
+
38
+ if (!$overall_rating && !$visitor_votes['number_of_votes'] && !$visitor_votes['sum_votes']) {
39
+ return $content;
40
+ }
41
+
42
+ //can't be between 0.1 and 1
43
+ if ($overall_rating > 0 && $overall_rating < 1) {
44
+ $overall_rating = 1;
45
+ }
46
+
47
+ $script_type = '<script type="application/ld+json">';
48
+ $end_script_type = '</script>';
49
+
50
+ $review_choosen = yasr_get_itemType();
51
+
52
+ //Use this hook to write your custom microdata from scratch
53
+ //if doesn't exists a filter for yasr_filter_schema_jsonld
54
+ //$review_chosen value is assigned to $filtered_schema.
55
+ $filtered_schema = apply_filters('yasr_filter_schema_jsonld', $review_choosen);
56
+
57
+ //So check here if $schema != $review_choosen
58
+ if ($filtered_schema !== $review_choosen) {
59
+ return $content . $script_type . $filtered_schema . $end_script_type;
60
+ }
61
+
62
+ //YASR adds microdata only if is_singular() && is_main_query() && !is_404()
63
+ if (is_singular() && is_main_query() && !is_404()) {
64
+ $rich_snippet = $this->returnRichSnippets($post_id, $review_choosen, $content, $overall_rating, $visitor_votes);
65
+
66
+ return $content . $script_type . json_encode($rich_snippet) . $end_script_type;
67
+ }
68
+
69
+ return $content;
70
+
71
+ } //End function
72
+
73
+ /**
74
+ * @author Dario Curvino <@dudo>
75
+ * @since 2.8.0
76
+ * @param $post_id
77
+ * @param $review_choosen
78
+ * @param $content
79
+ * @param $overall_rating
80
+ * @param $visitor_votes
81
+ *
82
+ * @return array|mixed|void
83
+ */
84
+ public function returnRichSnippets($post_id, $review_choosen, $content, $overall_rating, $visitor_votes) {
85
+ $rich_snippet_data = $this->richSnippetsGetData($post_id);
86
+
87
+ $rich_snippet['@context'] = 'https://schema.org/';
88
+ $rich_snippet['@type'] = $review_choosen;
89
+ $rich_snippet['name'] = $rich_snippet_data['review_name'];
90
+
91
+ $cleaned_content = wp_strip_all_tags(strip_shortcodes($content));
92
+ $rich_snippet['description'] = wp_trim_words($cleaned_content, 55, '...');
93
+
94
+ $rich_snippet['image'] = array(
95
+ '@type' => 'ImageObject',
96
+ 'url' => $rich_snippet_data['post_image_url'],
97
+ 'width' => $rich_snippet_data['post_image_size'][0],
98
+ 'height' => $rich_snippet_data['post_image_size'][1]
99
+ );
100
+
101
+ //Add everywhere except for blogPosting
102
+ if ($review_choosen !== 'BlogPosting') {
103
+ $rich_snippet = $this->richSnippetsReview($rich_snippet_data, $cleaned_content, $overall_rating);
104
+
105
+ //if both are included, google will index AggregateRating instead of Review.
106
+ //So, if post is selected as review, exclude AggregateRating
107
+ if($rich_snippet_data['is_post_a_review'] !== 'yes') {
108
+ $rich_snippet = $this->richSnippetsAggregateRating($visitor_votes);
109
+ }
110
+ }
111
+
112
+ //Use this hook to manage itemTypes
113
+ //if doesn't exists a filter for yasr_filter_existing_schema, put $rich_snippet into $more_rich_snippet
114
+ $filtered_rich_snippet = apply_filters('yasr_filter_existing_schema', $rich_snippet, $rich_snippet_data);
115
+
116
+ if ($filtered_rich_snippet !== $rich_snippet && is_array($filtered_rich_snippet)) {
117
+ $rich_snippet = $filtered_rich_snippet;
118
+ }
119
+
120
+ return $rich_snippet;
121
+ }
122
+
123
+ /**
124
+ * Returns all data that is not in the post meta (author name, date, etc)
125
+ *
126
+ * @author Dario Curvino <@dudo>
127
+ * @since 2.8.0
128
+ *
129
+ * @param $post_id
130
+ *
131
+ * @return array|void
132
+ */
133
+ public function richSnippetsGetData ($post_id) {
134
+ $data_to_return = array();
135
+
136
+ $data_to_return['author'] = get_the_author();
137
+ //use this hook to change the itemType name
138
+ $data_to_return['review_name'] = wp_strip_all_tags(apply_filters('yasr_filter_schema_title', $post_id));
139
+
140
+ $data_to_return['date'] = get_the_date('c');
141
+ $data_to_return['date_modified'] = get_the_modified_date('c');
142
+ $data_to_return['is_post_a_review'] = get_post_meta($post_id, 'yasr_post_is_review', true);
143
+
144
+ $logo_image_url = '';
145
+ $post_image_url = $logo_image_url; //this will be overwritten if has_post_thumbnail is true
146
+
147
+ if (YASR_PUBLISHER_LOGO) {
148
+ $logo_image_url = YASR_PUBLISHER_LOGO;
149
+ $post_image_url = $logo_image_url; //this will be overwritten if has_post_thumbnail is true
150
+
151
+ $logo_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url(YASR_PUBLISHER_LOGO, PHP_URL_PATH);
152
+
153
+ $post_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
154
+ $logo_image_size = @getimagesize($logo_image_url_absolute); //the @ should be useless, just to be safe
155
+ }
156
+ else {
157
+ $post_image_size[0] = 0;
158
+ $post_image_size[1] = 0;
159
+ $logo_image_size[0] = 0;
160
+ $logo_image_size[1] = 0;
161
+ }
162
+
163
+ //be sure that getimagesize has returned an array
164
+ if(!is_array($post_image_size)) {
165
+ $post_image_size[0] = 0;
166
+ $post_image_size[1] = 0;
167
+ }
168
+
169
+ if(!is_array($logo_image_size)) {
170
+ $logo_image_size[0] = 0;
171
+ $logo_image_size[1] = 0;
172
+ }
173
+
174
+ //if exists featuread image get the url and overwrite the variable
175
+ if (has_post_thumbnail()) {
176
+ $post_image_url = wp_get_attachment_url(get_post_thumbnail_id());
177
+ $post_image_url_absolute = $_SERVER['DOCUMENT_ROOT'] . parse_url($post_image_url, PHP_URL_PATH);
178
+ $post_image_size = @getimagesize($post_image_url_absolute); //the @ should be useless, just to be safe
179
+ }
180
+
181
+ $publisher_image_index = 'logo';
182
+ if (YASR_PUBLISHER_TYPE === 'Person') {
183
+ $publisher_image_index = 'image';
184
+ }
185
+
186
+ $data_to_return['publisher'] = array(
187
+ '@type' => YASR_PUBLISHER_TYPE,
188
+ 'name' => wp_strip_all_tags(YASR_PUBLISHER_NAME),
189
+ //already sanitized in the settings, just to be safe
190
+ $publisher_image_index => array(
191
+ '@type' => 'ImageObject',
192
+ 'url' => $logo_image_url,
193
+ 'width' => $logo_image_size[0],
194
+ 'height' => $logo_image_size[1]
195
+ ),
196
+ );
197
+
198
+ $data_to_return['post_image_url'] = $post_image_url;
199
+ $data_to_return['post_image_size'] = $post_image_size;
200
+ $data_to_return['logo_image_url'] = $logo_image_url;
201
+ $data_to_return['logo_image_size'] = $logo_image_size;
202
+
203
+ return $data_to_return;
204
+ }
205
+
206
+ /**
207
+ * Returns the 'Review' type
208
+ *
209
+ * @author Dario Curvino <@dudo>
210
+ * @since 2.8.0
211
+ * @param $rich_snippet_data
212
+ * @param $cleaned_content
213
+ * @param $overall_rating
214
+ *
215
+ * @return array|void
216
+ */
217
+ private function richSnippetsReview($rich_snippet_data, $cleaned_content, $overall_rating) {
218
+ if ($overall_rating) {
219
+ $rich_snippet['Review'] = array(
220
+ '@type' => 'Review',
221
+ 'name' => $rich_snippet_data['review_name'],
222
+ 'reviewBody' => $cleaned_content,
223
+ 'author' => array(
224
+ '@type' => 'Person',
225
+ 'name' => $rich_snippet_data['author']
226
+ ),
227
+ 'datePublished' => $rich_snippet_data['date'],
228
+ 'dateModified' => $rich_snippet_data['date_modified'],
229
+ 'reviewRating' => array(
230
+ '@type' => 'Rating',
231
+ 'ratingValue' => $overall_rating,
232
+ 'bestRating' => 5,
233
+ 'worstRating' => 1
234
+ ),
235
+ );
236
+ $rich_snippet['Review']['publisher'] = $rich_snippet_data['publisher'];
237
+
238
+ return $rich_snippet;
239
+ }
240
+
241
+ }
242
+
243
+ /**
244
+ * @author Dario Curvino <@dudo>
245
+ * @since 2.8.0
246
+ *
247
+ * @param $visitor_votes
248
+ *
249
+ * @return array|void
250
+ */
251
+ private function richSnippetsAggregateRating ($visitor_votes) {
252
+ if ($visitor_votes && $visitor_votes['sum_votes'] !== 0 && $visitor_votes['number_of_votes'] !== 0) {
253
+ $average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
254
+ $average_rating = round($average_rating, 1);
255
+
256
+ $rich_snippet['aggregateRating'] = array(
257
+ '@type' => 'AggregateRating',
258
+ 'ratingValue' => $average_rating,
259
+ 'ratingCount' => $visitor_votes['number_of_votes'],
260
+ 'bestRating' => 5,
261
+ 'worstRating' => 1,
262
+ );
263
+
264
+ return $rich_snippet;
265
+ }
266
+ }
267
+
268
+ /**
269
+ * @author Dario Curvino <@dudo>
270
+ * @param $rich_snippet array contains common data for all rich snippets
271
+ * @param $rich_snippet_data array contains all data that is not post_meta (author name, date, etc.)
272
+ *
273
+ * @return array
274
+ */
275
+ public function additional_schema($rich_snippet, $rich_snippet_data) {
276
+ $post_meta = $this->post_meta();
277
+
278
+ //avoid undefined
279
+ $more_rich_snippet = array();
280
+
281
+ //get the select itemType
282
+ $review_choosen = yasr_get_itemType();
283
+
284
+ if($review_choosen === 'BlogPosting') {
285
+ $more_rich_snippet = $this->blogPosting($rich_snippet, $rich_snippet_data);
286
+ }
287
+ if($review_choosen === 'Product') {
288
+ $more_rich_snippet = $this->itemProduct($post_meta);
289
+ }
290
+ if($review_choosen === 'LocalBusiness') {
291
+ $more_rich_snippet = $this->localBusiness($post_meta);
292
+ }
293
+ if($review_choosen === 'Recipe') {
294
+ $more_rich_snippet = $this->recipe($post_meta);
295
+ }
296
+ if($review_choosen === 'SoftwareApplication') {
297
+ $more_rich_snippet = $this->softwareApplication($post_meta);
298
+ }
299
+ if($review_choosen === 'Book') {
300
+ $more_rich_snippet = $this->book($post_meta);
301
+ }
302
+ if($review_choosen === 'Movie') {
303
+ $more_rich_snippet = $this->movie($post_meta);
304
+ }
305
+
306
+ return array_merge($rich_snippet, $more_rich_snippet);
307
+
308
+ }
309
+
310
+ /**
311
+ * @author Dario Curvino <@dudo>
312
+ * @param $rich_snippet
313
+ * @param $rich_snippet_data
314
+ *
315
+ * @return mixed
316
+ */
317
+ private function blogPosting($rich_snippet, $rich_snippet_data) {
318
+ $rich_snippet['datePublished'] = $rich_snippet_data['date'];
319
+ $rich_snippet['headline'] = $rich_snippet_data['review_name'];
320
+ $rich_snippet['mainEntityOfPage'] = array(
321
+ '@type' => 'WebPage',
322
+ '@id' => get_permalink()
323
+ );
324
+ $rich_snippet['author'] = array(
325
+ '@type' => 'Person',
326
+ 'name' => $rich_snippet_data['author']
327
+ );
328
+
329
+ $rich_snippet['dateModified'] = $rich_snippet_data['date_modified'];
330
+
331
+ $rich_snippet['image'] = array(
332
+ '@type' => 'ImageObject',
333
+ 'url' => $rich_snippet_data['post_image_url'],
334
+ 'width' => $rich_snippet_data['post_image_size'][0],
335
+ 'height' => $rich_snippet_data['post_image_size'][1]
336
+ );
337
+
338
+ //blogposting doesn't allow 'Person' has a publisher
339
+ $rich_snippet['publisher'] = $rich_snippet_data['publisher'];
340
+ $rich_snippet['publisher']['@type'] = 'Organization';
341
+
342
+ return $rich_snippet;
343
+ }
344
+
345
+ /**
346
+ * @author Dario Curvino <@dudo>
347
+ * @param $post_meta
348
+ *
349
+ * @return array
350
+ */
351
+ private function itemProduct($post_meta) {
352
+ $global_identifer_name = $post_meta['yasr_product_global_identifier_select'];
353
+
354
+ $rich_snippet['brand'] = $post_meta['yasr_product_brand'];
355
+ $rich_snippet['sku'] = $post_meta['yasr_product_sku'];
356
+ $rich_snippet[$global_identifer_name] = $post_meta['yasr_product_global_identifier_value'];
357
+
358
+ if(!empty($post_meta['yasr_product_price'])) {
359
+ $rich_snippet['offers'] = array(
360
+ '@type' => 'Offer',
361
+ 'price' => $post_meta['yasr_product_price'],
362
+ 'priceCurrency' => $post_meta['yasr_product_price_currency'],
363
+ 'priceValidUntil' => $post_meta['yasr_product_price_valid_until'],
364
+ 'availability' => $post_meta['yasr_product_price_availability'],
365
+ 'url' => $post_meta['yasr_product_price_url'],
366
+ );
367
+
368
+ }
369
+ return $rich_snippet;
370
+ }
371
+
372
+ /**
373
+ * @author Dario Curvino <@dudo>
374
+ * @param $post_meta
375
+ *
376
+ * @return array
377
+ */
378
+ private function localBusiness($post_meta) {
379
+ $rich_snippet['address'] = $post_meta['yasr_localbusiness_address'];
380
+ $rich_snippet['priceRange'] = $post_meta['yasr_localbusiness_pricerange'];
381
+ $rich_snippet['telephone'] = $post_meta['yasr_localbusiness_telephone'];
382
+
383
+ return $rich_snippet;
384
+ }
385
+
386
+ /**
387
+ * @author Dario Curvino <@dudo>
388
+ * @since
389
+ * @param $post_meta
390
+ *
391
+ * @return array
392
+ */
393
+ private function recipe($post_meta) {
394
+ $instruction_array_clean = array();
395
+ $ingredient_array = array();
396
+
397
+ if(!empty($post_meta['yasr_recipe_recipeinstructions'])) {
398
+ $instruction_array = explode(PHP_EOL, $post_meta['yasr_recipe_recipeinstructions']);
399
+ $i=0;
400
+ foreach ($instruction_array as $instrunction) {
401
+ $instruction_array_clean[$i]['@type'] = "HowToStep";
402
+ $instruction_array_clean[$i]['text'] = $instrunction;
403
+ $i++;
404
+ }
405
+ }
406
+
407
+ if(!empty($post_meta['yasr_recipe_recipeingredient'])) {
408
+ $ingredient_array = explode(PHP_EOL, $post_meta['yasr_recipe_recipeingredient']);
409
+ }
410
+
411
+ if(!empty($post_meta['yasr_recipe_nutrition'])) {
412
+ $rich_snippet['nutrition'] = array(
413
+ "@type" => "NutritionInformation",
414
+ "calories" => $post_meta['yasr_recipe_nutrition'] . " calories",
415
+ );
416
+
417
+ }
418
+
419
+ $rich_snippet['author'] = array(
420
+ '@type' => 'Person',
421
+ 'name' => get_the_author()
422
+ );
423
+
424
+ $rich_snippet['cookTime'] = $post_meta['yasr_recipe_cooktime'];
425
+ $rich_snippet['description'] = $post_meta['yasr_recipe_description'];
426
+ $rich_snippet['keywords'] = $post_meta['yasr_recipe_keywords'];
427
+ $rich_snippet['prepTime'] = $post_meta['yasr_recipe_preptime'];
428
+ $rich_snippet['recipeCategory'] = $post_meta['yasr_recipe_recipecategory'];
429
+ $rich_snippet['recipeCuisine'] = $post_meta['yasr_recipe_recipecuisine'];
430
+ $rich_snippet['recipeIngredient'] = $ingredient_array;
431
+ $rich_snippet['recipeInstructions'] = $instruction_array_clean;
432
+ $rich_snippet['video'] = $post_meta['yasr_recipe_video'];
433
+
434
+ return $rich_snippet;
435
+ }
436
+
437
+ /**
438
+ * @author Dario Curvino <@dudo>
439
+ * @param $post_meta
440
+ *
441
+ * @return array
442
+ */
443
+ private function softwareApplication($post_meta) {
444
+ $rich_snippet['applicationCategory'] = $post_meta['yasr_software_application'];
445
+ $rich_snippet['operatingSystem'] = $post_meta['yasr_software_os'];
446
+
447
+ if(!empty($post_meta['yasr_software_price'])) {
448
+ $rich_snippet['offers'] = array(
449
+ '@type' => 'Offer',
450
+ 'price' => $post_meta['yasr_software_price'],
451
+ 'priceCurrency' => $post_meta['yasr_software_price_currency'],
452
+ 'priceValidUntil' => $post_meta['yasr_software_price_valid_until'],
453
+ 'availability' => $post_meta['yasr_software_price_availability'],
454
+ 'url' => $post_meta['yasr_software_price_url'],
455
+ );
456
+
457
+ }
458
+ return $rich_snippet;
459
+ }
460
+
461
+ /**
462
+ * @author Dario Curvino <@dudo>
463
+ * @param $post_meta
464
+ *
465
+ * @return array
466
+ */
467
+ private function book($post_meta) {
468
+
469
+ if(!empty($post_meta['yasr_book_author'])) {
470
+ $rich_snippet['author'] = array(
471
+ '@type' => 'Person',
472
+ 'name' => $post_meta['yasr_book_author'],
473
+ );
474
+ }
475
+
476
+ $rich_snippet['bookEdition'] = $post_meta['yasr_book_bookedition'];
477
+ $rich_snippet['bookFormat'] = $post_meta['yasr_book_bookformat'];
478
+ $rich_snippet['isbn'] = $post_meta['yasr_book_isbn'];
479
+ $rich_snippet['numberOfPages'] = $post_meta['yasr_book_number_of_pages'];
480
+
481
+ return $rich_snippet;
482
+ }
483
+
484
+ /**
485
+ * @author Dario Curvino <@dudo>
486
+ * @param $post_meta
487
+ *
488
+ * @return array
489
+ */
490
+ private function movie($post_meta) {
491
+ $actors_array_clean = array();
492
+ $director_array_clean = array();
493
+
494
+ if(!empty($post_meta['yasr_movie_actor'])) {
495
+ $actors_array = explode(PHP_EOL, $post_meta['yasr_movie_actor']);
496
+ $i=0;
497
+ foreach ($actors_array as $actor) {
498
+ $actors_array_clean[$i]['@type'] = "Person";
499
+ $actors_array_clean[$i]['name'] = $actor;
500
+
501
+ $i++;
502
+ }
503
+ }
504
+
505
+ $rich_snippet['actor'] = $actors_array_clean;
506
+
507
+ if(!empty($post_meta['yasr_movie_director'])) {
508
+ $director_array = explode(PHP_EOL, $post_meta['yasr_movie_director']);
509
+ $i=0;
510
+ foreach ($director_array as $director) {
511
+ $director_array_clean[$i]['@type'] = "Person";
512
+ $director_array_clean[$i]['name'] = $director;
513
+
514
+ $i++;
515
+ }
516
+ }
517
+
518
+ $rich_snippet['director'] = $director_array_clean;
519
+ $rich_snippet['duration'] = $post_meta['yasr_movie_duration'];
520
+ $rich_snippet['dateCreated'] = $post_meta['yasr_movie_datecreated'];
521
+
522
+ return $rich_snippet;
523
+ }
524
+
525
+ /**
526
+ * Get the postmeta for the itemTypes
527
+ *
528
+ * @author Dario Curvino <@dudo>
529
+ * @return array|mixed
530
+ */
531
+ private function post_meta() {
532
+ $post_meta = get_post_meta(get_the_ID(), 'yasr_schema_additional_fields', true);
533
+ //avoid undefined
534
+ if(!is_array($post_meta)) {
535
+ $post_meta = array();
536
+ }
537
+
538
+ $array_item_type_info = json_decode(YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS, true);
539
+
540
+ foreach ($array_item_type_info as $item_type) {
541
+ //avoid undefined
542
+ if(!isset($post_meta[$item_type])) {
543
+ $post_meta[$item_type] = '';
544
+ }
545
+ }
546
+
547
+ return $post_meta;
548
+ }
549
+
550
+
551
+ /**
552
+ * Filter the title that will be used in the rich snippets
553
+ * Use a user defined title if found, or the post title otherwise
554
+ * @author Dario Curvino <@dudo>
555
+ *
556
+ * @param $post_id
557
+ *
558
+ * @return mixed|string
559
+ */
560
+ public function filter_title($post_id) {
561
+ $saved_data = $this->post_meta();
562
+
563
+ //if is not empty, overwrite the title with custom itemType name
564
+ if(!empty($saved_data['yasr_schema_title'])) {
565
+ $schema_title = $saved_data['yasr_schema_title'];
566
+ } else {
567
+ //Here I don't use get_the_title because it run after filters are applied.
568
+ //This causes that stars near title will appear in schema title
569
+ //https://wordpress.stackexchange.com/questions/257499/get-title-without-filterthe-title
570
+ $schema_title = get_post_field('post_title', $post_id, 'raw');
571
+ }
572
+ return $schema_title;
573
+ }
574
+ }
public/yasr-public-init.php CHANGED
@@ -56,5 +56,5 @@ $yasr_public_filters = new YasrPublicFilters();
56
  $yasr_public_filters->addFilters();
57
 
58
  //filter yasr rich snippet
59
- $yasr_additional_rich_fields = new YasrRichSnippetAdditionalFields;
60
  $yasr_additional_rich_fields->addFilters();
56
  $yasr_public_filters->addFilters();
57
 
58
  //filter yasr rich snippet
59
+ $yasr_additional_rich_fields = new YasrRichSnippets;
60
  $yasr_additional_rich_fields->addFilters();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.8
7
  Requires PHP: 5.4
8
- Stable tag: 2.7.9
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
@@ -194,9 +194,18 @@ Yes, YASR is 100% fully compatible with PHP 8
194
 
195
  The full changelog can be found in the plugin's directory. Recent entries:
196
 
 
 
 
 
 
 
 
 
197
  = 2.7.9 =
198
  * FIXED: missing stats in some circumstances for yasr_visitor_votes shortcode
199
 
 
200
  = 2.7.8 =
201
  * FIXED: error when "Load results with AJAX?" is enabled, and the attribute "readonly" is set to yasr_visitor_votes shortcode
202
  * TWEAKED: css minor changes
@@ -267,4 +276,4 @@ The class yasr-total-average-container has be renamed yasr-vv-stats-text-contain
267
 
268
 
269
  = Additional Info =
270
- See credits.txt file
5
  Contributors: Dudo
6
  Tested up to: 5.8
7
  Requires PHP: 5.4
8
+ Stable tag: 2.8.0
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
194
 
195
  The full changelog can be found in the plugin's directory. Recent entries:
196
 
197
+ = 2.8.0 =
198
+ * FIXED: if blogPosting itemType is selected, and a non valid url image is is supplied in the rich snippets settings,
199
+ a php warning is returned
200
+ * TWEAKED: The ajax method yasr_stats_visitors_votes now returns only json data, instead of HTML
201
+ * TWEAKED: Ajax error responses are now json_encoded
202
+ * TWEAKED: stats tooltip in yasr_visitor_votes works now with flexbox
203
+ * TWEAKED: minor changes
204
+
205
  = 2.7.9 =
206
  * FIXED: missing stats in some circumstances for yasr_visitor_votes shortcode
207
 
208
+
209
  = 2.7.8 =
210
  * FIXED: error when "Load results with AJAX?" is enabled, and the attribute "readonly" is set to yasr_visitor_votes shortcode
211
  * TWEAKED: css minor changes
276
 
277
 
278
  = Additional Info =
279
+ See credits.txt file
yet-another-stars-rating.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
- * Version: 2.7.9
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
@@ -76,7 +76,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
- define( 'YASR_VERSION_NUM', '2.7.9' );
80
  //Plugin absolute path
81
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
82
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
+ * Version: 2.8.0
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
+ define( 'YASR_VERSION_NUM', '2.8.0' );
80
  //Plugin absolute path
81
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
82
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );