Yasr – Yet Another Stars Rating - Version 2.7.7

Version Description

  • TWEAKED: When "Load results with AJAX? " is enabled, data is loaded through admin-ajax.php instead of REST API.
  • TWEAKED: most of caching plugins are automatically detected: if one is found, "load results with ajax" is enabled by default.
  • Minor changes
Download this release

Release Info

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

Code changes from version 2.7.6 to 2.7.7

admin/classes/YasrOnInstall.php CHANGED
@@ -129,6 +129,9 @@ class YasrOnInstall {
129
  /****** Install yasr functions ******/
130
  private function defaultSettings() {
131
 
 
 
 
132
  //Write default option settings
133
  $option = get_option('yasr_general_options');
134
 
@@ -163,7 +166,11 @@ class YasrOnInstall {
163
  $option['publisher_logo'] = get_site_icon_url();
164
  $option['allowed_user'] = 'allow_anonymous';
165
  $option['visitors_stats'] = 'yes';
166
- $option['enable_ajax'] = 'no';
 
 
 
 
167
 
168
  add_option("yasr_general_options", $option); //Write here the default value if there is not option
169
 
129
  /****** Install yasr functions ******/
130
  private function defaultSettings() {
131
 
132
+ $caching_plugin = new YasrFindCachingPlugins();
133
+ $caching_plugin_found = $caching_plugin->cachingPluginFound();
134
+
135
  //Write default option settings
136
  $option = get_option('yasr_general_options');
137
 
166
  $option['publisher_logo'] = get_site_icon_url();
167
  $option['allowed_user'] = 'allow_anonymous';
168
  $option['visitors_stats'] = 'yes';
169
+ if($caching_plugin_found !== false) {
170
+ $option['enable_ajax'] = 'yes';
171
+ } else {
172
+ $option['enable_ajax'] = 'no';
173
+ }
174
 
175
  add_option("yasr_general_options", $option); //Write here the default value if there is not option
176
 
admin/{class-wp-list-table.php → classes/Yasr_WP_List_Table.php} RENAMED
@@ -5,7 +5,7 @@
5
  * @since 3.1.0
6
  * @access private
7
  */
8
- class YASR_WP_List_Table {
9
 
10
  /**
11
  * The current list of items.
5
  * @since 3.1.0
6
  * @access private
7
  */
8
+ class Yasr_WP_List_Table {
9
 
10
  /**
11
  * The current list of items.
admin/css/yasr-admin.css CHANGED
@@ -52,7 +52,7 @@
52
  text-align: center;
53
  }
54
 
55
- #yasr-rateit-vote-overall-text {
56
  display: block;
57
  }
58
 
@@ -60,11 +60,6 @@
60
  display: block;
61
  }
62
 
63
- #yasr-comma-between-select {
64
- vertical-align: text-bottom;
65
- line-height: 0.5em;
66
- }
67
-
68
  .rich-snippet-title {
69
  font-weight: bold;
70
  margin-bottom: 5px;
52
  text-align: center;
53
  }
54
 
55
+ #yasr-overall-rating-text {
56
  display: block;
57
  }
58
 
60
  display: block;
61
  }
62
 
 
 
 
 
 
63
  .rich-snippet-title {
64
  font-weight: bold;
65
  margin-bottom: 5px;
admin/editor/yasr-metabox-top-right.php CHANGED
@@ -41,7 +41,7 @@ wp_nonce_field('yasr_nonce_is_post_review_action', 'yasr_nonce_is_post_review');
41
  <input type='hidden' name='yasr_overall_rating' id='yasr-overall-rating-value' value='<?php echo $overall_rating?>'>
42
  <div id="yasr-vote-overall-stars-container">
43
  <div id="yasr-vote-overall-stars">
44
- <span id="yasr-rateit-vote-overall-text">
45
  <?php _e('Rate this article / item', 'yet-another-stars-rating'); ?>
46
  </span>
47
 
41
  <input type='hidden' name='yasr_overall_rating' id='yasr-overall-rating-value' value='<?php echo $overall_rating?>'>
42
  <div id="yasr-vote-overall-stars-container">
43
  <div id="yasr-vote-overall-stars">
44
+ <span id="yasr-overall-rating-text">
45
  <?php _e('Rate this article / item', 'yet-another-stars-rating'); ?>
46
  </span>
47
 
admin/js/src/yasr-pricing-page.js CHANGED
@@ -69,9 +69,15 @@ function YasrPricingPrintFeatures(props) {
69
  }
70
 
71
  function YasrPricingPrice(props) {
72
- let price = '';
73
- let licenses = 1;
 
74
  if(props.license === 'single') {
 
 
 
 
 
75
  if(props.cycle === 'monthly') {
76
  if(props.currency === 'eur') {
77
  //eur
@@ -103,6 +109,12 @@ function YasrPricingPrice(props) {
103
  }
104
  else if(props.license === 'plus') {
105
  licenses = 5;
 
 
 
 
 
 
106
  if(props.cycle === 'monthly') {
107
  if(props.currency === 'eur') {
108
  //eur
@@ -134,6 +146,11 @@ function YasrPricingPrice(props) {
134
  }
135
  else if(props.license === 'enterprise') {
136
  licenses = 30;
 
 
 
 
 
137
  if(props.cycle === 'monthly') {
138
  if(props.currency === 'eur') {
139
  //eur
@@ -173,7 +190,7 @@ function YasrPricingPrice(props) {
173
  <a href="#"
174
  className="yasr-buy-button"
175
  onClick={(event) => {
176
- YasrPricingRedirect(props.cycle, licenses, props.currency)
177
  event.preventDefault();
178
  }}
179
  >Buy YASR </a>
@@ -237,12 +254,15 @@ function YasrPricingPriceDesc(props) {
237
  * @param cycle
238
  * @param licenses
239
  * @param currency
 
240
  *
241
  * @return void;
242
  */
243
- function YasrPricingRedirect (cycle, licenses, currency) {
244
  const params = {
 
245
  billing_cycle: cycle,
 
246
  licenses: licenses,
247
  id: 'yasr_checkout',
248
  page: 'yasr_settings_page-pricing',
69
  }
70
 
71
  function YasrPricingPrice(props) {
72
+ let price = '';
73
+ let licenses = 1;
74
+ let pricingId = '';
75
  if(props.license === 'single') {
76
+ if(props.currency === 'eur') {
77
+ pricingId = 5399;
78
+ } else {
79
+ pricingId = 1933;
80
+ }
81
  if(props.cycle === 'monthly') {
82
  if(props.currency === 'eur') {
83
  //eur
109
  }
110
  else if(props.license === 'plus') {
111
  licenses = 5;
112
+ if(props.currency === 'eur') {
113
+ pricingId = 5400;
114
+ } else {
115
+ pricingId = 1935;
116
+ }
117
+
118
  if(props.cycle === 'monthly') {
119
  if(props.currency === 'eur') {
120
  //eur
146
  }
147
  else if(props.license === 'enterprise') {
148
  licenses = 30;
149
+ if(props.currency === 'eur') {
150
+ pricingId = 5550;
151
+ } else {
152
+ pricingId = 5549;
153
+ }
154
  if(props.cycle === 'monthly') {
155
  if(props.currency === 'eur') {
156
  //eur
190
  <a href="#"
191
  className="yasr-buy-button"
192
  onClick={(event) => {
193
+ YasrPricingRedirect(props.cycle, licenses, props.currency, pricingId)
194
  event.preventDefault();
195
  }}
196
  >Buy YASR </a>
254
  * @param cycle
255
  * @param licenses
256
  * @param currency
257
+ * @param pricingId
258
  *
259
  * @return void;
260
  */
261
+ function YasrPricingRedirect (cycle, licenses, currency, pricingId) {
262
  const params = {
263
+ plugin_id: 256,
264
  billing_cycle: cycle,
265
+ pricing_id: pricingId,
266
  licenses: licenses,
267
  id: 'yasr_checkout',
268
  page: 'yasr_settings_page-pricing',
admin/js/yasr-pricing-page.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function c(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,c),r.l=!0,r.exports}c.m=e,c.c=t,c.d=function(e,t,n){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(c.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)c.d(n,r,function(t){return e[t]}.bind(null,r));return n},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="",c(c.s=0)}([function(e,t,c){e.exports=c(1)},function(e,t){function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var c=0;c<t.length;c++){var n=t[c];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e){var t=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(e){return!1}}();return function(){var c,n=s(e);if(t){var r=s(this).constructor;c=Reflect.construct(n,arguments,r)}else c=n.apply(this,arguments);return l(this,c)}}function l(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?i(e):t}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e){var t="$";return"eur"===e.name&&(t="€"),React.createElement("small",null,t," ")}function o(e){var t="/year";return"monthly"===e.name&&(t="/month"),"lifetime"===e.name&&(t=""),React.createElement("small",null,t)}function y(e){var t=" 1 website";return"plus"===e.license&&(t=" 5 websites"),"enterprise"===e.license&&(t=" 30 websites"),React.createElement("ul",{className:"PT-Features"},React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"1 year")," of supports and updates ",React.createElement("br",null),"for",React.createElement("strong",null,t)),React.createElement("li",{className:"yasr-pricing-table-feature"},"User reviews"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Custom rankings"),React.createElement("li",{className:"yasr-pricing-table-feature"},"20 + ready to use themes"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Upload your own theme"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Add fake ratings"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Direct email support"),"lifetime"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},"We setup the plugin for free ",React.createElement("br",null),"(only lifetime plans)"))}function m(e){var t="",c=1;return"single"===e.license?t="monthly"===e.cycle?"eur"===e.currency?"4.49":"4.99":"lifetime"===e.cycle?"eur"===e.currency?"129.99":"149.99":"eur"===e.currency?"41.99":"47.88":"plus"===e.license?(c=5,t="monthly"===e.cycle?"eur"===e.currency?"8.99":"9.99":"lifetime"===e.cycle?"eur"===e.currency?"249.99":"289.99":"eur"===e.currency?"83.88":"95.88"):"enterprise"===e.license&&(c=30,t="monthly"===e.cycle?"eur"===e.currency?"12.99":"14.99":"lifetime"===e.cycle?"eur"===e.currency?"359.99":"439.99":"eur"===e.currency?"119.88":"143.88"),React.createElement("div",{className:"yasr-pring-table-price"},React.createElement(u,{name:e.currency}),React.createElement("span",null,t),React.createElement(o,{name:e.cycle}),React.createElement(p,{cycle:e.cycle,currency:e.currency,license:e.license}),React.createElement("p",{className:"PT-CTA"},React.createElement("a",{href:"#",className:"yasr-buy-button",onClick:function(t){!function(e,t,c){var n={billing_cycle:e,licenses:t,id:"yasr_checkout",page:"yasr_settings_page-pricing",checkout:"true",plan_id:"2778",plan_name:"yasrpro",disable_licenses_selector:!0,hide_billing_cycles:!0,currency:c},r=[];for(var a in n){var l=encodeURIComponent(a),i=encodeURIComponent(n[a]);r.push(l+"="+i)}r=r.join("&");var s=yasrCommonData.adminUrl+"admin.php?"+r;window.open(s,"_self")}(e.cycle,c,e.currency),t.preventDefault()}},"Buy YASR ")))}function p(e){if("annual"===e.cycle){var t="";return t="plus"===e.license?"eur"===e.currency?"6.99":"7.99":"enterprise"===e.license?"eur"===e.currency?"9.99":"11.99":"eur"===e.currency?"3.49":"3.99",React.createElement("p",{className:"yasr-pricing-table-price-desc"},React.createElement(u,{name:e.currency}),t," /month")}return React.createElement(React.Fragment,null)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}(u,React.Component);var t,c,l,s=a(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=s.call(this,e)).state={currencyName:"usd",cycle:"annual"},t.updateCurrency=t.updateCurrency.bind(i(t)),t.updateCycle=t.updateCycle.bind(i(t)),t}return t=u,(c=[{key:"updateCurrency",value:function(e){var t=e.target;!0===("checkbox"===t.type?t.checked:t.value)?this.setState({currencyName:"eur"}):this.setState({currencyName:"usd"})}},{key:"updateCycle",value:function(e){this.setState({cycle:e.target.value})}},{key:"render",value:function(){return React.createElement(React.Fragment,null,React.createElement("div",{id:"yasr-radio-billing-cycle"},React.createElement("input",{type:"radio",id:"yasr-billing-cycle-monthly",name:"billing-cycle",value:"monthly",onChange:this.updateCycle,checked:"monthly"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-monthly"},"Monthly"),React.createElement("input",{type:"radio",id:"yasr-billing-cycle-annual",name:"billing-cycle",value:"annual",onChange:this.updateCycle,checked:"annual"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-annual"},"Annual"),React.createElement("input",{type:"radio",id:"yasr-billing-cycle-lifetime",name:"billing-cycle",value:"lifetime",onChange:this.updateCycle,checked:"lifetime"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-lifetime"},"Lifetime")),React.createElement("div",{id:"yasr-pricing-table"},React.createElement("div",{className:"yasr-pricing-table-item"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Plus"),React.createElement("p",{className:"yasr-pricing-table-subtitle"},"5 websites")),React.createElement(y,{cycle:this.state.cycle,license:"plus"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(m,{cycle:this.state.cycle,currency:this.state.currencyName,license:"plus"}))),React.createElement("div",{className:"yasr-pricing-table-item is-highlighted"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Single"),React.createElement("p",{className:"yasr-pricing-table-subtitle"}," 1 website")),React.createElement(y,{cycle:this.state.cycle,license:"single"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(m,{cycle:this.state.cycle,currency:this.state.currencyName,license:"single"}))),React.createElement("div",{className:"yasr-pricing-table-item"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Enterprise"),React.createElement("p",{className:"yasr-pricing-table-subtitle"}," 30 websites")),React.createElement(y,{cycle:this.state.cycle,license:"enterprise"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(m,{cycle:this.state.cycle,currency:this.state.currencyName,license:"enterprise"})))),React.createElement("div",{id:"switch-container"},React.createElement("span",{className:"yasr-pricing-text-switcher"}," Display Prices In US $ "),React.createElement("label",{className:"yasr-pricing-switch"},React.createElement("input",{type:"checkbox",onChange:this.updateCurrency}),React.createElement("span",{className:"yasr-pricing-slider"})),React.createElement("span",{className:"yasr-pricing-text-switcher"}," €")))}}])&&n(t.prototype,c),l&&n(t,l),u}();ReactDOM.render(React.createElement(f,null),document.getElementById("yasr-table-container"));var d=document.getElementById("yasr-link-policy"),b=document.getElementById("yasr-link-policy-faq"),g=document.getElementById("yasr-refund-policy"),h=document.getElementById("yasr-close-modal-policy");d.addEventListener("click",(function(){g.style.display="block",document.body.style.backgroundColor="rgba(0,0,0,0.7)"})),b.addEventListener("click",(function(){g.style.display="block",document.body.style.backgroundColor="rgba(0,0,0,0.7)"})),h.onclick=function(){g.style.display="none",document.body.style.backgroundColor="#f1f1f1"}}]);
1
+ !function(e){var t={};function c(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,c),r.l=!0,r.exports}c.m=e,c.c=t,c.d=function(e,t,n){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(c.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)c.d(n,r,function(t){return e[t]}.bind(null,r));return n},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="",c(c.s=0)}([function(e,t,c){e.exports=c(1)},function(e,t){function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var c=0;c<t.length;c++){var n=t[c];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e){var t=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(e){return!1}}();return function(){var c,n=s(e);if(t){var r=s(this).constructor;c=Reflect.construct(n,arguments,r)}else c=n.apply(this,arguments);return l(this,c)}}function l(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?i(e):t}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e){var t="$";return"eur"===e.name&&(t="€"),React.createElement("small",null,t," ")}function o(e){var t="/year";return"monthly"===e.name&&(t="/month"),"lifetime"===e.name&&(t=""),React.createElement("small",null,t)}function y(e){var t=" 1 website";return"plus"===e.license&&(t=" 5 websites"),"enterprise"===e.license&&(t=" 30 websites"),React.createElement("ul",{className:"PT-Features"},React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"1 year")," of supports and updates ",React.createElement("br",null),"for",React.createElement("strong",null,t)),React.createElement("li",{className:"yasr-pricing-table-feature"},"User reviews"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Custom rankings"),React.createElement("li",{className:"yasr-pricing-table-feature"},"20 + ready to use themes"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Upload your own theme"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Add fake ratings"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Direct email support"),"lifetime"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},"We setup the plugin for free ",React.createElement("br",null),"(only lifetime plans)"))}function m(e){var t="",c=1,n="";return"single"===e.license?(n="eur"===e.currency?5399:1933,t="monthly"===e.cycle?"eur"===e.currency?"4.49":"4.99":"lifetime"===e.cycle?"eur"===e.currency?"129.99":"149.99":"eur"===e.currency?"41.99":"47.88"):"plus"===e.license?(c=5,n="eur"===e.currency?5400:1935,t="monthly"===e.cycle?"eur"===e.currency?"8.99":"9.99":"lifetime"===e.cycle?"eur"===e.currency?"249.99":"289.99":"eur"===e.currency?"83.88":"95.88"):"enterprise"===e.license&&(c=30,n="eur"===e.currency?5550:5549,t="monthly"===e.cycle?"eur"===e.currency?"12.99":"14.99":"lifetime"===e.cycle?"eur"===e.currency?"359.99":"439.99":"eur"===e.currency?"119.88":"143.88"),React.createElement("div",{className:"yasr-pring-table-price"},React.createElement(u,{name:e.currency}),React.createElement("span",null,t),React.createElement(o,{name:e.cycle}),React.createElement(p,{cycle:e.cycle,currency:e.currency,license:e.license}),React.createElement("p",{className:"PT-CTA"},React.createElement("a",{href:"#",className:"yasr-buy-button",onClick:function(t){!function(e,t,c,n){var r={plugin_id:256,billing_cycle:e,pricing_id:n,licenses:t,id:"yasr_checkout",page:"yasr_settings_page-pricing",checkout:"true",plan_id:"2778",plan_name:"yasrpro",disable_licenses_selector:!0,hide_billing_cycles:!0,currency:c},a=[];for(var l in r){var i=encodeURIComponent(l),s=encodeURIComponent(r[l]);a.push(i+"="+s)}a=a.join("&");var u=yasrCommonData.adminUrl+"admin.php?"+a;window.open(u,"_self")}(e.cycle,c,e.currency,n),t.preventDefault()}},"Buy YASR ")))}function p(e){if("annual"===e.cycle){var t="";return t="plus"===e.license?"eur"===e.currency?"6.99":"7.99":"enterprise"===e.license?"eur"===e.currency?"9.99":"11.99":"eur"===e.currency?"3.49":"3.99",React.createElement("p",{className:"yasr-pricing-table-price-desc"},React.createElement(u,{name:e.currency}),t," /month")}return React.createElement(React.Fragment,null)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}(u,React.Component);var t,c,l,s=a(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=s.call(this,e)).state={currencyName:"usd",cycle:"annual"},t.updateCurrency=t.updateCurrency.bind(i(t)),t.updateCycle=t.updateCycle.bind(i(t)),t}return t=u,(c=[{key:"updateCurrency",value:function(e){var t=e.target;!0===("checkbox"===t.type?t.checked:t.value)?this.setState({currencyName:"eur"}):this.setState({currencyName:"usd"})}},{key:"updateCycle",value:function(e){this.setState({cycle:e.target.value})}},{key:"render",value:function(){return React.createElement(React.Fragment,null,React.createElement("div",{id:"yasr-radio-billing-cycle"},React.createElement("input",{type:"radio",id:"yasr-billing-cycle-monthly",name:"billing-cycle",value:"monthly",onChange:this.updateCycle,checked:"monthly"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-monthly"},"Monthly"),React.createElement("input",{type:"radio",id:"yasr-billing-cycle-annual",name:"billing-cycle",value:"annual",onChange:this.updateCycle,checked:"annual"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-annual"},"Annual"),React.createElement("input",{type:"radio",id:"yasr-billing-cycle-lifetime",name:"billing-cycle",value:"lifetime",onChange:this.updateCycle,checked:"lifetime"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-lifetime"},"Lifetime")),React.createElement("div",{id:"yasr-pricing-table"},React.createElement("div",{className:"yasr-pricing-table-item"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Plus"),React.createElement("p",{className:"yasr-pricing-table-subtitle"},"5 websites")),React.createElement(y,{cycle:this.state.cycle,license:"plus"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(m,{cycle:this.state.cycle,currency:this.state.currencyName,license:"plus"}))),React.createElement("div",{className:"yasr-pricing-table-item is-highlighted"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Single"),React.createElement("p",{className:"yasr-pricing-table-subtitle"}," 1 website")),React.createElement(y,{cycle:this.state.cycle,license:"single"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(m,{cycle:this.state.cycle,currency:this.state.currencyName,license:"single"}))),React.createElement("div",{className:"yasr-pricing-table-item"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Enterprise"),React.createElement("p",{className:"yasr-pricing-table-subtitle"}," 30 websites")),React.createElement(y,{cycle:this.state.cycle,license:"enterprise"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(m,{cycle:this.state.cycle,currency:this.state.currencyName,license:"enterprise"})))),React.createElement("div",{id:"switch-container"},React.createElement("span",{className:"yasr-pricing-text-switcher"}," Display Prices In US $ "),React.createElement("label",{className:"yasr-pricing-switch"},React.createElement("input",{type:"checkbox",onChange:this.updateCurrency}),React.createElement("span",{className:"yasr-pricing-slider"})),React.createElement("span",{className:"yasr-pricing-text-switcher"}," €")))}}])&&n(t.prototype,c),l&&n(t,l),u}();ReactDOM.render(React.createElement(f,null),document.getElementById("yasr-table-container"));var d=document.getElementById("yasr-link-policy"),b=document.getElementById("yasr-link-policy-faq"),g=document.getElementById("yasr-refund-policy"),h=document.getElementById("yasr-close-modal-policy");d.addEventListener("click",(function(){g.style.display="block",document.body.style.backgroundColor="rgba(0,0,0,0.7)"})),b.addEventListener("click",(function(){g.style.display="block",document.body.style.backgroundColor="rgba(0,0,0,0.7)"})),h.onclick=function(){g.style.display="none",document.body.style.backgroundColor="#f1f1f1"}}]);
admin/js/yasr-settings.js CHANGED
@@ -1 +1 @@
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)},u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(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(r))throw TypeError("Stringified UUID is invalid");return r};for(var m=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)},y=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;f(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=_(n),s=_(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),d=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,v=document.getElementById(m),f=document.getElementById(g),b=document.getElementById(p),E="yasr-vv-loader-"+l;if("yes"===yasrCommonData.ajaxEnabled){var k=r.getAttribute("data-cpt");""===k&&(k="posts");var I="wp/v2/"+k+"/"+o+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+I).done((function(t){var e;e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),h(u,a,o,e,i,l,d,c,v,f,E,b),!0!==n&&(null!==v&&(v.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&null!==b&&(b.innerHTML=t.yasr_visitor_votes.stars_attributes.span_bottom,b.style.display=""))})).fail((function(t,e,r,m){console.info(y("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(u,a,o,s,i,l,d,c,v,f,E,b),!0!==n&&(b.style.display="")}))}else h(u,a,o,s,i,l,d,c,v,f,E,b)}}(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,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){s!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(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=_(o);f(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_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function f(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 h(t,e,r,a,n,s,o,i,l,u,d,c){e=parseFloat(e),a=_(a);f(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(d).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){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==c&&(c.innerHTML=t.rating_saved_text),document.getElementById(d).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 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 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 r,a=B(t);if(e){var n=B(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return w(this,r)}}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-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return f(r,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===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 T(t){var e="after",r=j("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(C,{post:t.post,tableId:t.tableId,text:r}),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:r}))}function Q(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(L,{colClass:e,post:t.post}),React.createElement(T,{colClass:r,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,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(Q,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}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,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},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(j("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(j("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(j(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(j(e)),t.setState({isLoaded:!0,data:r})}))}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:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",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("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.restEndpoint+a+"?source="+r+n];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.restEndpoint+a+"?show=most&source="+r+n+o,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}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},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:a,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,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(S,{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",u=new URLSearchParams(a);return null!==u.get("view")&&(o=u.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(S,{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,j("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,r),a&&E(e,a),s}();function M(){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=document.getElementById(r);R(React.createElement(H,{source:a,tableId:r,params:n}),s)}}var P,O=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(P=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===P){var A,N=function(t){var e=G.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(O("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){a.forEach((function(t){e===t&&M()}))}))},D=function(t,e,r,a,n,s,o,i){W.className="",W.classList.add("yasr-settings-row-24"),t.style.display="",e.style.display="",s.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")},F=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.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){n.style.display="",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];s.style.display="",e.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display=""),!0===l?(r.style.display="",a.style.display="",t.style.display="none"):(r.style.display="none",a.style.display="none",t.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var q=[],J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""};A=J.name,document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]");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-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),rt=document.getElementById("builder-username-options"),at=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=G.value,it=!1;"yasr_ov_ranking"===ot?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===ot||"yasr_top_reviewers"===ot?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!1):"yasr_visitor_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!0):F(et,tt,X,Z,rt,at,nt,st),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),Y.innerHTML="",J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!1),J.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!0),J.setid=" setid="+$[0].value):F(et,tt,X,Z,rt,at,nt,st),J.name=t.target.value,A=J.name+J.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(J.setid=" setid="+t.target.value),q=wp.hooks.applyFilters("yasrBuilderFilterShortcode",J);for(var e=2;J.length;e++)q.hasOwnProperty(J[e])&&(J[e]=q[e]);A=J.name+J.setid+J.rows+J.view+J.minvotesmost+J.minvoteshg+J.size+J.txtPosition+J.txt+J.display+J.category+J.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]"),!0===it&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&N()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){N(),it=!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)},u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(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(r))throw TypeError("Stringified UUID is invalid");return r};for(var m=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)},y=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;f(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=_(n),s=_(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),d=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,v=document.getElementById(m),f=document.getElementById(g),b=document.getElementById(p),E="yasr-vv-loader-"+l;if("yes"===yasrCommonData.ajaxEnabled){var k={action:"yasr_load_vv",post_id:o,nonce_visitor:d};document.getElementById(i).innerHTML=yasrCommonData.loaderHtml,jQuery.get(yasrCommonData.ajaxurl,k).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),h(u,a,o,e,i,l,d,c,v,f,E,b),!0!==n&&(null!==v&&(v.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==b&&(b.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,b.style.display=""))})).fail((function(t,e,r,m){console.info(y("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(u,a,o,s,i,l,d,c,v,f,E,b),!0!==n&&(b.style.display="")}))}else h(u,a,o,s,i,l,d,c,v,f,E,b)}}(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,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){s!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(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=_(o);f(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){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function f(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 h(t,e,r,a,n,s,o,i,l,u,d,c){e=parseFloat(e),a=_(a);var m=document.getElementById(n);document.getElementById(n).innerHTML="";f(t,n,m,1,a,e,(function(t,e){document.getElementById(d).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){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==c&&(c.innerHTML=t.rating_saved_text,c.style.display=""),document.getElementById(d).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 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 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 r,a=B(t);if(e){var n=B(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return w(this,r)}}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-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return f(r,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===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 T(t){var e="after",r=j("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(C,{post:t.post,tableId:t.tableId,text:r}),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:r}))}function Q(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(L,{colClass:e,post:t.post}),React.createElement(T,{colClass:r,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,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(Q,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}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,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},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(j("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(j("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(j(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(j(e)),t.setState({isLoaded:!0,data:r})}))}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:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",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("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.restEndpoint+a+"?source="+r+n];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.restEndpoint+a+"?show=most&source="+r+n+o,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}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},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:a,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,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(S,{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",u=new URLSearchParams(a);return null!==u.get("view")&&(o=u.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(S,{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,j("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,r),a&&E(e,a),s}();function M(){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=document.getElementById(r);R(React.createElement(H,{source:a,tableId:r,params:n}),s)}}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,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(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){a.forEach((function(t){e===t&&M()}))}))},D=function(t,e,r,a,n,s,o,i){W.className="",W.classList.add("yasr-settings-row-24"),t.style.display="",e.style.display="",s.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")},F=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.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){n.style.display="",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];s.style.display="",e.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display=""),!0===l?(r.style.display="",a.style.display="",t.style.display="none"):(r.style.display="none",a.style.display="none",t.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var J=[],q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",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-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),rt=document.getElementById("builder-username-options"),at=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=G.value,it=!1;"yasr_ov_ranking"===ot?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===ot||"yasr_top_reviewers"===ot?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!1):"yasr_visitor_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!0):F(et,tt,X,Z,rt,at,nt,st),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),Y.innerHTML="",q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!1),q.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!0),q.setid=" setid="+$[0].value):F(et,tt,X,Z,rt,at,nt,st),q.name=t.target.value,N=q.name+q.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(q.setid=" setid="+t.target.value),J=wp.hooks.applyFilters("yasrBuilderFilterShortcode",q);for(var e=2;q.length;e++)J.hasOwnProperty(q[e])&&(q[e]=J[e]);N=q.name+q.setid+q.rows+q.view+q.minvotesmost+q.minvoteshg+q.size+q.txtPosition+q.txt+q.display+q.category+q.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]"),!0===it&&"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(),it=!0}}}]);
admin/settings/classes/YasrSettings.php CHANGED
@@ -712,7 +712,9 @@ class YasrSettings {
712
  <div class="yasr-settings-row-45">
713
  <div>
714
  <strong>
715
- <?php _e('Load results with AJAX?', 'yet-another-stars-rating'); ?>
 
 
716
  </strong>
717
  <div class="yasr-onoffswitch-big">
718
  <input type="checkbox" name="yasr_general_options[enable_ajax]" class="yasr-onoffswitch-checkbox"
@@ -730,6 +732,17 @@ class YasrSettings {
730
  Not required for yasr_overall_rating and yasr_multiset.',
731
  'yet-another-stars-rating'
732
  );
 
 
 
 
 
 
 
 
 
 
 
733
  ?>
734
  </div>
735
  <div>
712
  <div class="yasr-settings-row-45">
713
  <div>
714
  <strong>
715
+ <?php
716
+ _e('Load results with AJAX?', 'yet-another-stars-rating');
717
+ ?>
718
  </strong>
719
  <div class="yasr-onoffswitch-big">
720
  <input type="checkbox" name="yasr_general_options[enable_ajax]" class="yasr-onoffswitch-checkbox"
732
  Not required for yasr_overall_rating and yasr_multiset.',
733
  'yet-another-stars-rating'
734
  );
735
+ $caching_plugin = new YasrFindCachingPlugins();
736
+ $caching_plugin_found = $caching_plugin->cachingPluginFound();
737
+ if($caching_plugin_found !== false) {
738
+ echo '<div class="yasr-element-row-container-description">'.
739
+ sprintf(
740
+ __('Since you\'re using the caching plugin %s you should enable this.',
741
+ 'yet-another-stars-rating'),
742
+ '<strong>'.$caching_plugin_found.'</strong>'
743
+ ).
744
+ '</div>';
745
+ }
746
  ?>
747
  </div>
748
  <div>
admin/settings/classes/YasrStats.php CHANGED
@@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
25
  /**
26
  * Create a new table class that will extend the WP_List_Table
27
  */
28
- class YasrStats extends YASR_WP_List_Table {
29
 
30
  private $active_tab;
31
 
25
  /**
26
  * Create a new table class that will extend the WP_List_Table
27
  */
28
+ class YasrStats extends Yasr_WP_List_Table {
29
 
30
  private $active_tab;
31
 
admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -1,72 +1,85 @@
1
  <?php
2
 
3
  /**Drow settings tab*/
4
- function yasr_settings_tabs($active_tab) {
5
-
6
  ?>
7
 
8
  <h2 class="nav-tab-wrapper yasr-no-underline">
9
 
10
  <a href="?page=yasr_settings_page&tab=general_settings"
11
  id="general_settings"
12
- class="nav-tab <?php if ($active_tab === 'general_settings') {
13
- echo 'nav-tab-active';
14
- } ?>">
15
- <?php _e('General Settings', 'yet-another-stars-rating'); ?>
 
 
 
 
16
  </a>
17
 
18
  <a href="?page=yasr_settings_page&tab=style_options"
19
  id="style_options"
20
- class="nav-tab <?php if ($active_tab === 'style_options') {
21
- echo 'nav-tab-active';
22
- } ?>">
23
- <?php
24
- _e('Aspect & Styles', 'yet-another-stars-rating');
25
- echo YASR_LOCKED_FEATURE;
26
- ?>
 
27
  </a>
28
 
29
  <a href="?page=yasr_settings_page&tab=manage_multi"
30
  id="manage_multi"
31
- class="nav-tab <?php if ($active_tab === 'manage_multi') {
32
- echo 'nav-tab-active';
33
- } ?>">
34
- <?php _e('Multi Sets', 'yet-another-stars-rating'); ?>
 
 
 
 
35
  </a>
36
 
37
  <a href="?page=yasr_settings_page&tab=rankings"
38
  id="rankings"
39
- class="nav-tab <?php if ($active_tab === 'rankings') {
40
- echo 'nav-tab-active';
41
- } ?>">
42
- <?php
43
- _e("Rankings", 'yet-another-stars-rating');
44
- echo YASR_LOCKED_FEATURE;
45
- ?>
 
46
  </a>
47
 
48
- <?php do_action('yasr_add_settings_tab', $active_tab);
49
-
50
- $rating_plugin_exists = new YasrImportRatingPlugins();
51
-
52
- if ($rating_plugin_exists->yasr_search_wppr() || $rating_plugin_exists->yasr_search_rmp()
53
- || $rating_plugin_exists->yasr_search_kksr() || $rating_plugin_exists->yasr_search_mr()) {
54
- ?>
55
  <a href="?page=yasr_settings_page&tab=migration_tools"
56
  id="migration_tools"
57
- class="nav-tab <?php if ($active_tab === 'migration_tools') {
58
- echo 'nav-tab-active';
59
- } ?>">
60
- <?php _e("Migration Tools", 'yet-another-stars-rating'); ?>
61
- </a>
62
- <?php
63
  }
64
-
 
 
65
  ?>
 
 
 
 
 
66
 
67
  </h2>
68
 
69
- <?php
70
  }
71
 
72
  /**
@@ -76,20 +89,13 @@ function yasr_settings_tabs($active_tab) {
76
  * @since 2.6.6
77
  * @return string
78
  */
79
- function yasr_description_auto_insert () {
80
-
81
- $name = __('Auto Insert Options', 'yet_another-stars-rating');
82
-
83
- $div_desc = '<div class="yasr-settings-description">';
84
- $description = sprintf(
85
- __('Automatically adds YASR in your posts or pages. %s
86
- Disable this if you prefer to use shortcodes.',
87
- 'yet-another-stars-rating'
88
- ),
89
- '<br />'
90
- );
91
- $end_div = '</div>';
92
-
93
  return $name . $div_desc . $description . $end_div;
94
  }
95
 
@@ -99,13 +105,12 @@ function yasr_description_auto_insert () {
99
  *
100
  * @return string
101
  */
102
- function yasr_description_stars_title() {
103
- $name = __('Enable stars next to the title?', 'yet_another-stars-rating');
104
-
105
- $div_desc = '<div class="yasr-settings-description">';
106
- $description = __('Enable this if you want to show stars next to the title','yet-another-stars-rating');
107
- $end_div = '.</div>';
108
-
109
  return $name . $div_desc . $description . $end_div;
110
  }
111
 
@@ -114,15 +119,12 @@ function yasr_description_stars_title() {
114
  * @since 2.6.6
115
  * @return string
116
  */
117
- function yasr_description_archive_page() {
118
- $name = __('Archive Pages', 'yet_another-stars-rating');
119
-
120
- $div_desc = '<div class="yasr-settings-description">';
121
- $description =
122
- __('Enable or disable these settings if you want to show ratings in archive pages (categories, tags, etc.)',
123
- 'yet-another-stars-rating');
124
- $end_div = '.</div>';
125
-
126
  return $name . $div_desc . $description . $end_div;
127
  }
128
 
@@ -131,16 +133,12 @@ function yasr_description_archive_page() {
131
  * @since 2.6.6
132
  * @return string
133
  */
134
- function yasr_description_vv_stats() {
135
- $name = __('Show stats for visitors votes?', 'yet_another-stars-rating');
136
-
137
- $div_desc = '<div class="yasr-settings-description">';
138
- $description =sprintf(
139
- __('Enable or disable the chart bar icon (and tooltip hover it) next to the %syasr_visitor_votes%s shortcode',
140
- 'yet-another-stars-rating'), '<em>', '</em>'
141
- );
142
- $end_div = '.</div>';
143
-
144
  return $name . $div_desc . $description . $end_div;
145
  }
146
 
@@ -149,32 +147,32 @@ function yasr_description_vv_stats() {
149
  * @since 2.6.6
150
  * @return string
151
  */
152
- function yasr_description_allow_vote() {
153
- $name = __('Who is allowed to vote?', 'yet_another-stars-rating');
154
-
155
- $div_desc = '<div class="yasr-settings-description">';
156
- $description =sprintf(
157
- __('Select who can rate your posts for %syasr_visitor_votes%s and %syasr_visitor_multiset%s shortcodes',
158
- 'yet-another-stars-rating'), '<em>', '</em>', '<em>', '</em>'
 
 
 
159
  );
160
- $end_div = '.</div>';
161
-
162
  return $name . $div_desc . $description . $end_div;
163
  }
164
 
165
-
166
  /**
167
  * @author Dario Curvino <@dudo>
168
  * @since 2.6.6
169
  * @return string
170
  */
171
- function yasr_description_cstm_txt() {
172
- $name = __('Custom texts', 'yet_another-stars-rating');
173
-
174
- $div_desc = '<div class="yasr-settings-description">';
175
- $description = __('Auto insert custom texts to show before or after the stars', 'yet-another-stars-rating');
176
- $end_div = '.</div>';
177
-
178
  return $name . $div_desc . $description . $end_div;
179
  }
180
 
@@ -183,63 +181,91 @@ function yasr_description_cstm_txt() {
183
  * @since 2.6.6
184
  * @return string
185
  */
186
- function yasr_description_strucutured_data() {
187
- $name = __('Stuctured data options', 'yet_another-stars-rating');
188
-
189
- $div_desc = '<div class="yasr-settings-description">';
190
- $description = __('If ratings in a post or page are found, YASR will create structured data to show them in search results
191
- (SERP)', 'yet-another-stars-rating');
192
- $description .= '<br /><a href="https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_rischnippets_desc"
193
  target="_blank">';
194
- $description .= __('More info here', 'yet-another-stars-rating');
195
- $description .= '</a>';
196
- $end_div = '.</div>';
197
-
198
  return $name . $div_desc . $description . $end_div;
199
  }
200
 
201
- function yasr_upgrade_pro_box($position = false) {
202
- if (yasr_fs()->is_free_plan()) {
203
- if ($position === "bottom") {
 
 
 
204
  $yasr_upgrade_class = "yasr-donatedivbottom";
205
  } else {
206
  $yasr_upgrade_class = "yasr-donatedivdx";
207
  }
208
-
209
  ?>
210
 
211
- <div class="<?php echo $yasr_upgrade_class ?>" style="display: none">
 
 
212
 
213
  <h2 class="yasr-donate-title" style="color: #34A7C1">
214
- <?php _e('Upgrade to YASR Pro', 'yet-another-stars-rating'); ?>
 
 
215
  </h2>
216
 
217
  <div class="yasr-upgrade-to-pro">
218
  <ul>
219
- <li><strong><?php _e(' User Reviews', 'yet-another-stars-rating'); ?></strong></li>
220
- <li><strong><?php _e(' Custom Rankings', 'yet-another-stars-rating'); ?></strong></li>
221
- <li><strong><?php _e(' 20 + ready to use themes', 'yet-another-stars-rating'); ?></strong></li>
222
- <li><strong><?php _e(' Upload your own theme', 'yet-another-stars-rating'); ?></strong></li>
223
- <li><strong><?php _e(' Dedicate support', 'yet-another-stars-rating'); ?></strong></li>
224
- <li><strong><?php _e(' ...And much more!!', 'yet-another-stars-rating'); ?></strong></li>
 
 
 
 
 
 
 
 
 
 
 
 
225
  </ul>
226
- <a href="<?php echo yasr_fs()->get_upgrade_url(); ?>">
 
 
227
  <button class="button button-primary">
228
  <span style="font-size: large; font-weight: bold;">
229
- <?php _e('Upgrade Now', 'yet-another-stars-rating')?>
 
 
230
  </span>
231
  </button>
232
  </a>
233
  <div style="display: block; margin-top: 10px; margin-bottom: 10px; ">
234
  --- or ---
235
  </div>
236
- <a href="<?php echo yasr_fs()->get_trial_url(); ?>">
 
 
237
  <button class="button button-primary">
238
  <span style="display: block; font-size: large; font-weight: bold; margin: -3px;">
239
- <?php _e('Start Free Trial', 'yet-another-stars-rating') ?>
 
 
240
  </span>
241
  <span style="display: block; margin-top: -10px; font-size: smaller;">
242
- <?php _e('No credit-card, risk free!', 'yet-another-stars-rating') ?>
 
 
243
  </span>
244
  </button>
245
  </a>
@@ -247,8 +273,7 @@ function yasr_upgrade_pro_box($position = false) {
247
 
248
  </div>
249
 
250
- <?php
251
-
252
  }
253
 
254
  }
@@ -258,39 +283,32 @@ function yasr_upgrade_pro_box($position = false) {
258
  * Since version 1.9.5
259
  *
260
  */
261
- function yasr_resources_box($position = false) {
262
- if ($position === "bottom") {
 
 
263
  $yasr_metabox_class = "yasr-donatedivbottom";
264
- } else {
265
  $yasr_metabox_class = "yasr-donatedivdx";
266
  }
267
-
268
- $div = "<div class='$yasr_metabox_class' id='yasr-resources-box' style='display:none;'>";
269
-
270
  $text = '<div class="yasr-donate-title">Resources</div>';
271
  $text .= '<div class="yasr-donate-single-resource">
272
  <span class="dashicons dashicons-star-filled" style="color: #ccc"></span>
273
- <a target="blank" href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_official">'
274
- . __('YASR official website', 'yet-another-stars-rating') .
275
- '</a>
276
  </div>';
277
  $text .= '<div class="yasr-donate-single-resource">
278
  <span class="dashicons dashicons-edit" style="color: #ccc"></span>
279
- <a target="blank" href="https://yetanotherstarsrating.com/docs/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=documentation">'
280
- . __('Documentation', 'yet-another-stars-rating') .
281
- '</a>
282
  </div>';
283
  $text .= '<div class="yasr-donate-single-resource">
284
  <span class="dashicons dashicons-book-alt" style="color: #ccc"></span>
285
- <a target="blank" href="https://yetanotherstarsrating.com/docs/faq/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=faq">'
286
- . __('F.A.Q.', 'yet-another-stars-rating') .
287
- '</a>
288
  </div>';
289
  $text .= '<div class="yasr-donate-single-resource">
290
  <span class="dashicons dashicons-video-alt3" style="color: #ccc"></span>
291
- <a target="blank" href="https://www.youtube.com/channel/UCU5jbO1PJsUUsCNbME9S-Zw">'
292
- . __('Youtube channel', 'yet-another-stars-rating') .
293
- '</a>
294
  </div>';
295
  $text .= '<div class="yasr-donate-single-resource">
296
  <span class="dashicons dashicons-smiley" style="color: #ccc"></span>
@@ -298,60 +316,56 @@ function yasr_resources_box($position = false) {
298
  Yasr Pro
299
  </a>
300
  </div>';
301
-
302
  $div_and_text = $div . $text . '</div>';
303
-
304
- echo $div_and_text;
305
-
306
  }
307
 
308
- function yasr_buy_cofee($position = false) {
309
- if ($position === "bottom") {
 
 
310
  $yasr_metabox_class = "yasr-donatedivbottom";
311
- } else {
312
  $yasr_metabox_class = "yasr-donatedivdx";
313
  }
314
-
315
- $buymecofeetext = __('Coffee is vital to make YASR development going on!', 'yet-another-stars-rating');
316
  $buymecofeetext .= '<br />';
317
-
318
- if(yasr_fs()->is_free_plan()) {
319
- $buymecofeetext .= __('If you are enjoying YASR, and you don\'t need the pro version, please consider to buy me a coffee, thanks!',
320
- 'yet-another-stars-rating');
321
  } else {
322
- $buymecofeetext .= __('If you are enjoying YASR, please consider to buy me a coffee, thanks!',
323
- 'yet-another-stars-rating');
324
  }
325
-
326
- $div = "<div class='$yasr_metabox_class' id='yasr-buy-cofee' style='display:none;'>";
327
-
328
- $text = '<div class="yasr-donate-title">' . __('Buy me a coffee!', 'yet-another-stars-rating') .'</div>';
329
  $text .= '<div style="text-align: center">';
330
  $text .= '<a href="https://www.buymeacoffee.com/dariocurvino" target="_blank">
331
- <img src="'.YASR_IMG_DIR.'/buymecofyel.png" alt="buymeacofee">
332
  </a>';
333
  $text .= '</div>';
334
  $text .= '<div style="margin-top: 15px;">';
335
  $text .= $buymecofeetext;
336
  $text .= '</div>';
337
  $div_and_text = $div . $text . '</div>';
338
-
339
- echo $div_and_text;
340
  }
341
 
342
  /** Add a box on the right for asking to rate 5 stars on Wordpress.org
343
  * Since version 0.9.0
344
  */
345
- function yasr_ask_rating($position = false) {
346
- if ($position === "bottom") {
 
 
347
  $yasr_metabox_class = "yasr-donatedivbottom";
348
- } else {
349
  $yasr_metabox_class = "yasr-donatedivdx";
350
  }
351
-
352
- $div = "<div class='$yasr_metabox_class' id='yasr-ask-five-stars' style='display:none;'>";
353
-
354
- $text = '<div class="yasr-donate-title">' . __('Can I ask your help?', 'yet-another-stars-rating') .'</div>';
355
  $text .= '<div style="font-size: 32px; color: #F1CB32; text-align:center; margin-bottom: 20px; margin-top: -5px;">
356
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
357
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
@@ -359,63 +373,54 @@ function yasr_ask_rating($position = false) {
359
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
360
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
361
  </div>';
362
- $text .= __('Please rate YASR 5 stars on', 'yet-another-stars-rating');
363
  $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">
364
  WordPress.org.</a><br />';
365
- $text .= __(' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating');
366
  $text .= "<br /><br />";
367
  $text .= "<em>> Dario Curvino</em>";
368
-
369
  $div_and_text = $div . $text . '</div>';
370
-
371
- echo $div_and_text;
372
-
373
  }
374
 
375
-
376
  /****
377
  Yasr Right settings panel, since version 1.9.5
378
  ****/
379
- function yasr_right_settings_panel($position = false) {
380
- do_action('yasr_right_settings_panel_box', $position);
381
- yasr_upgrade_pro_box($position);
382
- yasr_resources_box($position);
383
- yasr_buy_cofee($position);
384
- yasr_ask_rating($position);
 
385
  }
386
 
387
-
388
  /** Change default admin footer on yasr settings pages
389
  * $text is the default wordpress text
390
  * Since 0.8.9
391
  */
392
-
393
- add_filter('admin_footer_text', 'yasr_custom_admin_footer');
394
-
395
- function yasr_custom_admin_footer($text) {
396
-
397
- if (isset($_GET['page'])) {
398
  $yasr_page = $_GET['page'];
399
-
400
- if ($yasr_page === 'yasr_settings_page') {
401
  $custom_text = ' | <i>';
402
  $custom_text .= sprintf(
403
- __('Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
404
- Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>',
405
- 'yet-another-stars-rating'
406
- ),
407
  'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=footer&utm_campaign=yasr_settings',
408
  'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
409
  'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
410
  );
411
  $custom_text .= '</i>';
412
-
413
  return $text . $custom_text;
414
-
415
  }
 
416
  return $text;
417
  }
 
418
  return $text;
419
  }
420
-
421
- ?>
1
  <?php
2
 
3
  /**Drow settings tab*/
4
+ function yasr_settings_tabs( $active_tab )
5
+ {
6
  ?>
7
 
8
  <h2 class="nav-tab-wrapper yasr-no-underline">
9
 
10
  <a href="?page=yasr_settings_page&tab=general_settings"
11
  id="general_settings"
12
+ class="nav-tab <?php
13
+ if ( $active_tab === 'general_settings' ) {
14
+ echo 'nav-tab-active' ;
15
+ }
16
+ ?>">
17
+ <?php
18
+ _e( 'General Settings', 'yet-another-stars-rating' );
19
+ ?>
20
  </a>
21
 
22
  <a href="?page=yasr_settings_page&tab=style_options"
23
  id="style_options"
24
+ class="nav-tab <?php
25
+ if ( $active_tab === 'style_options' ) {
26
+ echo 'nav-tab-active' ;
27
+ }
28
+ ?>">
29
+ <?php
30
+ _e( 'Aspect & Styles', 'yet-another-stars-rating' );
31
+ ?>
32
  </a>
33
 
34
  <a href="?page=yasr_settings_page&tab=manage_multi"
35
  id="manage_multi"
36
+ class="nav-tab <?php
37
+ if ( $active_tab === 'manage_multi' ) {
38
+ echo 'nav-tab-active' ;
39
+ }
40
+ ?>">
41
+ <?php
42
+ _e( 'Multi Sets', 'yet-another-stars-rating' );
43
+ ?>
44
  </a>
45
 
46
  <a href="?page=yasr_settings_page&tab=rankings"
47
  id="rankings"
48
+ class="nav-tab <?php
49
+ if ( $active_tab === 'rankings' ) {
50
+ echo 'nav-tab-active' ;
51
+ }
52
+ ?>">
53
+ <?php
54
+ _e( "Rankings", 'yet-another-stars-rating' );
55
+ ?>
56
  </a>
57
 
58
+ <?php
59
+ do_action( 'yasr_add_settings_tab', $active_tab );
60
+ $rating_plugin_exists = new YasrImportRatingPlugins();
61
+
62
+ if ( $rating_plugin_exists->yasr_search_wppr() || $rating_plugin_exists->yasr_search_rmp() || $rating_plugin_exists->yasr_search_kksr() || $rating_plugin_exists->yasr_search_mr() ) {
63
+ ?>
 
64
  <a href="?page=yasr_settings_page&tab=migration_tools"
65
  id="migration_tools"
66
+ class="nav-tab <?php
67
+ if ( $active_tab === 'migration_tools' ) {
68
+ echo 'nav-tab-active' ;
 
 
 
69
  }
70
+ ?>">
71
+ <?php
72
+ _e( "Migration Tools", 'yet-another-stars-rating' );
73
  ?>
74
+ </a>
75
+ <?php
76
+ }
77
+
78
+ ?>
79
 
80
  </h2>
81
 
82
+ <?php
83
  }
84
 
85
  /**
89
  * @since 2.6.6
90
  * @return string
91
  */
92
+ function yasr_description_auto_insert()
93
+ {
94
+ $name = __( 'Auto Insert Options', 'yet_another-stars-rating' );
95
+ $div_desc = '<div class="yasr-settings-description">';
96
+ $description = sprintf( __( 'Automatically adds YASR in your posts or pages. %s
97
+ Disable this if you prefer to use shortcodes.', 'yet-another-stars-rating' ), '<br />' );
98
+ $end_div = '</div>';
 
 
 
 
 
 
 
99
  return $name . $div_desc . $description . $end_div;
100
  }
101
 
105
  *
106
  * @return string
107
  */
108
+ function yasr_description_stars_title()
109
+ {
110
+ $name = __( 'Enable stars next to the title?', 'yet_another-stars-rating' );
111
+ $div_desc = '<div class="yasr-settings-description">';
112
+ $description = __( 'Enable this if you want to show stars next to the title', 'yet-another-stars-rating' );
113
+ $end_div = '.</div>';
 
114
  return $name . $div_desc . $description . $end_div;
115
  }
116
 
119
  * @since 2.6.6
120
  * @return string
121
  */
122
+ function yasr_description_archive_page()
123
+ {
124
+ $name = __( 'Archive Pages', 'yet_another-stars-rating' );
125
+ $div_desc = '<div class="yasr-settings-description">';
126
+ $description = __( 'Enable or disable these settings if you want to show ratings in archive pages (categories, tags, etc.)', 'yet-another-stars-rating' );
127
+ $end_div = '.</div>';
 
 
 
128
  return $name . $div_desc . $description . $end_div;
129
  }
130
 
133
  * @since 2.6.6
134
  * @return string
135
  */
136
+ function yasr_description_vv_stats()
137
+ {
138
+ $name = __( 'Show stats for visitors votes?', 'yet_another-stars-rating' );
139
+ $div_desc = '<div class="yasr-settings-description">';
140
+ $description = sprintf( __( 'Enable or disable the chart bar icon (and tooltip hover it) next to the %syasr_visitor_votes%s shortcode', 'yet-another-stars-rating' ), '<em>', '</em>' );
141
+ $end_div = '.</div>';
 
 
 
 
142
  return $name . $div_desc . $description . $end_div;
143
  }
144
 
147
  * @since 2.6.6
148
  * @return string
149
  */
150
+ function yasr_description_allow_vote()
151
+ {
152
+ $name = __( 'Who is allowed to vote?', 'yet_another-stars-rating' );
153
+ $div_desc = '<div class="yasr-settings-description">';
154
+ $description = sprintf(
155
+ __( 'Select who can rate your posts for %syasr_visitor_votes%s and %syasr_visitor_multiset%s shortcodes', 'yet-another-stars-rating' ),
156
+ '<em>',
157
+ '</em>',
158
+ '<em>',
159
+ '</em>'
160
  );
161
+ $end_div = '.</div>';
 
162
  return $name . $div_desc . $description . $end_div;
163
  }
164
 
 
165
  /**
166
  * @author Dario Curvino <@dudo>
167
  * @since 2.6.6
168
  * @return string
169
  */
170
+ function yasr_description_cstm_txt()
171
+ {
172
+ $name = __( 'Custom texts', 'yet_another-stars-rating' );
173
+ $div_desc = '<div class="yasr-settings-description">';
174
+ $description = __( 'Auto insert custom texts to show before or after the stars', 'yet-another-stars-rating' );
175
+ $end_div = '.</div>';
 
176
  return $name . $div_desc . $description . $end_div;
177
  }
178
 
181
  * @since 2.6.6
182
  * @return string
183
  */
184
+ function yasr_description_strucutured_data()
185
+ {
186
+ $name = __( 'Stuctured data options', 'yet_another-stars-rating' );
187
+ $div_desc = '<div class="yasr-settings-description">';
188
+ $description = __( 'If ratings in a post or page are found, YASR will create structured data to show them in search results
189
+ (SERP)', 'yet-another-stars-rating' );
190
+ $description .= '<br /><a href="https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_rischnippets_desc"
191
  target="_blank">';
192
+ $description .= __( 'More info here', 'yet-another-stars-rating' );
193
+ $description .= '</a>';
194
+ $end_div = '.</div>';
 
195
  return $name . $div_desc . $description . $end_div;
196
  }
197
 
198
+ function yasr_upgrade_pro_box( $position = false )
199
+ {
200
+
201
+ if ( yasr_fs()->is_free_plan() ) {
202
+
203
+ if ( $position === "bottom" ) {
204
  $yasr_upgrade_class = "yasr-donatedivbottom";
205
  } else {
206
  $yasr_upgrade_class = "yasr-donatedivdx";
207
  }
208
+
209
  ?>
210
 
211
+ <div class="<?php
212
+ echo $yasr_upgrade_class ;
213
+ ?>" style="display: none">
214
 
215
  <h2 class="yasr-donate-title" style="color: #34A7C1">
216
+ <?php
217
+ _e( 'Upgrade to YASR Pro', 'yet-another-stars-rating' );
218
+ ?>
219
  </h2>
220
 
221
  <div class="yasr-upgrade-to-pro">
222
  <ul>
223
+ <li><strong><?php
224
+ _e( ' User Reviews', 'yet-another-stars-rating' );
225
+ ?></strong></li>
226
+ <li><strong><?php
227
+ _e( ' Custom Rankings', 'yet-another-stars-rating' );
228
+ ?></strong></li>
229
+ <li><strong><?php
230
+ _e( ' 20 + ready to use themes', 'yet-another-stars-rating' );
231
+ ?></strong></li>
232
+ <li><strong><?php
233
+ _e( ' Upload your own theme', 'yet-another-stars-rating' );
234
+ ?></strong></li>
235
+ <li><strong><?php
236
+ _e( ' Dedicate support', 'yet-another-stars-rating' );
237
+ ?></strong></li>
238
+ <li><strong><?php
239
+ _e( ' ...And much more!!', 'yet-another-stars-rating' );
240
+ ?></strong></li>
241
  </ul>
242
+ <a href="<?php
243
+ echo yasr_fs()->get_upgrade_url() ;
244
+ ?>">
245
  <button class="button button-primary">
246
  <span style="font-size: large; font-weight: bold;">
247
+ <?php
248
+ _e( 'Upgrade Now', 'yet-another-stars-rating' );
249
+ ?>
250
  </span>
251
  </button>
252
  </a>
253
  <div style="display: block; margin-top: 10px; margin-bottom: 10px; ">
254
  --- or ---
255
  </div>
256
+ <a href="<?php
257
+ echo yasr_fs()->get_trial_url() ;
258
+ ?>">
259
  <button class="button button-primary">
260
  <span style="display: block; font-size: large; font-weight: bold; margin: -3px;">
261
+ <?php
262
+ _e( 'Start Free Trial', 'yet-another-stars-rating' );
263
+ ?>
264
  </span>
265
  <span style="display: block; margin-top: -10px; font-size: smaller;">
266
+ <?php
267
+ _e( 'No credit-card, risk free!', 'yet-another-stars-rating' );
268
+ ?>
269
  </span>
270
  </button>
271
  </a>
273
 
274
  </div>
275
 
276
+ <?php
 
277
  }
278
 
279
  }
283
  * Since version 1.9.5
284
  *
285
  */
286
+ function yasr_resources_box( $position = false )
287
+ {
288
+
289
+ if ( $position === "bottom" ) {
290
  $yasr_metabox_class = "yasr-donatedivbottom";
291
+ } else {
292
  $yasr_metabox_class = "yasr-donatedivdx";
293
  }
294
+
295
+ $div = "<div class='{$yasr_metabox_class}' id='yasr-resources-box' style='display:none;'>";
 
296
  $text = '<div class="yasr-donate-title">Resources</div>';
297
  $text .= '<div class="yasr-donate-single-resource">
298
  <span class="dashicons dashicons-star-filled" style="color: #ccc"></span>
299
+ <a target="blank" href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_official">' . __( 'YASR official website', 'yet-another-stars-rating' ) . '</a>
 
 
300
  </div>';
301
  $text .= '<div class="yasr-donate-single-resource">
302
  <span class="dashicons dashicons-edit" style="color: #ccc"></span>
303
+ <a target="blank" href="https://yetanotherstarsrating.com/docs/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=documentation">' . __( 'Documentation', 'yet-another-stars-rating' ) . '</a>
 
 
304
  </div>';
305
  $text .= '<div class="yasr-donate-single-resource">
306
  <span class="dashicons dashicons-book-alt" style="color: #ccc"></span>
307
+ <a target="blank" href="https://yetanotherstarsrating.com/docs/faq/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=faq">' . __( 'F.A.Q.', 'yet-another-stars-rating' ) . '</a>
 
 
308
  </div>';
309
  $text .= '<div class="yasr-donate-single-resource">
310
  <span class="dashicons dashicons-video-alt3" style="color: #ccc"></span>
311
+ <a target="blank" href="https://www.youtube.com/channel/UCU5jbO1PJsUUsCNbME9S-Zw">' . __( 'Youtube channel', 'yet-another-stars-rating' ) . '</a>
 
 
312
  </div>';
313
  $text .= '<div class="yasr-donate-single-resource">
314
  <span class="dashicons dashicons-smiley" style="color: #ccc"></span>
316
  Yasr Pro
317
  </a>
318
  </div>';
 
319
  $div_and_text = $div . $text . '</div>';
320
+ echo $div_and_text ;
 
 
321
  }
322
 
323
+ function yasr_buy_cofee( $position = false )
324
+ {
325
+
326
+ if ( $position === "bottom" ) {
327
  $yasr_metabox_class = "yasr-donatedivbottom";
328
+ } else {
329
  $yasr_metabox_class = "yasr-donatedivdx";
330
  }
331
+
332
+ $buymecofeetext = __( 'Coffee is vital to make YASR development going on!', 'yet-another-stars-rating' );
333
  $buymecofeetext .= '<br />';
334
+
335
+ if ( yasr_fs()->is_free_plan() ) {
336
+ $buymecofeetext .= __( 'If you are enjoying YASR, and you don\'t need the pro version, please consider to buy me a coffee, thanks!', 'yet-another-stars-rating' );
 
337
  } else {
338
+ $buymecofeetext .= __( 'If you are enjoying YASR, please consider to buy me a coffee, thanks!', 'yet-another-stars-rating' );
 
339
  }
340
+
341
+ $div = "<div class='{$yasr_metabox_class}' id='yasr-buy-cofee' style='display:none;'>";
342
+ $text = '<div class="yasr-donate-title">' . __( 'Buy me a coffee!', 'yet-another-stars-rating' ) . '</div>';
 
343
  $text .= '<div style="text-align: center">';
344
  $text .= '<a href="https://www.buymeacoffee.com/dariocurvino" target="_blank">
345
+ <img src="' . YASR_IMG_DIR . '/buymecofyel.png" alt="buymeacofee">
346
  </a>';
347
  $text .= '</div>';
348
  $text .= '<div style="margin-top: 15px;">';
349
  $text .= $buymecofeetext;
350
  $text .= '</div>';
351
  $div_and_text = $div . $text . '</div>';
352
+ echo $div_and_text ;
 
353
  }
354
 
355
  /** Add a box on the right for asking to rate 5 stars on Wordpress.org
356
  * Since version 0.9.0
357
  */
358
+ function yasr_ask_rating( $position = false )
359
+ {
360
+
361
+ if ( $position === "bottom" ) {
362
  $yasr_metabox_class = "yasr-donatedivbottom";
363
+ } else {
364
  $yasr_metabox_class = "yasr-donatedivdx";
365
  }
366
+
367
+ $div = "<div class='{$yasr_metabox_class}' id='yasr-ask-five-stars' style='display:none;'>";
368
+ $text = '<div class="yasr-donate-title">' . __( 'Can I ask your help?', 'yet-another-stars-rating' ) . '</div>';
 
369
  $text .= '<div style="font-size: 32px; color: #F1CB32; text-align:center; margin-bottom: 20px; margin-top: -5px;">
370
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
371
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
373
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
374
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
375
  </div>';
376
+ $text .= __( 'Please rate YASR 5 stars on', 'yet-another-stars-rating' );
377
  $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">
378
  WordPress.org.</a><br />';
379
+ $text .= __( ' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating' );
380
  $text .= "<br /><br />";
381
  $text .= "<em>> Dario Curvino</em>";
 
382
  $div_and_text = $div . $text . '</div>';
383
+ echo $div_and_text ;
 
 
384
  }
385
 
 
386
  /****
387
  Yasr Right settings panel, since version 1.9.5
388
  ****/
389
+ function yasr_right_settings_panel( $position = false )
390
+ {
391
+ do_action( 'yasr_right_settings_panel_box', $position );
392
+ yasr_upgrade_pro_box( $position );
393
+ yasr_resources_box( $position );
394
+ yasr_buy_cofee( $position );
395
+ yasr_ask_rating( $position );
396
  }
397
 
 
398
  /** Change default admin footer on yasr settings pages
399
  * $text is the default wordpress text
400
  * Since 0.8.9
401
  */
402
+ add_filter( 'admin_footer_text', 'yasr_custom_admin_footer' );
403
+ function yasr_custom_admin_footer( $text )
404
+ {
405
+
406
+ if ( isset( $_GET['page'] ) ) {
 
407
  $yasr_page = $_GET['page'];
408
+
409
+ if ( $yasr_page === 'yasr_settings_page' ) {
410
  $custom_text = ' | <i>';
411
  $custom_text .= sprintf(
412
+ __( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
413
+ Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>', 'yet-another-stars-rating' ),
 
 
414
  'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=footer&utm_campaign=yasr_settings',
415
  'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
416
  'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
417
  );
418
  $custom_text .= '</i>';
 
419
  return $text . $custom_text;
 
420
  }
421
+
422
  return $text;
423
  }
424
+
425
  return $text;
426
  }
 
 
admin/settings/yasr-settings-page.php CHANGED
@@ -100,7 +100,7 @@ if (!current_user_can('manage_options')) {
100
  yasr_right_settings_panel();
101
  ?>
102
 
103
- <div class="">
104
  </div>
105
 
106
  <?php
100
  yasr_right_settings_panel();
101
  ?>
102
 
103
+ <div>
104
  </div>
105
 
106
  <?php
admin/yasr-admin-init.php CHANGED
@@ -48,7 +48,6 @@ require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-functions.php';
48
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-actions.php';
49
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-actions-ajax.php';
50
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-filters.php';
51
- require YASR_ABSOLUTE_PATH_ADMIN . '/class-wp-list-table.php';
52
  require YASR_ABSOLUTE_PATH_ADMIN . '/settings/yasr-settings-functions-misc.php';
53
  require YASR_ABSOLUTE_PATH_ADMIN . '/editor/yasr-editor-functions.php';
54
  require YASR_ABSOLUTE_PATH_ADMIN . '/editor/YasrOnSavePost.php';
48
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-actions.php';
49
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-actions-ajax.php';
50
  require YASR_ABSOLUTE_PATH_ADMIN . '/yasr-admin-filters.php';
 
51
  require YASR_ABSOLUTE_PATH_ADMIN . '/settings/yasr-settings-functions-misc.php';
52
  require YASR_ABSOLUTE_PATH_ADMIN . '/editor/yasr-editor-functions.php';
53
  require YASR_ABSOLUTE_PATH_ADMIN . '/editor/YasrOnSavePost.php';
includes/classes/YasrDatabaseRatings.php CHANGED
@@ -143,8 +143,7 @@ class YasrDatabaseRatings {
143
  public static function visitorVotesHasUserVoted($post_id = false) {
144
  global $wpdb;
145
 
146
- $current_user = wp_get_current_user();
147
- $user_id = $current_user->ID;
148
 
149
  //just to be safe
150
  if (!is_int($post_id)) {
143
  public static function visitorVotesHasUserVoted($post_id = false) {
144
  global $wpdb;
145
 
146
+ $user_id = get_current_user_id();
 
147
 
148
  //just to be safe
149
  if (!is_int($post_id)) {
includes/classes/YasrFindCachingPlugins.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Copyright 2020 Dario Curvino (email : d.curvino@tiscali.it)
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>
19
+ */
20
+
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
+ } // Exit if accessed directly
24
+
25
+ /**
26
+ * Check if caching plugin is active
27
+ *
28
+ * @author Dario Curvino <@dudo>
29
+ * @since 2.7.7
30
+ * Class YasrFindCachingPlugins
31
+ */
32
+ class YasrFindCachingPlugins {
33
+
34
+ /**
35
+ * @author Dario Curvino <@dudo>
36
+ * @since 2.7.7
37
+ * @return false|string
38
+ */
39
+ public function cachingPluginFound () {
40
+ $methods = get_class_methods($this);
41
+
42
+ foreach($methods as $method) {
43
+ if(($method !== 'cachingPluginFound') && $this->{$method}()) {
44
+ return $method;
45
+ }
46
+ }
47
+ return false;
48
+ }
49
+
50
+ /**
51
+ * @author Dario Curvino <@dudo>
52
+ * @since 2.7.7
53
+ * @return bool
54
+ */
55
+ public function wpRocket() {
56
+ if (is_plugin_active('wp-rocket/wp-rocket.php')) {
57
+ return true;
58
+ }
59
+ return false;
60
+ }
61
+
62
+ /**
63
+ * @author Dario Curvino <@dudo>
64
+ * @since 2.7.7
65
+ * @return bool
66
+ */
67
+ public function cacheEnabler() {
68
+ if (is_plugin_active('cache-enabler/cache-enabler.php')) {
69
+ return true;
70
+ }
71
+ return false;
72
+ }
73
+
74
+ /**
75
+ * @author Dario Curvino <@dudo>
76
+ * @since 2.7.7
77
+ * @return bool
78
+ */
79
+ public function litespeed() {
80
+ if (is_plugin_active('litespeed-cache/litespeed-cache.php')) {
81
+ return true;
82
+ }
83
+ return false;
84
+ }
85
+
86
+ /**
87
+ * @author Dario Curvino <@dudo>
88
+ * @since 2.7.7
89
+ * @return bool
90
+ */
91
+ public function w3TotalCache() {
92
+ if (is_plugin_active('w3-total-cache/w3-total-cache.php')) {
93
+ return true;
94
+ }
95
+ return false;
96
+ }
97
+
98
+ /**
99
+ * @author Dario Curvino <@dudo>
100
+ * @since 2.7.7
101
+ * @return bool
102
+ */
103
+ public function wpFastestCache() {
104
+ if (is_plugin_active('wp-fastest-cache/wpFastestCache.php')) {
105
+ return true;
106
+ }
107
+ return false;
108
+ }
109
+
110
+ /**
111
+ * @author Dario Curvino <@dudo>
112
+ * @since 2.7.7
113
+ * @return bool
114
+ */
115
+ public function wpSuperCache() {
116
+ if (is_plugin_active('wp-super-cache/wp-cache.php')) {
117
+ return true;
118
+ }
119
+ return false;
120
+ }
121
+
122
+ /**
123
+ * @author Dario Curvino <@dudo>
124
+ * @since 2.7.7
125
+ * @return bool
126
+ */
127
+ public function wpOptimize() {
128
+ if (is_plugin_active('wp-optimize/wp-optimize.php')) {
129
+ return true;
130
+ }
131
+ return false;
132
+ }
133
+
134
+ /**
135
+ * @author Dario Curvino <@dudo>
136
+ * @since 2.7.7
137
+ * @return bool
138
+ */
139
+ public function breeze() {
140
+ if (is_plugin_active('breeze/breeze.php')) {
141
+ return true;
142
+ }
143
+ return false;
144
+ }
145
+
146
+ /**
147
+ * @author Dario Curvino <@dudo>
148
+ * @since 2.7.7
149
+ * @return bool
150
+ */
151
+ public function cometCache() {
152
+ if (is_plugin_active('comet-cache/comet-cache.php')) {
153
+ return true;
154
+ }
155
+ return false;
156
+ }
157
+
158
+ /**
159
+ * @author Dario Curvino <@dudo>
160
+ * @since 2.7.7
161
+ * @return bool
162
+ */
163
+ public function hummingbird() {
164
+ if (is_plugin_active('hummingbird-performance/wp-hummingbird.php')) {
165
+ return true;
166
+ }
167
+ return false;
168
+ }
169
+
170
+ /**
171
+ * @author Dario Curvino <@dudo>
172
+ * @since 2.7.7
173
+ * @return bool
174
+ */
175
+ public function pantheon() {
176
+ if (is_plugin_active('pantheon-advanced-page-cache/pantheon-advanced-page-cache.php')) {
177
+ return true;
178
+ }
179
+ return false;
180
+ }
181
+
182
+ /**
183
+ * @author Dario Curvino <@dudo>
184
+ * @since 2.7.7
185
+ * @return bool
186
+ */
187
+ public function performanceScoreBooster() {
188
+ if (is_plugin_active('wp-performance-score-booster/wp-performance-score-booster.php')) {
189
+ return true;
190
+ }
191
+ return false;
192
+ }
193
+
194
+ }
includes/classes/YasrIncludesFilters.php CHANGED
@@ -26,11 +26,11 @@ class YasrIncludesFilters {
26
  public function filterCustomTexts($yasr_stored_options) {
27
  $this->yasr_stored_options = $yasr_stored_options;
28
 
29
- add_filter('yasr_cstm_text_before_overall', array($this, 'filterTextOverall'), 99);
30
- add_filter('yasr_cstm_text_before_vv', array($this, 'filterTextVVBefore'), 99, 3);
31
- add_filter('yasr_cstm_text_after_vv', array($this, 'filterTextVVAfter'), 99, 3);
32
- add_filter('yasr_cstm_text_already_voted', array($this, 'filterTextAlreadyVoted'), 99, 2);
33
- add_filter('yasr_must_sign_in', array($this, 'filterTextMustSignIn'), 99 );
34
  }
35
 
36
  /**
26
  public function filterCustomTexts($yasr_stored_options) {
27
  $this->yasr_stored_options = $yasr_stored_options;
28
 
29
+ add_filter('yasr_cstm_text_before_overall', array($this, 'filterTextOverall'));
30
+ add_filter('yasr_cstm_text_before_vv', array($this, 'filterTextVVBefore'), 10, 3);
31
+ add_filter('yasr_cstm_text_after_vv', array($this, 'filterTextVVAfter'), 10, 3);
32
+ add_filter('yasr_cstm_text_already_voted', array($this, 'filterTextAlreadyVoted'), 10, 2);
33
+ add_filter('yasr_must_sign_in', array($this, 'filterTextMustSignIn'));
34
  }
35
 
36
  /**
includes/classes/YasrMultiSetData.php CHANGED
@@ -233,8 +233,8 @@ class YasrMultiSetData {
233
  }
234
 
235
  //get meta values (field id and rating)
236
- $ratings = $wpdb->get_results($wpdb->prepare("
237
- SELECT CAST((SUM(l.vote)/COUNT(l.vote)) AS DECIMAL(2,1)) AS average_rating,
238
  COUNT(l.vote) AS number_of_votes,
239
  field_id AS field
240
  FROM " . YASR_LOG_MULTI_SET . " AS l
233
  }
234
 
235
  //get meta values (field id and rating)
236
+ $ratings = $wpdb->get_results($wpdb->prepare(
237
+ "SELECT CAST((SUM(l.vote)/COUNT(l.vote)) AS DECIMAL(2,1)) AS average_rating,
238
  COUNT(l.vote) AS number_of_votes,
239
  field_id AS field
240
  FROM " . YASR_LOG_MULTI_SET . " AS l
includes/js/src/yasr-front.js CHANGED
@@ -49,7 +49,6 @@ export function yasrSearchStarsDom (starsClass) {
49
 
50
  //used in shortcode page and ajax page
51
  function yasrDrawTipsProgress (yasrStatsInDom) {
52
-
53
  //htmlcheckid declared false
54
  let htmlIdChecked = false;
55
 
@@ -157,7 +156,6 @@ function yasrSetRating (yasrRatingsInDom) {
157
  }
158
 
159
  function yasrVisitorVotesFront (yasrRaterVVInDom) {
160
-
161
  //Check in the object
162
  for (let i = 0; i < yasrRaterVVInDom.length; i++) {
163
 
@@ -202,16 +200,18 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
202
  let loaderContainer = 'yasr-vv-loader-' + uniqueId;
203
 
204
  if(yasrCommonData.ajaxEnabled === 'yes') {
205
- let cpt = elem.getAttribute('data-cpt');
206
-
207
- if(cpt === '') {
208
- cpt = 'posts';
209
- }
210
 
211
- let urlVisitorVotes = 'wp/v2/'+ cpt +'/' + postId + '?_fields=yasr_visitor_votes&_wpnonce='+yasrCommonData.nonce;
 
212
 
213
- jQuery.get(yasrCommonData.restEndpoint + urlVisitorVotes).done(
214
- function (data) {
 
215
  let readonly;
216
  //if has readonly attribute, it is always true
217
  if(readonlyShortcode === true) {
@@ -233,7 +233,6 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
233
 
234
  //do this only if yasr_visitor_votes has not the readonly attribute
235
  if(readonlyShortcode !== true) {
236
-
237
  if(containerVotesNumber !== null) {
238
  containerVotesNumber.innerHTML = data.yasr_visitor_votes.number_of_votes;
239
  }
@@ -271,6 +270,21 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
271
 
272
  }
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
275
  containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer) {
276
 
@@ -282,6 +296,9 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
282
 
283
  const elem = document.getElementById(htmlId);
284
 
 
 
 
285
  let rateCallback = function (rating, done) {
286
  //show the loader
287
  document.getElementById(loaderContainer).innerHTML = yasrCommonData.loaderHtml;
@@ -311,6 +328,8 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
311
  }
312
  if(bottomContainer !== null) {
313
  bottomContainer.innerHTML = response.rating_saved_text;
 
 
314
  }
315
 
316
  //empty loader gif
@@ -391,7 +410,7 @@ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
391
  nonce: nonce,
392
  post_id: multiSetPostId,
393
  rating: ratingArray,
394
- set_type: multiSetId
395
  };
396
 
397
  //Send value to the Server
49
 
50
  //used in shortcode page and ajax page
51
  function yasrDrawTipsProgress (yasrStatsInDom) {
 
52
  //htmlcheckid declared false
53
  let htmlIdChecked = false;
54
 
156
  }
157
 
158
  function yasrVisitorVotesFront (yasrRaterVVInDom) {
 
159
  //Check in the object
160
  for (let i = 0; i < yasrRaterVVInDom.length; i++) {
161
 
200
  let loaderContainer = 'yasr-vv-loader-' + uniqueId;
201
 
202
  if(yasrCommonData.ajaxEnabled === 'yes') {
203
+ let data = {
204
+ action: 'yasr_load_vv',
205
+ post_id: postId,
206
+ nonce_visitor: nonce
207
+ };
208
 
209
+ //show the loader
210
+ document.getElementById(htmlId).innerHTML = yasrCommonData.loaderHtml;
211
 
212
+ jQuery.get(yasrCommonData.ajaxurl, data).done(
213
+ function (response) {
214
+ let data = JSON.parse(response);
215
  let readonly;
216
  //if has readonly attribute, it is always true
217
  if(readonlyShortcode === true) {
233
 
234
  //do this only if yasr_visitor_votes has not the readonly attribute
235
  if(readonlyShortcode !== true) {
 
236
  if(containerVotesNumber !== null) {
237
  containerVotesNumber.innerHTML = data.yasr_visitor_votes.number_of_votes;
238
  }
270
 
271
  }
272
 
273
+ /**
274
+ *
275
+ * @param starSize
276
+ * @param rating
277
+ * @param postId
278
+ * @param readonly
279
+ * @param htmlId
280
+ * @param uniqueId
281
+ * @param nonce
282
+ * @param isSingular
283
+ * @param containerVotesNumber
284
+ * @param containerAverageNumber
285
+ * @param loaderContainer
286
+ * @param bottomContainer
287
+ */
288
  function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular,
289
  containerVotesNumber, containerAverageNumber, loaderContainer, bottomContainer) {
290
 
296
 
297
  const elem = document.getElementById(htmlId);
298
 
299
+ //Be sure the loader is hidden
300
+ document.getElementById(htmlId).innerHTML = '';
301
+
302
  let rateCallback = function (rating, done) {
303
  //show the loader
304
  document.getElementById(loaderContainer).innerHTML = yasrCommonData.loaderHtml;
328
  }
329
  if(bottomContainer !== null) {
330
  bottomContainer.innerHTML = response.rating_saved_text;
331
+ //Be sure the bottom container is showed
332
+ bottomContainer.style.display = '';
333
  }
334
 
335
  //empty loader gif
410
  nonce: nonce,
411
  post_id: multiSetPostId,
412
  rating: ratingArray,
413
+ set_id: multiSetId
414
  };
415
 
416
  //Send value to the Server
includes/js/yasr-front.js CHANGED
@@ -1 +1 @@
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){t.exports=r(1)},function(t,e,r){"use strict";var a,n;r.r(e),r.d(e,"yasrSearchStarsDom",(function(){return L})),r.d(e,"yasrSetRaterValue",(function(){return j}));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,r=(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(r))throw TypeError("Stringified UUID is invalid");return r};var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||s)();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 d(a)};function y(t){return(y="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 g(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 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 r,a=h(t);if(e){var n=h(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return v(this,r)}}function v(t,e){return!e||"object"!==y(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(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return j(r,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 I(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 k(t){var e="after",r=b("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(R,{post:t.post,tableId:t.tableId,text:r}),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:r}))}function w(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(I,{colClass:e,post:t.post}),React.createElement(k,{colClass:r,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,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(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}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,r,a,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},e}return e=o,(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(b("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(b("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(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:r})}))}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:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",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("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];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.restEndpoint+a+"?show=most&source="+r+n+s,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}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 o=React.createElement("span",null,React.createElement("span",{id:a},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:a,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,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,o="most-rated-posts-"+r,s="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(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(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(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(C,{data:o,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,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,r),a&&g(e,a),o}();for(var x=wp.i18n.__,B=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],T=0;T<B.length;T++)L(B[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 r=t.item(e),a=r.id;j(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"),o=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),c=r.getAttribute("data-rater-nonce"),d=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,y="yasr-vv-average-container-"+l,g="yasr-vv-bottom-container-"+l,f=document.getElementById(m),p=document.getElementById(y),v=document.getElementById(g),h="yasr-vv-loader-"+l;if("yes"===yasrCommonData.ajaxEnabled){var b=r.getAttribute("data-cpt");""===b&&(b="posts");var _="wp/v2/"+b+"/"+s+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+_).done((function(t){var e;e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),P(u,a,s,e,i,l,c,d,f,p,h,v),!0!==n&&(null!==f&&(f.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==p&&(p.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&null!==v&&(v.innerHTML=t.yasr_visitor_votes.stars_attributes.span_bottom,v.style.display=""))})).fail((function(t,e,r,m){console.info(x("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,a,s,o,i,l,c,d,f,p,h,v),!0!==n&&(v.style.display="")}))}else P(u,a,s,o,i,l,c,d,f,p,h,v)}}(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 o="#"+t.item(n).id,s=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:s};tippy(o,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){o!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){a=o}})}(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),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);j(16,o,n,1,s,!1,(function(t,a){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},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_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function j(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,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];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,r,a,n,o,s,i,l,u,c,d){e=parseFloat(e),a=O(a);j(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(c).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(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),document.getElementById(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 r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=document.getElementById(r);_(React.createElement(S,{source:a,tableId:r,params:n}),o)}}()}]);
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){t.exports=r(1)},function(t,e,r){"use strict";var a,n;r.r(e),r.d(e,"yasrSearchStarsDom",(function(){return L})),r.d(e,"yasrSetRaterValue",(function(){return j}));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,r=(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(r))throw TypeError("Stringified UUID is invalid");return r};var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||s)();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 d(a)};function y(t){return(y="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 g(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 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 r,a=h(t);if(e){var n=h(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return v(this,r)}}function v(t,e){return!e||"object"!==y(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(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return j(r,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 I(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 k(t){var e="after",r=b("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(R,{post:t.post,tableId:t.tableId,text:r}),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:r}))}function w(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(I,{colClass:e,post:t.post}),React.createElement(k,{colClass:r,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,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(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}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,r,a,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},e}return e=o,(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(b("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(b("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(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:r})}))}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:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",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("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];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.restEndpoint+a+"?show=most&source="+r+n+s,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}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 o=React.createElement("span",null,React.createElement("span",{id:a},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:a,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,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,o="most-rated-posts-"+r,s="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(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(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(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(C,{data:o,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,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,r),a&&g(e,a),o}();for(var B=wp.i18n.__,T=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],x=0;x<T.length;x++)L(T[x]);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 r=t.item(e),a=r.id;j(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"),o=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),c=r.getAttribute("data-rater-nonce"),d=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,y="yasr-vv-average-container-"+l,g="yasr-vv-bottom-container-"+l,f=document.getElementById(m),p=document.getElementById(y),v=document.getElementById(g),h="yasr-vv-loader-"+l;if("yes"===yasrCommonData.ajaxEnabled){var b={action:"yasr_load_vv",post_id:s,nonce_visitor:c};document.getElementById(i).innerHTML=yasrCommonData.loaderHtml,jQuery.get(yasrCommonData.ajaxurl,b).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),P(u,a,s,e,i,l,c,d,f,p,h,v),!0!==n&&(null!==f&&(f.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==p&&(p.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==v&&(v.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,v.style.display=""))})).fail((function(t,e,r,m){console.info(B("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,a,s,o,i,l,c,d,f,p,h,v),!0!==n&&(v.style.display="")}))}else P(u,a,s,o,i,l,c,d,f,p,h,v)}}(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 o="#"+t.item(n).id,s=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:s};tippy(o,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){o!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){a=o}})}(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),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);j(16,o,n,1,s,!1,(function(t,a){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},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){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function j(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,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];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,r,a,n,o,s,i,l,u,c,d){e=parseFloat(e),a=O(a);var m=document.getElementById(n);document.getElementById(n).innerHTML="";j(t,n,m,1,a,e,(function(t,e){document.getElementById(c).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(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=""),document.getElementById(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 r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=document.getElementById(r);_(React.createElement(S,{source:a,tableId:r,params:n}),o)}}()}]);
includes/rest/classes/YasrCustomFields.php CHANGED
@@ -69,7 +69,7 @@ class YasrCustomFields extends WP_REST_Controller {
69
  $post_types,
70
  'yasr_visitor_votes',
71
  array(
72
- 'get_callback' => array($this, 'returnArrayVisitorVotes'),
73
  'update_callback' => null,
74
  'schema' => $yasr_vv_schema
75
  )
@@ -77,38 +77,6 @@ class YasrCustomFields extends WP_REST_Controller {
77
 
78
  }
79
 
80
- //can't be private
81
- protected function returnArrayVisitorVotes() {
82
-
83
- //default values
84
- $array_to_return = array(
85
- 'number_of_votes' => 0,
86
- 'sum_votes' => 0,
87
- 'stars_attributes' => array(
88
- 'read_only' => true,
89
- 'span_bottom' => false
90
- )
91
- );
92
-
93
- $cookie_value = YasrVisitorVotes::checkCookie();
94
- $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
95
-
96
- //if user is enabled to rate, readonly must be false
97
- if($stars_enabled === 'true_logged' || $stars_enabled === 'true_not_logged') {
98
- $array_to_return['stars_attributes']['read_only'] = false;
99
- }
100
-
101
- $array_to_return['stars_attributes']['span_bottom'] = YasrVisitorVotes::showTextBelowStars($cookie_value);
102
-
103
- $array_visitor_votes = YasrDatabaseRatings::getVisitorVotes();
104
-
105
- $array_to_return['number_of_votes'] = $array_visitor_votes['number_of_votes'];
106
- $array_to_return['sum_votes'] = $array_visitor_votes['sum_votes'];
107
-
108
- return $array_to_return;
109
-
110
- }
111
-
112
  /**
113
  * Function to returns all supported itemtype
114
  * (YASR_SUPPORTED_SCHEMA_TYPES)
69
  $post_types,
70
  'yasr_visitor_votes',
71
  array(
72
+ 'get_callback' => function () {return YasrShortcodesAjax::returnArrayVisitorVotes();},
73
  'update_callback' => null,
74
  'schema' => $yasr_vv_schema
75
  )
77
 
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  /**
81
  * Function to returns all supported itemtype
82
  * (YASR_SUPPORTED_SCHEMA_TYPES)
includes/shortcodes/classes/YasrShortcode.php CHANGED
@@ -41,7 +41,6 @@ abstract class YasrShortcode
41
  public $show_average ;
42
  //null
43
  public $shortcode_name ;
44
- public $post_type ;
45
  public function __construct( $atts, $shortcode_name )
46
  {
47
  $this->shortcode_name = $shortcode_name;
@@ -66,8 +65,7 @@ abstract class YasrShortcode
66
  $this->set_id = (int) $atts['setid'];
67
  $this->show_average = sanitize_text_field( $atts['show_average'] );
68
  }
69
-
70
- $this->post_type = YasrCustomPostTypes::returnBaseUrl( $this->post_id );
71
  }
72
 
73
  /**
41
  public $show_average ;
42
  //null
43
  public $shortcode_name ;
 
44
  public function __construct( $atts, $shortcode_name )
45
  {
46
  $this->shortcode_name = $shortcode_name;
65
  $this->set_id = (int) $atts['setid'];
66
  $this->show_average = sanitize_text_field( $atts['show_average'] );
67
  }
68
+
 
69
  }
70
 
71
  /**
includes/shortcodes/classes/YasrShortcodesAjax.php ADDED
@@ -0,0 +1,607 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 2 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>
18
+ */
19
+
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
+ } // Exit if accessed directly
23
+
24
+ /**
25
+ * This function adds ajax action needed for shortcodes
26
+ *
27
+ * @author Dario Curvino <@dudo>
28
+ * @since 2.7.7
29
+ * Class YasrShortcodesAjax
30
+ */
31
+ class YasrShortcodesAjax {
32
+
33
+ public function init() {
34
+ if (YASR_ENABLE_AJAX === 'yes') {
35
+ //load vv with ajax
36
+ add_action('wp_ajax_yasr_load_vv', array('YasrShortcodesAjax', 'returnArrayVisitorVotes'));
37
+ add_action('wp_ajax_nopriv_yasr_load_vv', array('YasrShortcodesAjax', 'returnArrayVisitorVotes'));
38
+ }
39
+
40
+ //VV save rating
41
+ add_action('wp_ajax_yasr_send_visitor_rating', array($this, 'saveVV'));
42
+ add_action('wp_ajax_nopriv_yasr_send_visitor_rating', array($this, 'saveVV'));
43
+
44
+ //MV save rating
45
+ add_action('wp_ajax_yasr_visitor_multiset_field_vote', array($this, 'saveMV'));
46
+ add_action('wp_ajax_nopriv_yasr_visitor_multiset_field_vote', array($this, 'saveMV'));
47
+
48
+
49
+ //VV load stats
50
+ if(YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'enabled') {
51
+ add_action('wp_ajax_yasr_stats_visitors_votes', array($this, 'returnVVStats'));
52
+ add_action('wp_ajax_nopriv_yasr_stats_visitors_votes', array($this, 'returnVVStats'));
53
+ }
54
+
55
+ }
56
+
57
+ /**
58
+ * Save or update rating for yasr_visitor_votes
59
+ *
60
+ * @author Dario Curvino <@dudo>
61
+ * @since refactor in 2.7.7
62
+ */
63
+ public function saveVV() {
64
+ if (isset($_POST['rating'], $_POST['post_id'], $_POST['nonce_visitor'])) {
65
+ $rating = (int) $_POST['rating'];
66
+ $post_id = (int) $_POST['post_id'];
67
+ $nonce_visitor = $_POST['nonce_visitor'];
68
+ $is_singular = $_POST['is_singular'];
69
+ }
70
+ else {
71
+ die();
72
+ }
73
+
74
+ $array_action_visitor_vote = array('post_id' => $post_id, 'is_singular' => $is_singular);
75
+
76
+ do_action('yasr_action_on_visitor_vote', $array_action_visitor_vote);
77
+
78
+ if (!wp_verify_nonce($nonce_visitor, 'yasr_nonce_vv')) {
79
+ die('Security check');
80
+ }
81
+
82
+ if ($rating < 1) {
83
+ $rating = 1;
84
+ }
85
+ elseif ($rating > 5) {
86
+ $rating = 5;
87
+ }
88
+
89
+ $current_user_id = get_current_user_id();
90
+ $ip_address = yasr_get_ip();
91
+
92
+ $result_update_log = null; //avoid undefined
93
+ $result_insert_log = null; //avoid undefined
94
+
95
+ if (is_user_logged_in()) {
96
+ //try to update first, if fails the do the insert
97
+ $result_update_log = $this->vvUpdateRating($post_id, $current_user_id, $rating, $ip_address);
98
+
99
+ //insert the new row
100
+ //use ! instead of === FALSE
101
+ if (!$result_update_log) {
102
+ $result_insert_log = $this->vvSaveRating($post_id, $current_user_id, $rating, $ip_address);
103
+ }
104
+
105
+ } //if user is not logged in insert
106
+ else {
107
+ $result_insert_log = $this->vvSaveRating($post_id, $current_user_id, $rating, $ip_address);
108
+ }
109
+
110
+ if ($result_update_log || $result_insert_log) {
111
+ echo json_encode($this->vvReturnResponse($post_id, $rating, $result_update_log));
112
+ }
113
+
114
+ die(); // this is required to return a proper result
115
+
116
+ }
117
+
118
+ /**
119
+ * @author Dario Curvino <@dudo>
120
+ * @since 2.7.7
121
+ *
122
+ * @param $post_id
123
+ * @param $user_id
124
+ * @param $rating
125
+ * @param $ip_address
126
+ *
127
+ * @return bool|int
128
+ */
129
+ public function vvSaveRating($post_id, $user_id, $rating, $ip_address) {
130
+ global $wpdb;
131
+ return $wpdb->replace(
132
+ YASR_LOG_TABLE, array(
133
+ 'post_id' => $post_id,
134
+ 'user_id' => $user_id,
135
+ 'vote' => $rating,
136
+ 'date' => date('Y-m-d H:i:s'),
137
+ 'ip' => $ip_address
138
+ ), array('%d', '%d', '%d', '%s', '%s', '%s')
139
+ );
140
+ }
141
+
142
+ /**
143
+ * @author Dario Curvino <@dudo>
144
+ * @since 2.7.7
145
+ *
146
+ * @param $post_id
147
+ * @param $user_id
148
+ * @param $rating
149
+ * @param $ip_address
150
+ *
151
+ * @return bool|int
152
+ */
153
+ public function vvUpdateRating($post_id, $user_id, $rating, $ip_address) {
154
+ global $wpdb;
155
+
156
+ return $wpdb->update(
157
+ YASR_LOG_TABLE, array(
158
+ 'post_id' => $post_id,
159
+ 'user_id' => $user_id,
160
+ 'vote' => $rating,
161
+ 'date' => date('Y-m-d H:i:s'),
162
+ 'ip' => $ip_address
163
+ ), array(
164
+ 'post_id' => $post_id,
165
+ 'user_id' => $user_id
166
+ ), array('%d', '%d', '%d', '%s', '%s', '%s'), array('%d', '%d')
167
+ );
168
+ }
169
+
170
+ /**
171
+ * @author Dario Curvino <@dudo>
172
+ * @since 2.7.7
173
+ *
174
+ * @param $post_id
175
+ * @param $rating
176
+ * @param $result_update_log
177
+ *
178
+ * @return array
179
+ */
180
+ public function vvReturnResponse($post_id, $rating, $result_update_log) {
181
+ $row_exists = YasrDatabaseRatings::getVisitorVotes($post_id);
182
+
183
+ $user_votes_sum = $row_exists['sum_votes'];
184
+ $number_of_votes = $row_exists['number_of_votes'];
185
+
186
+ //customize visitor_votes cookie name
187
+ $cookiename = apply_filters('yasr_vv_cookie', 'yasr_visitor_vote_cookie');
188
+
189
+ $data_to_save = array(
190
+ 'post_id' => $post_id,
191
+ 'rating' => $rating
192
+ );
193
+
194
+ yasr_setcookie($cookiename, $data_to_save);
195
+
196
+ $total_rating = ($user_votes_sum / $number_of_votes);
197
+ $medium_rating = round($total_rating, 1);
198
+
199
+ //Default text when rating is saved
200
+ if ($result_update_log) {
201
+ $rating_saved_text = __('Rating Updated!', 'yet-another-stars-rating');
202
+ }
203
+ else {
204
+ $rating_saved_text = __('Rating Saved!', 'yet-another-stars-rating');
205
+ }
206
+
207
+ //Customize it
208
+ $rating_saved_text = wp_kses_post(apply_filters('yasr_vv_saved_text', $rating_saved_text));
209
+
210
+ $rating_saved_span = '<span class="yasr-small-block-bold" id="yasr-vote-saved">' . $rating_saved_text
211
+ . '</span>';
212
+
213
+ return array(
214
+ 'number_of_votes' => $number_of_votes,
215
+ 'average_rating' => $medium_rating,
216
+ 'rating_saved_text' => $rating_saved_span
217
+ );
218
+ }
219
+
220
+ /**
221
+ * Return response for Ajax and Rest API
222
+ *
223
+ * @author Dario Curvino <@dudo>
224
+ * @since moved in YasrShortcodeAjax since 2.7.7
225
+ * @return array
226
+ */
227
+ public static function returnArrayVisitorVotes() {
228
+ $post_id = false;
229
+ if (isset($_GET['post_id'])) {
230
+ $post_id = (int) $_GET['post_id'];
231
+ }
232
+
233
+ //default values
234
+ $array_to_return = array(
235
+ 'number_of_votes' => 0,
236
+ 'sum_votes' => 0,
237
+ 'stars_attributes' => array(
238
+ 'read_only' => true,
239
+ 'span_bottom' => false
240
+ )
241
+ );
242
+
243
+ $cookie_value = YasrVisitorVotes::checkCookie($post_id);
244
+ $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
245
+
246
+ //if user is enabled to rate, readonly must be false
247
+ if ($stars_enabled === 'true_logged' || $stars_enabled === 'true_not_logged') {
248
+ $array_to_return['stars_attributes']['read_only'] = false;
249
+ }
250
+
251
+ $array_to_return['stars_attributes']['span_bottom'] = YasrVisitorVotes::showTextBelowStars($cookie_value, $post_id);
252
+
253
+ $array_visitor_votes = YasrDatabaseRatings::getVisitorVotes($post_id);
254
+
255
+ $array_to_return['number_of_votes'] = $array_visitor_votes['number_of_votes'];
256
+ $array_to_return['sum_votes'] = $array_visitor_votes['sum_votes'];
257
+
258
+ //this means is an ajax call
259
+ if (isset($_GET['action']) && $_GET['action'] === 'yasr_load_vv' && isset($_GET['nonce_visitor'])) {
260
+ if (!wp_verify_nonce($_GET['nonce_visitor'], 'yasr_nonce_vv')) {
261
+ die('Security check');
262
+ }
263
+ $array_to_echo['yasr_visitor_votes'] = $array_to_return;
264
+ echo json_encode($array_to_echo);
265
+ die();
266
+ }
267
+
268
+ //return rest response
269
+ return $array_to_return;
270
+ }
271
+
272
+
273
+ /**
274
+ * Save or update rating for yasr_visitor_multiset
275
+ *
276
+ * @author Dario Curvino <@dudo>
277
+ * @since 2.7.7
278
+ */
279
+ public function saveMV() {
280
+ if (isset($_POST['post_id']) && isset($_POST['rating']) && isset($_POST['set_id'])) {
281
+ $post_id = (int) $_POST['post_id'];
282
+ $rating = $_POST['rating'];
283
+ $set_id = (int) $_POST['set_id'];
284
+ $nonce = $_POST['nonce'];
285
+
286
+ if (!is_int($post_id) || !is_int($set_id)) {
287
+ exit("Missing post id or set type");
288
+ }
289
+
290
+ if (!is_array($rating)) {
291
+ exit("Error with rating");
292
+ }
293
+ } else {
294
+ exit();
295
+ }
296
+
297
+ if (!wp_verify_nonce($nonce, 'yasr_nonce_insert_visitor_rating_multiset')) {
298
+ die('Security Check');
299
+ }
300
+
301
+ $current_user_id = get_current_user_id();
302
+ $ip_address = yasr_get_ip();
303
+
304
+ $array_action_visitor_multiset_vote = array('post_id' => $post_id);
305
+
306
+ do_action('yasr_action_on_visitor_multiset_vote', $array_action_visitor_multiset_vote);
307
+
308
+ $array_error = array();
309
+
310
+ //clean array, so if an user rate same field twice, take only the last rating
311
+ $cleaned_array = yasr_unique_multidim_array($rating, 'field');
312
+
313
+ //this is a counter: if at the end of the foreach it still 0, means that an user rated in a set
314
+ //and then submit another one
315
+ $counter_matched_fields = 0;
316
+
317
+ foreach ($cleaned_array as $rating_values) {
318
+ $rating_postid = (int)$rating_values['postid'];
319
+ $rating_setid = (int)$rating_values['setid'];
320
+
321
+ //check if the set id in the array is the same of the clicked
322
+ if ($rating_postid === $post_id && $rating_setid === $set_id) {
323
+ //increase the counter
324
+ $counter_matched_fields = $counter_matched_fields + 1;
325
+
326
+ $id_field = (int)$rating_values['field'];
327
+ $rating = $rating_values['rating'];
328
+
329
+ //if the user is logged
330
+ if(is_user_logged_in()) {
331
+ //first try to update the vote
332
+ $update_query_success = $this->mvUpdateRating ($id_field, $set_id, $post_id, $rating, $current_user_id, $ip_address);
333
+
334
+ //if the update fails
335
+ if (!$update_query_success) {
336
+ //insert as new rating
337
+ $insert_query_success = $this->mvSaveRating ($id_field, $set_id, $post_id, $rating, $current_user_id, $ip_address);
338
+ //if rating is not saved, it is an error
339
+ if (!$insert_query_success) {
340
+ $array_error[] = 1;
341
+ }
342
+ }
343
+ }
344
+ //else try to insert vote
345
+ else {
346
+ $replace_query_success = $this->mvSaveRating ($id_field, $set_id, $post_id, $rating, $current_user_id, $ip_address);
347
+ //if rating is not saved, it is an error
348
+ if (!$replace_query_success) {
349
+ $array_error[] = 1;
350
+ }
351
+ }
352
+ } //End if $rating_values['postid'] == $post_id
353
+
354
+ } //End foreach ($rating as $rating_values)
355
+
356
+ if ($counter_matched_fields === 0) {
357
+ $array_error[] = 1;
358
+ }
359
+
360
+ $error_found = false;
361
+
362
+ foreach ($array_error as $error) {
363
+ if ($error === 1) {
364
+ $error_found = true;
365
+ }
366
+ }
367
+
368
+ //echo response
369
+ echo $this->mvReturnResponse ($error_found, $post_id, $set_id);
370
+
371
+ die();
372
+
373
+ } //End callback function
374
+
375
+ /**
376
+ * Save rating for multi set visitor
377
+ *
378
+ * @author Dario Curvino <@dudo>
379
+ * @since 2.7.7
380
+ * @param $id_field
381
+ * @param $set_id
382
+ * @param $post_id
383
+ * @param $rating
384
+ * @param $user_id
385
+ * @param $ip_address
386
+ *
387
+ * @return bool|int
388
+ */
389
+ public function mvSaveRating ($id_field, $set_id, $post_id, $rating, $user_id, $ip_address) {
390
+ global $wpdb;
391
+
392
+ return $wpdb->replace(
393
+ YASR_LOG_MULTI_SET,
394
+ array(
395
+ 'field_id' => $id_field,
396
+ 'set_type' => $set_id,
397
+ 'post_id' => $post_id,
398
+ 'vote' => $rating,
399
+ 'user_id' => $user_id,
400
+ 'date' => date('Y-m-d H:i:s'),
401
+ 'ip' => $ip_address
402
+ ),
403
+ array("%d", "%d", "%d", "%d", "%d", "%s", "%s")
404
+ );
405
+ }
406
+
407
+ /**
408
+ * Update rating for multi set visitor
409
+ *
410
+ * @author Dario Curvino <@dudo>
411
+ * @since 2.7.7
412
+ * @param $id_field
413
+ * @param $set_id
414
+ * @param $post_id
415
+ * @param $rating
416
+ * @param $user_id
417
+ * @param $ip_address
418
+ *
419
+ * @return bool|int
420
+ */
421
+ public function mvUpdateRating ($id_field, $set_id, $post_id, $rating, $user_id, $ip_address) {
422
+ global $wpdb;
423
+
424
+ return $wpdb->update(
425
+ YASR_LOG_MULTI_SET,
426
+ array(
427
+ 'field_id' => $id_field,
428
+ 'set_type' => $set_id,
429
+ 'post_id' => $post_id,
430
+ 'vote' => $rating,
431
+ 'user_id' => $user_id,
432
+ 'date' => date( 'Y-m-d H:i:s' ),
433
+ 'ip' => $ip_address
434
+ ),
435
+ array(
436
+ 'field_id' => $id_field,
437
+ 'set_type' => $set_id,
438
+ 'post_id' => $post_id,
439
+ 'user_id' => $user_id
440
+ ),
441
+ array( "%d", "%d", "%d", "%d", "%d", "%s", "%s" ),
442
+ array( "%d", "%d", "%d", "%d" )
443
+ );
444
+ }
445
+
446
+ /**
447
+ * @author Dario Curvino <@dudo>
448
+ * @since 2.7.2
449
+ * @param $post_id
450
+ * @param $set_id
451
+ *
452
+ * @return string
453
+ */
454
+ public function mvReturnResponse ($error_found, $post_id, $set_id) {
455
+ if (!$error_found) {
456
+ $cookiename = apply_filters('yasr_mv_cookie', 'yasr_multi_visitor_cookie');
457
+
458
+ $data_to_save = array(
459
+ 'post_id' => $post_id,
460
+ 'set_id' => $set_id
461
+ );
462
+
463
+ yasr_setcookie($cookiename, $data_to_save);
464
+
465
+ $rating_saved_text = __('Rating Saved', 'yet-another-stars-rating');
466
+ return wp_kses_post(apply_filters('yasr_mv_saved_text', $rating_saved_text));
467
+ }
468
+
469
+ return(__('Rating not saved. Please Try again', 'yet-another-stars-rating'));
470
+
471
+ }
472
+
473
+ /**
474
+ * @author Dario Curvino <@dudo>
475
+ * @since 2.7.7
476
+ */
477
+ public function returnVVStats() {
478
+ if (isset($_POST['post_id']) && $_POST['post_id'] !== '') {
479
+ $post_id = (int) $_POST['post_id'];
480
+ }
481
+ else {
482
+ return;
483
+ }
484
+
485
+ $votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
486
+ $votes_number = $votes_array['number_of_votes'];
487
+
488
+ if ($votes_number !== 0) {
489
+ $medium_rating = ($votes_array['sum_votes'] / $votes_number);
490
+ }
491
+ else {
492
+ $medium_rating = 0;
493
+ }
494
+
495
+ $medium_rating = round($medium_rating, 1);
496
+ $missing_vote = null; //avoid undefined variable
497
+
498
+ global $wpdb;
499
+
500
+ //create an empty array
501
+ $existing_votes = array();
502
+
503
+ $stats = $wpdb->get_results(
504
+ $wpdb->prepare(
505
+ "SELECT ROUND(vote, 0) as vote,
506
+ COUNT(vote) as n_of_votes
507
+ FROM " . YASR_LOG_TABLE . "
508
+ WHERE post_id=%d
509
+ AND vote > 0
510
+ AND vote <= 5
511
+ GROUP BY vote
512
+ ORDER BY vote DESC
513
+ ", $post_id
514
+ ), ARRAY_A
515
+ );
516
+
517
+ $total_votes = 0; //Avoid undefined variable if stats exists. Necessary if $stats not exists
518
+
519
+ //if query return 0 write an empty array $existing_votes
520
+ if ($stats) {
521
+ //Write a new array with only existing votes, and count all the number of votes
522
+ foreach ($stats as $votes_array) {
523
+ $existing_votes[] = $votes_array['vote'];//Create an array with only existing votes
524
+ $total_votes = $total_votes + $votes_array['n_of_votes'];
525
+ }
526
+ }
527
+
528
+ for ($i = 1; $i <= 5; $i++) {
529
+ //If query return 0 write a new $stats array with index
530
+ if (!$stats) {
531
+ $stats[$i] = array();
532
+ $stats[$i]['vote'] = $i;
533
+ $stats[$i]['n_of_votes'] = 0;
534
+ }
535
+ else {
536
+ //If in the new array there are some vote missing create a new array
537
+ /** @noinspection TypeUnsafeArraySearchInspection */
538
+ if (!in_array($i, $existing_votes)) {
539
+ $missing_vote[$i] = array();
540
+ $missing_vote[$i]['vote'] = $i;
541
+ $missing_vote[$i]['n_of_votes'] = 0;
542
+ }
543
+ }
544
+ }
545
+
546
+ //If missing_vote exists merge it
547
+ if ($missing_vote) {
548
+ $stats = array_merge($stats, $missing_vote);
549
+ }
550
+
551
+ arsort($stats); //sort it by $votes[n_of_votes]
552
+
553
+ $html_to_return = '<div class="yasr-visitors-stats-tooltip">';
554
+ $html_to_return .= '<span id="yasr-medium-rating-tooltip">' . $medium_rating . ' ' . __(
555
+ 'out of 5 stars', 'yet-another-stars-rating'
556
+ ) . '</span>';
557
+ $html_to_return .= '<div class="yasr-progress-bars-container">';
558
+
559
+ if ($total_votes === 0) {
560
+ $increase_bar_value = 0;
561
+ }
562
+ else {
563
+ $increase_bar_value = 100 / $total_votes; //Find how much all the bars should increase per vote
564
+ }
565
+
566
+ $i = 5;
567
+
568
+ $stars_text = __('stars', 'yet-another-stars-rating');
569
+
570
+ foreach ($stats as $logged_votes) {
571
+
572
+ //cast int
573
+ $logged_votes['n_of_votes'] = (int) $logged_votes['n_of_votes'];
574
+
575
+ if ($i === 1) {
576
+ $stars_text = __('star', 'yet-another-stars-rating');
577
+ }
578
+
579
+ $value_progressbar = $increase_bar_value * $logged_votes['n_of_votes']; //value of the single bar
580
+ $value_progressbar = round($value_progressbar, 2) . '%'; //use only 2 decimal
581
+
582
+ $html_to_return .= "<div class='yasr-progress-bar-row-container yasr-w3-container'>
583
+ <div class='yasr-progress-bar-name'>$i $stars_text</div>
584
+ <div class='yasr-single-progress-bar-container'>
585
+ <div class='yasr-w3-border '>
586
+ <div class='yasr-w3-amber' style='height:17px;width:$value_progressbar'></div>
587
+ </div></div>
588
+ <div class='yasr-progress-bar-votes-count'>" . $logged_votes['n_of_votes'] . "</div><br />
589
+ </div>";
590
+
591
+ $i--;
592
+
593
+ //if there is a 0 rating in the database (only possible if manually added) break foreach
594
+ if ($i < 1) {
595
+ break;
596
+ }
597
+
598
+ } //End foreach
599
+
600
+ $html_to_return .= '</div></div>';
601
+ echo json_encode($html_to_return);
602
+
603
+ die();
604
+
605
+ }
606
+
607
+ }
includes/shortcodes/classes/YasrVisitorMultiSet.php CHANGED
@@ -41,7 +41,6 @@ class YasrVisitorMultiSet extends YasrMultiSet {
41
  * @return string
42
  */
43
  public function printVisitorMultiSet () {
44
-
45
  $ajax_nonce_visitor_multiset = wp_create_nonce("yasr_nonce_insert_visitor_rating_multiset");
46
 
47
  $this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
@@ -144,7 +143,6 @@ class YasrVisitorMultiSet extends YasrMultiSet {
144
  *
145
  */
146
  protected function multisetAttributes() {
147
-
148
  $this->checkCookie();
149
 
150
  $set_enabled = YasrShortcode::starsEnalbed($this->checkCookie());
41
  * @return string
42
  */
43
  public function printVisitorMultiSet () {
 
44
  $ajax_nonce_visitor_multiset = wp_create_nonce("yasr_nonce_insert_visitor_rating_multiset");
45
 
46
  $this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
143
  *
144
  */
145
  protected function multisetAttributes() {
 
146
  $this->checkCookie();
147
 
148
  $set_enabled = YasrShortcode::starsEnalbed($this->checkCookie());
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -41,9 +41,9 @@ class YasrVisitorVotes extends YasrShortcode {
41
  }
42
 
43
  $this->unique_id = str_shuffle(uniqid());
44
- $this->ajax_nonce_visitor = wp_create_nonce("yasr_nonce_insert_visitor_rating");
45
 
46
- $this->shortcode_html = '<!--Yasr Visitor Votes Shortcode-->';
47
  $this->shortcode_html .= "<div id='yasr_visitor_votes_$this->post_id' class='yasr-visitor-votes'>";
48
 
49
  }
@@ -87,15 +87,14 @@ class YasrVisitorVotes extends YasrShortcode {
87
 
88
  $stars_htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
89
  $this->shortcode_html .= "<div id='$stars_htmlid'
90
- class='yasr-rater-stars-vv'
91
- data-rater-postid='$this->post_id'
92
- data-rating='$average_rating'
93
- data-rater-starsize='".$this->starSize()."'
94
- data-rater-readonly='$this->readonly'
95
- data-rater-nonce='$this->ajax_nonce_visitor'
96
- data-issingular='$this->is_singular'
97
- data-cpt='$this->post_type'>
98
- </div>";
99
 
100
  $this->shortcode_html .= $this->containerAfterStars($number_of_votes, $average_rating);
101
  //loader div
@@ -129,8 +128,7 @@ class YasrVisitorVotes extends YasrShortcode {
129
  data-rater-starsize='".$this->starSize()."'
130
  data-rater-postid='$this->post_id'
131
  data-rater-readonly='true'
132
- data-readonly-attribute='true'
133
- data-cpt='$this->post_type'
134
  ></div>";
135
 
136
  $end_container = '</div>'; //close yasr-vv-stars-stats-container
@@ -201,7 +199,7 @@ class YasrVisitorVotes extends YasrShortcode {
201
  public static function showTextBelowStars ($cookie_value, $post_id=false) {
202
 
203
  $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
204
- $div_bottom_line = false;
205
  $span_bottom_line_content = false;
206
 
207
  if ($stars_enabled === 'true_logged' || $stars_enabled === 'false_already_voted') {
@@ -224,14 +222,13 @@ class YasrVisitorVotes extends YasrShortcode {
224
  //if rating is not false, show the text after the stars
225
  if($rating) {
226
  $default_text = __('You\'ve already voted this article with ', 'yet-another-stars-rating') . $rating;
227
- $custom_text = apply_filters('yasr_cstm_text_already_voted', $default_text, $rating);
228
  } else {
229
  $custom_text = '';
230
  }
231
 
232
  $span_bottom_line_content .= ($custom_text);
233
  $span_bottom_line_content .= '</span>';
234
-
235
  }
236
 
237
  //If only logged in users can vote
@@ -326,7 +323,7 @@ class YasrVisitorVotes extends YasrShortcode {
326
  public function visitorStats () {
327
  global $yasr_plugin_imported;
328
 
329
- $span_dashicon = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"
330
  class="yasr-dashicons-visitor-stats"
331
  data-postid="'.$this->post_id.'"
332
  id="yasr-stats-dashicon-'.$this->unique_id.'">
41
  }
42
 
43
  $this->unique_id = str_shuffle(uniqid());
44
+ $this->ajax_nonce_visitor = wp_create_nonce("yasr_nonce_vv");
45
 
46
+ $this->shortcode_html = '<!--Yasr Visitor Votes Shortcode-->';
47
  $this->shortcode_html .= "<div id='yasr_visitor_votes_$this->post_id' class='yasr-visitor-votes'>";
48
 
49
  }
87
 
88
  $stars_htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
89
  $this->shortcode_html .= "<div id='$stars_htmlid'
90
+ class='yasr-rater-stars-vv'
91
+ data-rater-postid='$this->post_id'
92
+ data-rating='$average_rating'
93
+ data-rater-starsize='".$this->starSize()."'
94
+ data-rater-readonly='$this->readonly'
95
+ data-rater-nonce='$this->ajax_nonce_visitor'
96
+ data-issingular='$this->is_singular'
97
+ ></div>";
 
98
 
99
  $this->shortcode_html .= $this->containerAfterStars($number_of_votes, $average_rating);
100
  //loader div
128
  data-rater-starsize='".$this->starSize()."'
129
  data-rater-postid='$this->post_id'
130
  data-rater-readonly='true'
131
+ data-readonly-attribute='true'
 
132
  ></div>";
133
 
134
  $end_container = '</div>'; //close yasr-vv-stars-stats-container
199
  public static function showTextBelowStars ($cookie_value, $post_id=false) {
200
 
201
  $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
202
+ $div_bottom_line = false;
203
  $span_bottom_line_content = false;
204
 
205
  if ($stars_enabled === 'true_logged' || $stars_enabled === 'false_already_voted') {
222
  //if rating is not false, show the text after the stars
223
  if($rating) {
224
  $default_text = __('You\'ve already voted this article with ', 'yet-another-stars-rating') . $rating;
225
+ $custom_text = wp_kses_post(apply_filters('yasr_cstm_text_already_voted', $default_text, $rating));
226
  } else {
227
  $custom_text = '';
228
  }
229
 
230
  $span_bottom_line_content .= ($custom_text);
231
  $span_bottom_line_content .= '</span>';
 
232
  }
233
 
234
  //If only logged in users can vote
323
  public function visitorStats () {
324
  global $yasr_plugin_imported;
325
 
326
+ $span_dashicon = '<svg xmlns="https://www.w3.org/2000/svg" width="20" height="20"
327
  class="yasr-dashicons-visitor-stats"
328
  data-postid="'.$this->post_id.'"
329
  id="yasr-stats-dashicon-'.$this->unique_id.'">
includes/shortcodes/yasr-shortcode-ajax.php DELETED
@@ -1,460 +0,0 @@
1
- <?php
2
- /*
3
-
4
- Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU General Public License as published by
8
- the Free Software Foundation, either version 2 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU General Public License for more details.
15
-
16
- You should have received a copy of the GNU General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>
18
- */
19
-
20
- if ( ! defined( 'ABSPATH' ) ) {
21
- exit( 'You\'re not allowed to see this page' );
22
- } // Exit if accessed directly
23
-
24
-
25
- /****** Yasr insert visitor votes, called from yasr-shortcode-function ******/
26
- add_action('wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback');
27
- add_action('wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback');
28
-
29
- /**
30
- * Save yasr_visitor_votes
31
- */
32
- function yasr_insert_visitor_votes_callback() {
33
-
34
- if (isset($_POST['rating'], $_POST['post_id'], $_POST['nonce_visitor'])) {
35
- $rating = (int) $_POST['rating'];
36
- $post_id = (int) $_POST['post_id'];
37
- $nonce_visitor = $_POST['nonce_visitor'];
38
- $is_singular = $_POST['is_singular'];
39
-
40
- } else {
41
- die();
42
- }
43
-
44
- $array_action_visitor_vote = array('post_id' => $post_id, 'is_singular' => $is_singular);
45
-
46
- do_action('yasr_action_on_visitor_vote', $array_action_visitor_vote);
47
-
48
- if (!wp_verify_nonce($nonce_visitor, 'yasr_nonce_insert_visitor_rating')) {
49
- die('Security check');
50
- }
51
-
52
- if ($rating < 1) {
53
- $rating = 1;
54
- } elseif ($rating > 5) {
55
- $rating = 5;
56
- }
57
-
58
- global $wpdb;
59
-
60
- $current_user = wp_get_current_user();
61
- $ip_adress = yasr_get_ip();
62
-
63
- $result_update_log = null; //avoid undefined
64
- $result_insert_log = null; //avoid undefined
65
-
66
- if (is_user_logged_in()) {
67
-
68
- //try to update first, if fails the do the insert
69
- $result_update_log = $wpdb->update(
70
- YASR_LOG_TABLE,
71
- array(
72
- 'post_id' => $post_id,
73
- 'user_id' => $current_user->ID,
74
- 'vote' => $rating,
75
- 'date' => date('Y-m-d H:i:s'),
76
- 'ip' => $ip_adress
77
- ),
78
- array(
79
- 'post_id' => $post_id,
80
- 'user_id' => $current_user->ID
81
- ),
82
- array('%d', '%d', '%d', '%s', '%s', '%s'),
83
- array('%d', '%d')
84
-
85
- );
86
-
87
- //insert the new row
88
- //use ! instead of === FALSE
89
- if (!$result_update_log) {
90
- $result_insert_log = $wpdb->insert(
91
- YASR_LOG_TABLE,
92
- array(
93
- 'post_id' => $post_id,
94
- 'user_id' => $current_user->ID,
95
- 'vote' => $rating,
96
- 'date' => date('Y-m-d H:i:s'),
97
- 'ip' => $ip_adress
98
- ),
99
- array('%d', '%d', '%d', '%s', '%s', '%s')
100
- );
101
- }
102
-
103
- } //if user is not logged in insert
104
- else {
105
- //be sure that allow anonymous is on
106
- if (YASR_ALLOWED_USER === 'allow_anonymous') {
107
- $result_insert_log = $wpdb->replace(
108
- YASR_LOG_TABLE,
109
- array(
110
- 'post_id' => $post_id,
111
- 'user_id' => $current_user->ID,
112
- 'vote' => $rating,
113
- 'date' => date('Y-m-d H:i:s'),
114
- 'ip' => $ip_adress
115
- ),
116
-
117
- array('%d', '%d', '%d', '%s', '%s', '%s')
118
- );
119
- }
120
-
121
- }
122
-
123
- if ($result_update_log || $result_insert_log) {
124
- $row_exists = YasrDatabaseRatings::getVisitorVotes($post_id);
125
-
126
- $user_votes_sum = $row_exists['sum_votes'];
127
- $number_of_votes = $row_exists['number_of_votes'];
128
-
129
- //customize visitor_votes cookie name
130
- $cookiename = apply_filters('yasr_vv_cookie', 'yasr_visitor_vote_cookie');
131
-
132
- $data_to_save = array(
133
- 'post_id' => $post_id,
134
- 'rating' => $rating
135
- );
136
-
137
- yasr_setcookie($cookiename, $data_to_save);
138
-
139
- $total_rating = ($user_votes_sum / $number_of_votes);
140
- $medium_rating = round($total_rating, 1);
141
-
142
- //Default text when rating is saved
143
- if($result_update_log) {
144
- $rating_saved_text = __('Rating Updated!', 'yet-another-stars-rating');
145
- } else {
146
- $rating_saved_text = __('Rating Saved!', 'yet-another-stars-rating');
147
- }
148
-
149
- //Customize it
150
- $rating_saved_text = wp_kses_post(apply_filters('yasr_vv_saved_text', $rating_saved_text));
151
-
152
- $rating_saved_span = '<span class="yasr-small-block-bold" id="yasr-vote-saved">'
153
- . $rating_saved_text .
154
- '</span>';
155
-
156
- $array_to_return = array(
157
- 'number_of_votes' => $number_of_votes,
158
- 'average_rating' => $medium_rating,
159
- 'rating_saved_text' => $rating_saved_span
160
- );
161
-
162
- echo json_encode($array_to_return);
163
-
164
- }
165
-
166
- die(); // this is required to return a proper result
167
-
168
- }
169
-
170
- /****** Get Multiple value from visitor and insert into db, used in yasr-shortcode-functions ******/
171
-
172
- add_action('wp_ajax_yasr_visitor_multiset_field_vote', 'yasr_visitor_multiset_field_vote_callback');
173
- add_action('wp_ajax_nopriv_yasr_visitor_multiset_field_vote', 'yasr_visitor_multiset_field_vote_callback');
174
-
175
- function yasr_visitor_multiset_field_vote_callback() {
176
-
177
- if (isset($_POST['post_id']) && isset($_POST['rating']) && isset($_POST['set_type'])) {
178
- $post_id = (int) $_POST['post_id'];
179
- $rating = $_POST['rating'];
180
- $set_type = (int) $_POST['set_type'];
181
- $nonce = $_POST['nonce'];
182
-
183
- if (!is_int($post_id) || !is_int($set_type)) {
184
- exit("Missing post id or set type");
185
- }
186
-
187
- if ($rating == "") {
188
- exit("You must insert at least a rating");
189
- }
190
-
191
- } else {
192
- exit();
193
- }
194
-
195
- if (!wp_verify_nonce($nonce, 'yasr_nonce_insert_visitor_rating_multiset')) {
196
- die('Security Check');
197
- }
198
-
199
- $current_user = wp_get_current_user();
200
- $ip_adress = yasr_get_ip();
201
-
202
- $array_action_visitor_multiset_vote = array('post_id' => $post_id);
203
-
204
- do_action('yasr_action_on_visitor_multiset_vote', $array_action_visitor_multiset_vote);
205
-
206
- global $wpdb;
207
-
208
- $array_error = array();
209
-
210
- //clean array, so if an user rate same field twice, take only the last rating
211
- $cleaned_array = yasr_unique_multidim_array($rating, 'field');
212
-
213
- //this is a counter: if at the end of the foreach it still 0, means that an user rated in a set
214
- //and then submit another one
215
- $counter_matched_fields = 0;
216
-
217
- foreach ($cleaned_array as $rating_values) {
218
-
219
- //check if the set id in the array is the same of the clicked
220
- if ($rating_values['postid'] == $post_id && $rating_values['setid'] == $set_type) {
221
-
222
- //increase the counter
223
- $counter_matched_fields = $counter_matched_fields + 1;
224
-
225
- $id_field = (int)$rating_values['field'];
226
- $rating = $rating_values['rating'];
227
-
228
- if(is_user_logged_in()) {
229
- $update_query_success = $wpdb->update(
230
- YASR_LOG_MULTI_SET,
231
- array(
232
- 'field_id' => $id_field,
233
- 'set_type' => $set_type,
234
- 'post_id' => $post_id,
235
- 'vote' => $rating,
236
- 'user_id' => $current_user->ID,
237
- 'date' => date( 'Y-m-d H:i:s' ),
238
- 'ip' => $ip_adress
239
-
240
- ),
241
- array(
242
- 'field_id' => $id_field,
243
- 'set_type' => $set_type,
244
- 'post_id' => $post_id,
245
- 'user_id' => $current_user->ID
246
- ),
247
- array( "%d", "%d", "%d", "%d", "%d", "%s", "%s" ),
248
- array( "%d", "%d", "%d", "%d" )
249
- );
250
-
251
- if (!$update_query_success) {
252
- $insert_query_success = $wpdb->insert(
253
- YASR_LOG_MULTI_SET,
254
- array(
255
- 'field_id' => $id_field,
256
- 'set_type' => $set_type,
257
- 'post_id' => $post_id,
258
- 'vote' => $rating,
259
- 'user_id' => $current_user->ID,
260
- 'date' => date('Y-m-d H:i:s'),
261
- 'ip' => $ip_adress
262
- ),
263
- array("%d", "%d", "%d", "%d", "%d", "%s", "%s")
264
- );
265
-
266
- if (!$insert_query_success) {
267
- $array_error[] = 1;
268
- }
269
- }
270
-
271
- } else {
272
- $replace_query_success = $wpdb->replace(
273
- YASR_LOG_MULTI_SET,
274
- array(
275
- 'field_id' => $id_field,
276
- 'set_type' => $set_type,
277
- 'post_id' => $post_id,
278
- 'vote' => $rating,
279
- 'user_id' => $current_user->ID,
280
- 'date' => date('Y-m-d H:i:s'),
281
- 'ip' => $ip_adress
282
- ),
283
- array("%d", "%d", "%d", "%d", "%d", "%s", "%s")
284
- );
285
-
286
- if (!$replace_query_success) {
287
- $array_error[] = 1;
288
- }
289
- }
290
-
291
- } //End if $rating_values['postid'] == $post_id
292
-
293
- } //End foreach ($rating as $rating_values)
294
-
295
- if ($counter_matched_fields === 0) {
296
- $array_error[] = 1;
297
- }
298
-
299
- $error_found = false;
300
-
301
- foreach ($array_error as $error) {
302
- if ($error === 1) {
303
- $error_found = true;
304
- }
305
- }
306
-
307
- if (!$error_found) {
308
- $cookiename = apply_filters('yasr_mv_cookie', 'yasr_multi_visitor_cookie');
309
-
310
- $data_to_save = array(
311
- 'post_id' => $post_id,
312
- 'set_id' => $set_type
313
- );
314
-
315
- yasr_setcookie($cookiename, $data_to_save);
316
-
317
- $rating_saved_text = __('Rating Saved', 'yet-another-stars-rating');
318
- $rating_saved_text = wp_kses_post(apply_filters('yasr_mv_saved_text', $rating_saved_text));
319
-
320
- echo $rating_saved_text;
321
-
322
- } else {
323
- _e('Rating not saved. Please Try again', 'yet-another-stars-rating');
324
- }
325
-
326
- die();
327
-
328
- } //End callback function
329
-
330
-
331
- add_action('wp_ajax_yasr_stats_visitors_votes', 'yasr_stats_visitors_votes_callback');
332
- add_action('wp_ajax_nopriv_yasr_stats_visitors_votes', 'yasr_stats_visitors_votes_callback');
333
-
334
- function yasr_stats_visitors_votes_callback() {
335
-
336
- if (isset($_POST['post_id']) && $_POST['post_id'] !== '') {
337
- $post_id = (int)$_POST['post_id'];
338
- } else {
339
- return;
340
- }
341
-
342
- $votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
343
- $votes_number = $votes_array['number_of_votes'];
344
-
345
- if ($votes_number !== 0) {
346
- $medium_rating = ($votes_array['sum_votes'] / $votes_number);
347
- } else {
348
- $medium_rating = 0;
349
- }
350
-
351
- $medium_rating = round($medium_rating, 1);
352
- $missing_vote = null; //avoid undefined variable
353
-
354
- global $wpdb;
355
-
356
- //create an empty array
357
- $existing_votes = array();
358
-
359
- $stats = $wpdb->get_results(
360
- $wpdb->prepare(
361
- "SELECT ROUND(vote, 0) as vote,
362
- COUNT(vote) as n_of_votes
363
- FROM " . YASR_LOG_TABLE . "
364
- WHERE post_id=%d
365
- AND vote > 0
366
- AND vote <= 5
367
- GROUP BY vote
368
- ORDER BY vote DESC
369
- ",
370
- $post_id
371
- ),
372
- ARRAY_A);
373
-
374
- $total_votes = 0; //Avoid undefined variable if stats exists. Necessary if $stats not exists
375
-
376
- //if query return 0 write an empty array $existing_votes
377
- if ($stats) {
378
- //Write a new array with only existing votes, and count all the number of votes
379
- foreach ($stats as $votes_array) {
380
- $existing_votes[] = $votes_array['vote'];//Create an array with only existing votes
381
- $total_votes = $total_votes + $votes_array['n_of_votes'];
382
- }
383
- }
384
-
385
- for ($i = 1; $i <= 5; $i ++) {
386
- //If query return 0 write a new $stats array with index
387
- if (!$stats) {
388
- $stats[$i] = array();
389
- $stats[$i]['vote'] = $i;
390
- $stats[$i]['n_of_votes'] = 0;
391
- } else {
392
- //If in the new array there are some vote missing create a new array
393
- /** @noinspection TypeUnsafeArraySearchInspection */
394
- if (!in_array($i, $existing_votes)) {
395
- $missing_vote[$i] = array();
396
- $missing_vote[$i]['vote'] = $i;
397
- $missing_vote[$i]['n_of_votes'] = 0;
398
- }
399
- }
400
- }
401
-
402
- //If missing_vote exists merge it
403
- if ($missing_vote) {
404
- $stats = array_merge($stats, $missing_vote);
405
- }
406
-
407
- arsort($stats); //sort it by $votes[n_of_votes]
408
-
409
- $html_to_return = '<div class="yasr-visitors-stats-tooltip">';
410
- $html_to_return .= '<span id="yasr-medium-rating-tooltip">' . $medium_rating . ' '
411
- . __('out of 5 stars', 'yet-another-stars-rating') .
412
- '</span>';
413
- $html_to_return .= '<div class="yasr-progress-bars-container">';
414
-
415
- if ($total_votes === 0) {
416
- $increase_bar_value = 0;
417
- } else {
418
- $increase_bar_value = 100 / $total_votes; //Find how much all the bars should increase per vote
419
- }
420
-
421
- $i = 5;
422
-
423
- $stars_text = __('stars', 'yet-another-stars-rating');
424
-
425
- foreach ($stats as $logged_votes) {
426
-
427
- //cast int
428
- $logged_votes['n_of_votes'] = (int)$logged_votes['n_of_votes'];
429
-
430
- if ($i === 1) {
431
- $stars_text = __('star', 'yet-another-stars-rating');
432
- }
433
-
434
- $value_progressbar = $increase_bar_value * $logged_votes['n_of_votes']; //value of the single bar
435
- $value_progressbar = round($value_progressbar, 2) . '%'; //use only 2 decimal
436
-
437
- $html_to_return .= "<div class='yasr-progress-bar-row-container yasr-w3-container'>
438
- <div class='yasr-progress-bar-name'>$i $stars_text</div>
439
- <div class='yasr-single-progress-bar-container'>
440
- <div class='yasr-w3-border '>
441
- <div class='yasr-w3-amber' style='height:17px;width:$value_progressbar'></div>
442
- </div></div>
443
- <div class='yasr-progress-bar-votes-count'>" . $logged_votes['n_of_votes'] . "</div><br />
444
- </div>";
445
-
446
- $i --;
447
-
448
- //if there is a 0 rating in the database (only possible if manually added) break foreach
449
- if ($i < 1) {
450
- break;
451
- }
452
-
453
- } //End foreach
454
-
455
- $html_to_return .= '</div></div>';
456
- echo json_encode($html_to_return);
457
-
458
- die();
459
-
460
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/shortcodes/yasr-shortcode-functions.php CHANGED
@@ -46,9 +46,6 @@ function yasr_autoload_shortcodes($class) {
46
  //AutoLoad YASR Shortcode Classes, only when a object is created
47
  spl_autoload_register('yasr_autoload_shortcodes');
48
 
49
- require YASR_ABSOLUTE_PATH_INCLUDES . '/shortcodes/yasr-shortcode-ajax.php';
50
-
51
-
52
  /****** Add shortcode for overall rating ******/
53
  add_shortcode('yasr_overall_rating', 'shortcode_overall_rating_callback');
54
 
46
  //AutoLoad YASR Shortcode Classes, only when a object is created
47
  spl_autoload_register('yasr_autoload_shortcodes');
48
 
 
 
 
49
  /****** Add shortcode for overall rating ******/
50
  add_shortcode('yasr_overall_rating', 'shortcode_overall_rating_callback');
51
 
includes/yasr-includes-init.php CHANGED
@@ -64,7 +64,7 @@ function yasr_autoload_includes_classes($class) {
64
  spl_autoload_register('yasr_autoload_includes_classes');
65
 
66
  require YASR_ABSOLUTE_PATH_INCLUDES . '/shortcodes/yasr-shortcode-functions.php';
67
- require YASR_ABSOLUTE_PATH_INCLUDES . '/rest/yasr-rest.php';
68
 
69
  /****** Getting options ******/
70
  //Get general options
@@ -302,4 +302,10 @@ $yasr_includes_filter = new YasrIncludesFilters();
302
  $yasr_includes_filter->filterCustomTexts($yasr_stored_options);
303
 
304
  //support for caching plugins
305
- $yasr_includes_filter->cachingPluginSupport();
 
 
 
 
 
 
64
  spl_autoload_register('yasr_autoload_includes_classes');
65
 
66
  require YASR_ABSOLUTE_PATH_INCLUDES . '/shortcodes/yasr-shortcode-functions.php';
67
+
68
 
69
  /****** Getting options ******/
70
  //Get general options
302
  $yasr_includes_filter->filterCustomTexts($yasr_stored_options);
303
 
304
  //support for caching plugins
305
+ $yasr_includes_filter->cachingPluginSupport();
306
+
307
+ $init_ajax = new YasrShortcodesAjax();
308
+ $init_ajax->init();
309
+
310
+ //Load rest API
311
+ require YASR_ABSOLUTE_PATH_INCLUDES . '/rest/yasr-rest.php';
includes/yasr-widgets.php CHANGED
@@ -37,7 +37,7 @@ class Yasr_Overall_Rating_Widget extends WP_Widget {
37
  /**
38
  * Register widget with WordPress.
39
  */
40
- function __construct() {
41
  parent::__construct(
42
  'yasr_overall_rating_widget', // Base ID
43
  __('Yasr Overall Rating', 'yet-another-stars-rating'), // Name
@@ -193,7 +193,7 @@ class Yasr_Visitor_Votes_Widget extends WP_Widget {
193
  /**
194
  * Register widget with WordPress.
195
  */
196
- function __construct() {
197
 
198
  parent::__construct(
199
  'yasr_visitor_votes_widget', // Base ID
@@ -376,7 +376,7 @@ class Yasr_Recent_Ratings_Widget extends WP_Widget {
376
  /**
377
  * Register widget with WordPress.
378
  */
379
- function __construct() {
380
 
381
  parent::__construct(
382
  'yasr_recent_ratings_widget', // Base ID
37
  /**
38
  * Register widget with WordPress.
39
  */
40
+ public function __construct() {
41
  parent::__construct(
42
  'yasr_overall_rating_widget', // Base ID
43
  __('Yasr Overall Rating', 'yet-another-stars-rating'), // Name
193
  /**
194
  * Register widget with WordPress.
195
  */
196
+ public function __construct() {
197
 
198
  parent::__construct(
199
  'yasr_visitor_votes_widget', // Base ID
376
  /**
377
  * Register widget with WordPress.
378
  */
379
+ public function __construct() {
380
 
381
  parent::__construct(
382
  'yasr_recent_ratings_widget', // Base ID
public/classes/YasrPublicFilters.php CHANGED
@@ -443,7 +443,6 @@ class YasrPublicFilters {
443
 
444
  $average_rating = round($average_rating, 1);
445
  $htmlid = 'yasr-visitor-votes-readonly-rater-' . str_shuffle(uniqid());
446
- $post_type = YasrCustomPostTypes::returnBaseUrl($post_id);
447
 
448
  $vv_widget = "<div class='yasr-stars-title yasr-rater-stars-vv'
449
  id='$htmlid'
@@ -452,7 +451,6 @@ class YasrPublicFilters {
452
  data-rater-postid='$post_id'
453
  data-rater-readonly='true'
454
  data-readonly-attribute='true'
455
- data-cpt='$post_type'
456
  ></div>";
457
 
458
  $vv_widget .= "<span class='yasr-stars-title-average'>$average_rating ($number_of_votes)</span>";
443
 
444
  $average_rating = round($average_rating, 1);
445
  $htmlid = 'yasr-visitor-votes-readonly-rater-' . str_shuffle(uniqid());
 
446
 
447
  $vv_widget = "<div class='yasr-stars-title yasr-rater-stars-vv'
448
  id='$htmlid'
451
  data-rater-postid='$post_id'
452
  data-rater-readonly='true'
453
  data-readonly-attribute='true'
 
454
  ></div>";
455
 
456
  $vv_widget .= "<span class='yasr-stars-title-average'>$average_rating ($number_of_votes)</span>";
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.7.2
7
  Requires PHP: 5.4
8
- Stable tag: 2.7.6
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
@@ -108,7 +108,6 @@ More info [here](https://wordpress.org/plugins/yet-another-stars-rating/faq/)
108
  = New videos, talked in Italian but easily to understand (eng subs will comes) =
109
  [Tutorial's playlist](https://www.youtube.com/playlist?list=PLFErQFOLUVMcx8Qb9--KKme3bQ_KGri71)
110
 
111
-
112
  == Developers ==
113
  While YASR - Yet Another Stars Rating does not require any coding, it is developer friendly!
114
  It is the first (and for now only) rating plugin that uses REST API.
@@ -192,6 +191,11 @@ If doesn't, you should work on your seo reputation.
192
 
193
  The full changelog can be found in the plugin's directory. Recent entries:
194
 
 
 
 
 
 
195
  = 2.7.6 =
196
  * TWEAKED: new pricing page
197
  * Minor changes
5
  Contributors: Dudo
6
  Tested up to: 5.7.2
7
  Requires PHP: 5.4
8
+ Stable tag: 2.7.7
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
108
  = New videos, talked in Italian but easily to understand (eng subs will comes) =
109
  [Tutorial's playlist](https://www.youtube.com/playlist?list=PLFErQFOLUVMcx8Qb9--KKme3bQ_KGri71)
110
 
 
111
  == Developers ==
112
  While YASR - Yet Another Stars Rating does not require any coding, it is developer friendly!
113
  It is the first (and for now only) rating plugin that uses REST API.
191
 
192
  The full changelog can be found in the plugin's directory. Recent entries:
193
 
194
+ = 2.7.7 =
195
+ * TWEAKED: When "Load results with AJAX? " is enabled, data is loaded through admin-ajax.php instead of REST API.
196
+ * TWEAKED: most of caching plugins are automatically detected: if one is found, "load results with ajax" is enabled by default.
197
+ * Minor changes
198
+
199
  = 2.7.6 =
200
  * TWEAKED: new pricing page
201
  * Minor changes
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.6
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.6' );
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.7.7
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.7.7' );
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__ );