Yasr – Yet Another Stars Rating - Version 2.7.9

Version Description

  • FIXED: missing stats in some circumstances for yasr_visitor_votes shortcode
Download this release

Release Info

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

Code changes from version 2.7.8 to 2.7.9

admin/editor/YasrOnSavePost.php CHANGED
@@ -257,10 +257,10 @@ class YasrOnSavePost {
257
  //this mean there we're not in the classic editor
258
  if (!isset($_POST['yasr_nonce_auto_insert'])) {
259
  return;
260
- } else {
261
- $nonce = $_POST['yasr_nonce_auto_insert'];
262
  }
263
 
 
 
264
  if (!wp_verify_nonce($nonce, 'yasr_nonce_auto_insert_action')) {
265
  return;
266
  }
257
  //this mean there we're not in the classic editor
258
  if (!isset($_POST['yasr_nonce_auto_insert'])) {
259
  return;
 
 
260
  }
261
 
262
+ $nonce = $_POST['yasr_nonce_auto_insert'];
263
+
264
  if (!wp_verify_nonce($nonce, 'yasr_nonce_auto_insert_action')) {
265
  return;
266
  }
admin/js/src/yasr-pricing-page.js CHANGED
@@ -53,8 +53,21 @@ function YasrPricingPrintFeatures(props) {
53
  }
54
  return (
55
  <ul className="PT-Features">
56
- <li className="yasr-pricing-table-feature"><strong>1 year</strong> of supports and updates <br/>for
57
- <strong>{numberOfSites}</strong></li>
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  <li className="yasr-pricing-table-feature">User reviews</li>
59
  <li className="yasr-pricing-table-feature">Custom rankings</li>
60
  <li className="yasr-pricing-table-feature">20 + ready to use themes</li>
53
  }
54
  return (
55
  <ul className="PT-Features">
56
+ {props.cycle === 'annual' && (
57
+ <li className="yasr-pricing-table-feature"><strong>1 year</strong> of supports and updates <br/>for
58
+ <strong>{numberOfSites}</strong>
59
+ </li>
60
+ )}
61
+ {props.cycle === 'monthly' && (
62
+ <li className="yasr-pricing-table-feature"><strong>1 month</strong> of supports and updates <br/>for
63
+ <strong>{numberOfSites}</strong>
64
+ </li>
65
+ )}
66
+ {props.cycle === 'lifetime' && (
67
+ <li className="yasr-pricing-table-feature"><strong>Lifetime</strong> updates and support<br/>for
68
+ <strong>{numberOfSites}</strong>
69
+ </li>
70
+ )}
71
  <li className="yasr-pricing-table-feature">User reviews</li>
72
  <li className="yasr-pricing-table-feature">Custom rankings</li>
73
  <li className="yasr-pricing-table-feature">20 + ready to use themes</li>
admin/js/src/yasr-settings-rankings.js CHANGED
@@ -15,6 +15,10 @@ if (activeTab === 'rankings') {
15
  jQuery(elementsClassParents).prop('disabled', true); //disable all parents elements;
16
  jQuery(elementsClassChilds).prop('disabled', true); //disable all childs elements;
17
 
 
 
 
 
18
  //add action in yasr-settings-page
19
  wp.hooks.doAction('yasrBuilderBegin', elementsClassParents, elementsClassChilds);
20
 
@@ -36,8 +40,10 @@ if (activeTab === 'rankings') {
36
  //This is the select for data Source
37
  const selectDataSource = document.getElementById('yasr-ranking-source');
38
  const selectMultiset = document.getElementById('yasr-ranking-multiset-select');
 
 
39
 
40
- //Ranking attributes
41
  const divParamsContainer = document.getElementById('yasr-builder-params-container');
42
  const divView = document.getElementById('builder-vv-default-view');
43
  const divVotes = document.getElementById('builder-vv-required-votes');
@@ -47,60 +53,69 @@ if (activeTab === 'rankings') {
47
  const divCategory = document.getElementById('builder-category');
48
  const divCpt = document.getElementById('builder-cpt');
49
  const divMultiSet = document.getElementById('yasr-ranking-multiset');
 
50
 
51
  let dataSource = selectDataSource.value;
52
  let previewClicked = false;
53
 
 
 
 
 
54
  //if on page load is selected something else from the default ranking (yasr_most_or_highest_rated_posts)
55
  //show the proper fields
56
  if(dataSource === 'yasr_ov_ranking' ) {
57
- yasrBuilderOvOptions(divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
58
  }
59
  else if(dataSource === 'yasr_most_active_users' || dataSource === 'yasr_top_reviewers') {
60
- yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
61
  }
62
  else if(dataSource === 'yasr_multi_set_ranking') {
63
- yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, false);
64
  }
65
  else if(dataSource === 'yasr_visitor_multi_set_ranking') {
66
- yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, true);
67
  }
68
  else {
69
- yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet)
70
  }
71
 
72
  //event listener for all change events
73
  document.addEventListener('change', event => {
74
  if(event.target.id === 'yasr-ranking-source') {
75
-
76
  //be sure to reset the class of the container to the default one
77
  divParamsContainer.className = '';
78
  divParamsContainer.classList.add('yasr-settings-row-33');
79
 
80
  //when event is on main select, be sure the preview div is empty
81
  previewDiv.innerHTML = '';
 
 
 
 
 
82
  //reset attributes
83
  shortcodeAttributes = yasrReturnShortcodeAttributes();
84
 
85
  if(event.target.value === 'yasr_ov_ranking') {
86
- yasrBuilderOvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
87
  }
88
  else if(event.target.value === 'yasr_most_active_users' || event.target.value === 'yasr_top_reviewers') {
89
- yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
90
  }
91
  else if(event.target.value === 'yasr_multi_set_ranking') {
92
- yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, false);
93
  //get the value of the first option(array key 0) in the select
94
  shortcodeAttributes['setid'] = ' setid='+selectMultiset[0].value;
95
  }
96
  else if(event.target.value === 'yasr_visitor_multi_set_ranking') {
97
- yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, true);
98
  //get the value of the first option(array key 0) in the select
99
  shortcodeAttributes['setid'] = ' setid='+selectMultiset[0].value;
100
  }
101
  //By default, show setting for yasr_most_or_highest_rated_posts
102
  else {
103
- yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet)
104
  }
105
 
106
  //be sure shortcodeAttributes is initialized again
@@ -133,6 +148,8 @@ if (activeTab === 'rankings') {
133
  shortcodeAttributes['txtPosition']+
134
  shortcodeAttributes['txt']+
135
  shortcodeAttributes['display']+
 
 
136
  shortcodeAttributes['category']+
137
  shortcodeAttributes['cpt'];
138
 
@@ -232,6 +249,8 @@ if (activeTab === 'rankings') {
232
  txtPosition: '',
233
  txt: '',
234
  display: '',
 
 
235
  category: '',
236
  cpt: ''
237
  };
@@ -247,25 +266,24 @@ if (activeTab === 'rankings') {
247
  * @param divCategory
248
  * @param divCpt
249
  * @param divMultiSet
 
250
  */
251
- function yasrBuilderOvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
252
- //Here the div must not be 33 but 24
253
- divParamsContainer.className = '';
254
- divParamsContainer.classList.add('yasr-settings-row-24');
255
-
256
- //show custom text for overall
257
- divOverallTxt.style.display = '';
258
- divSize.style.display = '';
259
- divCategory.style.display = '';
260
- divView.style.display = 'none';
261
- divVotes.style.display = 'none';
262
- divUsername.style.display = 'none';
263
- if(divCpt !== null) {
264
- divCpt.style.display = '';
265
- }
266
- if(divMultiSet !== null) {
267
- divMultiSet.style.display = 'none';
268
- }
269
  }
270
 
271
  /**
@@ -278,20 +296,23 @@ if (activeTab === 'rankings') {
278
  * @param divCategory
279
  * @param divCpt
280
  * @param divMultiSet
 
281
  */
282
- function yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
283
- divView.style.display = ''
284
- divVotes.style.display = '';
285
- divSize.style.display = '';
286
- divCategory.style.display = '';
287
- divOverallTxt.style.display = 'none';
288
- divUsername.style.display = 'none';
289
- if(divCpt !== null) {
290
- divCpt.style.display = '';
291
- }
292
- if(divMultiSet !== null) {
293
- divMultiSet.style.display = 'none';
294
- }
 
 
295
  }
296
 
297
  /**
@@ -304,20 +325,23 @@ if (activeTab === 'rankings') {
304
  * @param divCategory
305
  * @param divCpt
306
  * @param divMultiSet
 
307
  */
308
- function yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
309
- divUsername.style.display = '';
310
- divOverallTxt.style.display = 'none';
311
- divView.style.display = 'none';
312
- divVotes.style.display = 'none';
313
- divSize.style.display = 'none';
314
- divCategory.style.display = 'none';
315
- if(divCpt !== null) {
316
- divCpt.style.display = 'none';
317
- }
318
- if(divMultiSet !== null) {
319
- divMultiSet.style.display = 'none';
320
- }
 
 
321
  }
322
 
323
  /**
@@ -331,25 +355,17 @@ if (activeTab === 'rankings') {
331
  * @param divCpt
332
  * @param divMultiSet
333
  * @param visitor
 
334
  */
335
  function yasrBuilderMultisetOptions
336
  (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt,
337
- divMultiSet, visitor=false
338
  ) {
339
- //common params for both
340
- divCategory.style.display = '';
341
- divSize.style.display = '';
342
- divUsername.style.display = 'none';
343
-
344
- if(divCpt !== null) {
345
- divCpt.style.display = '';
346
- }
347
- if(divMultiSet !== null) {
348
- divMultiSet.style.display = '';
349
- }
350
-
351
  //params for yasr_visitor_multi_set_ranking
352
  if(visitor === true) {
 
 
 
353
  divView.style.display = ''
354
  divVotes.style.display = '';
355
  divOverallTxt.style.display = 'none';
@@ -361,6 +377,21 @@ if (activeTab === 'rankings') {
361
  divVotes.style.display = 'none';
362
  divOverallTxt.style.display = '';
363
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  }
365
 
366
  }
15
  jQuery(elementsClassParents).prop('disabled', true); //disable all parents elements;
16
  jQuery(elementsClassChilds).prop('disabled', true); //disable all childs elements;
17
 
18
+ jQuery(elementsClassParents).find('input').each(function () {
19
+ jQuery(this).prop('disabled', true);
20
+ });
21
+
22
  //add action in yasr-settings-page
23
  wp.hooks.doAction('yasrBuilderBegin', elementsClassParents, elementsClassChilds);
24
 
40
  //This is the select for data Source
41
  const selectDataSource = document.getElementById('yasr-ranking-source');
42
  const selectMultiset = document.getElementById('yasr-ranking-multiset-select');
43
+ const datePickerStart = document.getElementById('yasr-builder-datepicker-start');
44
+ const datePickerEnd = document.getElementById('yasr-builder-datepicker-end');
45
 
46
+ //Containers Div
47
  const divParamsContainer = document.getElementById('yasr-builder-params-container');
48
  const divView = document.getElementById('builder-vv-default-view');
49
  const divVotes = document.getElementById('builder-vv-required-votes');
53
  const divCategory = document.getElementById('builder-category');
54
  const divCpt = document.getElementById('builder-cpt');
55
  const divMultiSet = document.getElementById('yasr-ranking-multiset');
56
+ const divDatePicker = document.getElementById('yasr-builder-datepicker');
57
 
58
  let dataSource = selectDataSource.value;
59
  let previewClicked = false;
60
 
61
+ //Be sure date picker fields are empty on page load (or reload)
62
+ datePickerStart.value = '';
63
+ datePickerEnd.value = '';
64
+
65
  //if on page load is selected something else from the default ranking (yasr_most_or_highest_rated_posts)
66
  //show the proper fields
67
  if(dataSource === 'yasr_ov_ranking' ) {
68
+ yasrBuilderOvOptions(divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker);
69
  }
70
  else if(dataSource === 'yasr_most_active_users' || dataSource === 'yasr_top_reviewers') {
71
+ yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker);
72
  }
73
  else if(dataSource === 'yasr_multi_set_ranking') {
74
+ yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, false, divDatePicker);
75
  }
76
  else if(dataSource === 'yasr_visitor_multi_set_ranking') {
77
+ yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, true, divDatePicker);
78
  }
79
  else {
80
+ yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker)
81
  }
82
 
83
  //event listener for all change events
84
  document.addEventListener('change', event => {
85
  if(event.target.id === 'yasr-ranking-source') {
 
86
  //be sure to reset the class of the container to the default one
87
  divParamsContainer.className = '';
88
  divParamsContainer.classList.add('yasr-settings-row-33');
89
 
90
  //when event is on main select, be sure the preview div is empty
91
  previewDiv.innerHTML = '';
92
+
93
+ //Empty date picker fields
94
+ datePickerStart.value = '';
95
+ datePickerEnd.value = '';
96
+
97
  //reset attributes
98
  shortcodeAttributes = yasrReturnShortcodeAttributes();
99
 
100
  if(event.target.value === 'yasr_ov_ranking') {
101
+ yasrBuilderOvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker);
102
  }
103
  else if(event.target.value === 'yasr_most_active_users' || event.target.value === 'yasr_top_reviewers') {
104
+ yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker);
105
  }
106
  else if(event.target.value === 'yasr_multi_set_ranking') {
107
+ yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, false, divDatePicker);
108
  //get the value of the first option(array key 0) in the select
109
  shortcodeAttributes['setid'] = ' setid='+selectMultiset[0].value;
110
  }
111
  else if(event.target.value === 'yasr_visitor_multi_set_ranking') {
112
+ yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, true, divDatePicker);
113
  //get the value of the first option(array key 0) in the select
114
  shortcodeAttributes['setid'] = ' setid='+selectMultiset[0].value;
115
  }
116
  //By default, show setting for yasr_most_or_highest_rated_posts
117
  else {
118
+ yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker)
119
  }
120
 
121
  //be sure shortcodeAttributes is initialized again
148
  shortcodeAttributes['txtPosition']+
149
  shortcodeAttributes['txt']+
150
  shortcodeAttributes['display']+
151
+ shortcodeAttributes['start_date']+
152
+ shortcodeAttributes['end_date']+
153
  shortcodeAttributes['category']+
154
  shortcodeAttributes['cpt'];
155
 
249
  txtPosition: '',
250
  txt: '',
251
  display: '',
252
+ start_date: '',
253
+ end_date: '',
254
  category: '',
255
  cpt: ''
256
  };
266
  * @param divCategory
267
  * @param divCpt
268
  * @param divMultiSet
269
+ * @param divDatePicker
270
  */
271
+ function yasrBuilderOvOptions
272
+ (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker) {
273
+ //show custom text for overall
274
+ divOverallTxt.style.display = '';
275
+ divSize.style.display = '';
276
+ divCategory.style.display = '';
277
+ divDatePicker.style.display = '';
278
+ divView.style.display = 'none';
279
+ divVotes.style.display = 'none';
280
+ divUsername.style.display = 'none';
281
+ if(divCpt !== null) {
282
+ divCpt.style.display = '';
283
+ }
284
+ if(divMultiSet !== null) {
285
+ divMultiSet.style.display = 'none';
286
+ }
 
 
287
  }
288
 
289
  /**
296
  * @param divCategory
297
  * @param divCpt
298
  * @param divMultiSet
299
+ * @param divDatePicker
300
  */
301
+ function yasrBuilderVvOptions
302
+ (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker) {
303
+ divView.style.display = ''
304
+ divVotes.style.display = '';
305
+ divSize.style.display = '';
306
+ divCategory.style.display = '';
307
+ divDatePicker.style.display = '';
308
+ divOverallTxt.style.display = 'none';
309
+ divUsername.style.display = 'none';
310
+ if(divCpt !== null) {
311
+ divCpt.style.display = '';
312
+ }
313
+ if(divMultiSet !== null) {
314
+ divMultiSet.style.display = 'none';
315
+ }
316
  }
317
 
318
  /**
325
  * @param divCategory
326
  * @param divCpt
327
  * @param divMultiSet
328
+ * @param divDatePicker
329
  */
330
+ function yasrBuilderNoStarsOptions
331
+ (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, divDatePicker) {
332
+ divUsername.style.display = '';
333
+ divDatePicker.style.display = 'none';
334
+ divOverallTxt.style.display = 'none';
335
+ divView.style.display = 'none';
336
+ divVotes.style.display = 'none';
337
+ divSize.style.display = 'none';
338
+ divCategory.style.display = 'none';
339
+ if(divCpt !== null) {
340
+ divCpt.style.display = 'none';
341
+ }
342
+ if(divMultiSet !== null) {
343
+ divMultiSet.style.display = 'none';
344
+ }
345
  }
346
 
347
  /**
355
  * @param divCpt
356
  * @param divMultiSet
357
  * @param visitor
358
+ * @param divDatePicker
359
  */
360
  function yasrBuilderMultisetOptions
361
  (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt,
362
+ divMultiSet, visitor=false, divDatePicker
363
  ) {
 
 
 
 
 
 
 
 
 
 
 
 
364
  //params for yasr_visitor_multi_set_ranking
365
  if(visitor === true) {
366
+ //Here the div must not be 33 but 24
367
+ divParamsContainer.className = '';
368
+ divParamsContainer.classList.add('yasr-settings-row-24');
369
  divView.style.display = ''
370
  divVotes.style.display = '';
371
  divOverallTxt.style.display = 'none';
377
  divVotes.style.display = 'none';
378
  divOverallTxt.style.display = '';
379
  }
380
+
381
+ //common params for both
382
+ divCategory.style.display = '';
383
+ divSize.style.display = '';
384
+ divDatePicker.style.display = '';
385
+ divUsername.style.display = 'none';
386
+
387
+ if(divCpt !== null) {
388
+ divCpt.style.display = '';
389
+ }
390
+ if(divMultiSet !== null) {
391
+ divMultiSet.style.display = '';
392
+ }
393
+
394
+
395
  }
396
 
397
  }
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,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"}}]);
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"},"annual"===e.cycle&&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)),"monthly"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"1 month")," of supports and updates ",React.createElement("br",null),"for",React.createElement("strong",null,t)),"lifetime"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"Lifetime")," updates and support",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="yasr-vv-loader-"+l,f=document.getElementById(m),b=document.getElementById(g),E=document.getElementById(p),k=document.getElementById(v);if("yes"===yasrCommonData.ajaxEnabled){var I={action:"yasr_load_vv",post_id:o,nonce_visitor:d};null!==k&&(k.innerHTML=yasrCommonData.loaderHtml),jQuery.get(yasrCommonData.ajaxurl,I).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,f,b,k,E),!0!==n&&(null!==f&&(f.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==b&&(b.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==E&&(E.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,E.style.display=""))})).fail((function(t,e,r,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,f,b,k,E),!0!==n&&(E.style.display="")}))}else h(u,a,o,s,i,l,d,c,f,b,k,E)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e,r,a=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(r=window.getComputedStyle(e[0],null).getPropertyValue("color")),r)&&(document.getElementById(t.item(n).id).style.fill=r);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{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);null!==d&&(d.innerHTML="");f(t,n,m,1,a,e,(function(t,e){null!==d&&(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=""),null!==d&&(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}}}]);
1
+ !function(t){var e={};function a(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=t,a.c=e,a.d=function(t,e,r){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=0)}([function(t,e,a){a(1),t.exports=a(2)},function(t,e){var a;if(document.getElementsByClassName("nav-tab-active").length>0&&(a=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===a){var r=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===r&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===a&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===a){var s=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===s){var o=jQuery("#yasr-edit-form-number-elements").attr("value");o++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(o>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+o+' <input type="text" name="edit-multi-set-element-'+o+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),o++}))}else s>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===a&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,a){"use strict";var r,n;a.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},d=[],u=0;u<256;++u)d.push((u+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(d[t[e+0]]+d[t[e+1]]+d[t[e+2]]+d[t[e+3]]+"-"+d[t[e+4]]+d[t[e+5]]+"-"+d[t[e+6]]+d[t[e+7]]+"-"+d[t[e+8]]+d[t[e+9]]+"-"+d[t[e+10]]+d[t[e+11]]+d[t[e+12]]+d[t[e+13]]+d[t[e+14]]+d[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a};for(var y=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return c(r)},m=wp.i18n.__,g=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],p=0;p<g.length;p++)v(g[p]);function v(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;f(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),s=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=_(n),s=_(s),!0===n&&(s=!0);var o=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),d=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),c=a.getAttribute("data-issingular"),y="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,v="yasr-vv-loader-"+l,f=document.getElementById(y),b=document.getElementById(g),E=document.getElementById(p),k=document.getElementById(v);if("yes"===yasrCommonData.ajaxEnabled){null!==k&&(k.innerHTML=yasrCommonData.loaderHtml);var I={action:"yasr_load_vv",post_id:o,nonce_visitor:u};jQuery.get(yasrCommonData.ajaxurl,I).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),h(d,r,o,e,i,l,u,c,f,b,k,E),!0!==n&&(null!==f&&(f.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==b&&(b.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==E&&(E.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,E.style.display=""))})).fail((function(t,e,a,y){console.info(m("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(d,r,o,s,i,l,u,c,f,b,k,E),!0!==n&&(E.style.display="")}))}else h(d,r,o,s,i,l,u,c,f,b,k,E)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a)&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){r=s}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),s=n.id,o=n.getAttribute("data-rater-readonly");o=_(o);f(16,s,n,1,o,!1,(function(t,r){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(a)}))}))}(e)}}function f(t,e){var a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:s,rating:o,rateCallback:i})}function h(t,e,a,r,n,s,o,i,l,d,u,c){e=parseFloat(e),r=_(r);var y=document.getElementById(n);null!==u&&(u.innerHTML="");f(t,n,y,1,r,e,(function(t,e){null!==u&&(u.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==d&&(d.innerHTML=t.average_rating),null!==c&&(c.innerHTML=t.rating_saved_text,c.style.display=""),null!==u&&(u.innerHTML="")})),e()}))}function _(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function b(t){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,r=B(t);if(e){var n=B(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return w(this,a)}}function w(t,e){return!e||"object"!==b(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}M();var j=wp.i18n.__,R=wp.element.render;function x(t){var e="yasr-ranking-element-"+y(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return f(a,e,!1,.1,!0,t.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",j("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",j("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function L(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function T(t){var e="after",a=j("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:a}),React.createElement(x,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(x,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:a}))}function Q(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(L,{colClass:e,post:t.post}),React.createElement(T,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(Q,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var H=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}(s,React.Component);var e,a,r,n=I(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(j("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(j("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(j(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(j(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:j("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},j("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},j("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},j("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},j("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,j("Order By","yet-another-stars-rating-pro"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(S,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",d=new URLSearchParams(r);return null!==d.get("view")&&(o=d.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(a,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:i,source:a}),React.createElement(S,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:l,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,j("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,a),r&&E(e,r),s}();function M(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);R(React.createElement(H,{source:r,tableId:a,params:n,nonce:s}),o)}}var O,P=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(O=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===O){var N,A=function(t){var e=G.value,a=document.getElementById("yasr-builder-shortcode").textContent,r=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];r=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",r),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+a).then((function(t){return!0===t.ok?t.json():(console.info(P("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,Y.childNodes.length>0?Y.replaceChild(e,Y.childNodes[0]):Y.appendChild(e)}})).then((function(t){r.forEach((function(t){e===t&&M()}))}))},D=function(t,e,a,r,n,s,o,i,l){t.style.display="",e.style.display="",s.style.display="",l.style.display="",a.style.display="none",r.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},F=function(t,e,a,r,n,s,o,i,l){a.style.display="",r.style.display="",e.style.display="",s.style.display="",l.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,a,r,n,s,o,i,l){n.style.display="",l.style.display="none",t.style.display="none",a.style.display="none",r.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},J=function(t,e,a,r,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(Z.className="",Z.classList.add("yasr-settings-row-24"),a.style.display="",r.style.display="",t.style.display="none"):(a.style.display="none",r.style.display="none",t.style.display=""),s.style.display="",e.style.display="",d.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),jQuery(".yasr-builder-elements-parents").find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var U=[],q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};N=q.name,document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]");var V=document.getElementById("yasr-builder-button-preview"),K=document.getElementById("yasr-builder-copy-shortcode"),Y=document.getElementById("yasr-builder-preview"),G=document.getElementById("yasr-ranking-source"),$=document.getElementById("yasr-ranking-multiset-select"),W=document.getElementById("yasr-builder-datepicker-start"),X=document.getElementById("yasr-builder-datepicker-end"),Z=document.getElementById("yasr-builder-params-container"),tt=document.getElementById("builder-vv-default-view"),et=document.getElementById("builder-vv-required-votes"),at=document.getElementById("builder-stars-size"),rt=document.getElementById("builder-overall-text"),nt=document.getElementById("builder-username-options"),st=document.getElementById("builder-category"),ot=document.getElementById("builder-cpt"),it=document.getElementById("yasr-ranking-multiset"),lt=document.getElementById("yasr-builder-datepicker"),dt=G.value,ut=!1;W.value="",X.value="","yasr_ov_ranking"===dt?D(rt,at,tt,et,nt,st,ot,it,lt):"yasr_most_active_users"===dt||"yasr_top_reviewers"===dt?z(rt,at,tt,et,nt,st,ot,it,lt):"yasr_multi_set_ranking"===dt?J(rt,at,tt,et,nt,st,ot,it,!1,lt):"yasr_visitor_multi_set_ranking"===dt?J(rt,at,tt,et,nt,st,ot,it,!0,lt):F(rt,at,tt,et,nt,st,ot,it,lt),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)Z.className="",Z.classList.add("yasr-settings-row-33"),Y.innerHTML="",W.value="",X.value="",q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(rt,at,tt,et,nt,st,ot,it,lt):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(rt,at,tt,et,nt,st,ot,it,lt):"yasr_multi_set_ranking"===t.target.value?(J(rt,at,tt,et,nt,st,ot,it,!1,lt),q.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(J(rt,at,tt,et,nt,st,ot,it,!0,lt),q.setid=" setid="+$[0].value):F(rt,at,tt,et,nt,st,ot,it,lt),q.name=t.target.value,N=q.name+q.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(q.setid=" setid="+t.target.value),U=wp.hooks.applyFilters("yasrBuilderFilterShortcode",q);for(var e=2;q.length;e++)U.hasOwnProperty(q[e])&&(q[e]=U[e]);N=q.name+q.setid+q.rows+q.view+q.minvotesmost+q.minvoteshg+q.size+q.txtPosition+q.txt+q.display+q.start_date+q.end_date+q.category+q.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]"),!0===ut&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&A()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){A(),ut=!0}}}]);
admin/settings/classes/YasrSettingsRankings.php CHANGED
@@ -211,19 +211,19 @@ class YasrSettingsRankings {
211
  <!-- Customize text -->
212
  <div class="yasr-builder-div-fluid" id="builder-overall-text" style="display: none">
213
  <?php
214
- $option_title = __('Show text before or after the stars?', 'yet-another-stars-rating');
215
- $class = 'yasr-builder-custom-text-overall yasr-builder-elements-parents';
216
- $array_options = array (
217
- 'no' => __('No', 'yet-another-stars-rating'),
218
- 'before' => __('Yes, before the stars', 'yet-another-stars-rating'),
219
- 'after' => __('Yes, after the stars', 'yet-another-stars-rating')
220
- );
221
- $name = 'yasr-builder-customize-overall-text';
222
- $default = 'no';
223
- $id = 'yasr-builder-ov-radio-text';
224
-
225
- echo $option_title.YASR_LOCKED_FEATURE;
226
- echo YasrPhpFieldsHelper::radio('', $class, $array_options, $name, $default, $id);
227
  ?>
228
  <br />
229
  <strong>
@@ -251,6 +251,33 @@ class YasrSettingsRankings {
251
  <?php
252
  }
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  public function categories(){
255
  if ($this->custom_post_types !== false) {
256
  $category_class = 'yasr-div-fixed-65';
211
  <!-- Customize text -->
212
  <div class="yasr-builder-div-fluid" id="builder-overall-text" style="display: none">
213
  <?php
214
+ $option_title = __('Show text before or after the stars?', 'yet-another-stars-rating');
215
+ $class = 'yasr-builder-custom-text-overall yasr-builder-elements-parents';
216
+ $array_options = array (
217
+ 'no' => __('No', 'yet-another-stars-rating'),
218
+ 'before' => __('Yes, before the stars', 'yet-another-stars-rating'),
219
+ 'after' => __('Yes, after the stars', 'yet-another-stars-rating')
220
+ );
221
+ $name = 'yasr-builder-customize-overall-text';
222
+ $default = 'no';
223
+ $id = 'yasr-builder-ov-radio-text';
224
+
225
+ echo '<strong>'.$option_title.'</strong>'.YASR_LOCKED_FEATURE;
226
+ echo YasrPhpFieldsHelper::radio('', $class, $array_options, $name, $default, $id);
227
  ?>
228
  <br />
229
  <strong>
251
  <?php
252
  }
253
 
254
+ public function setDate() {
255
+ ?>
256
+ <div class="yasr-builder-div-fluid" id="yasr-builder-datepicker" style="display: none">
257
+ <?php
258
+ $name_id = 'yasr-builder-datepicker-start';
259
+ echo '<strong>'.__('Start Date', 'yet-another-stars-rating').'</strong>' . YASR_LOCKED_FEATURE;
260
+ echo YasrPhpFieldsHelper::text(
261
+ 'yasr-option-div yasr-builder-elements-parents',
262
+ '',
263
+ $name_id,
264
+ $name_id
265
+ );
266
+
267
+ $name_id = 'yasr-builder-datepicker-end';
268
+ echo '<strong>'.__('End Date', 'yet-another-stars-rating').'</strong>' . YASR_LOCKED_FEATURE;
269
+ echo YasrPhpFieldsHelper::text(
270
+ 'yasr-option-div yasr-builder-elements-parents',
271
+ '',
272
+ $name_id,
273
+ $name_id
274
+ );
275
+ ?>
276
+ </div>
277
+ <?php
278
+
279
+ }
280
+
281
  public function categories(){
282
  if ($this->custom_post_types !== false) {
283
  $category_class = 'yasr-div-fixed-65';
admin/settings/multiset/yasr-settings-functions-multiset.php CHANGED
@@ -762,12 +762,12 @@ function yasr_process_edit_multi_set_form() {
762
 
763
  if ($error) {
764
  return $array_errors;
765
- } else {
766
- echo "<div class=\"updated\"><p><strong>";
767
- _e("Settings Saved", 'yet-another-stars-rating');
768
- echo "</strong></p></div> ";
769
  }
770
 
 
 
 
 
771
 
772
  } //End if isset( $_POST['yasr_edit_multi_set_form']
773
 
762
 
763
  if ($error) {
764
  return $array_errors;
 
 
 
 
765
  }
766
 
767
+ echo "<div class=\"updated\"><p><strong>";
768
+ _e("Settings Saved", 'yet-another-stars-rating');
769
+ echo "</strong></p></div> ";
770
+
771
 
772
  } //End if isset( $_POST['yasr_edit_multi_set_form']
773
 
admin/settings/rankings/yasr-ranking-builder.php CHANGED
@@ -70,11 +70,15 @@ $cr_setting = new YasrSettingsRankings($custom_post_types);
70
  $cr_setting->size();
71
  //custom text for overall rating
72
  $cr_setting->ovCustomText();
 
 
73
  //settings for display name
74
  $cr_setting->usernameDisplay();
75
  ?>
76
  </div>
77
 
 
 
78
  <!--Second Row -->
79
  <div class="yasr-builder-ranking-container" style="margin-top: 20px">
80
  <?php
70
  $cr_setting->size();
71
  //custom text for overall rating
72
  $cr_setting->ovCustomText();
73
+ //Date
74
+ $cr_setting->setDate();
75
  //settings for display name
76
  $cr_setting->usernameDisplay();
77
  ?>
78
  </div>
79
 
80
+ <hr style="border: 1px dotted #ddd; margin-top: 20px;"/>
81
+
82
  <!--Second Row -->
83
  <div class="yasr-builder-ranking-container" style="margin-top: 20px">
84
  <?php
includes/classes/YasrPhpFieldsHelper.php CHANGED
@@ -125,14 +125,24 @@ if (!class_exists('YasrPhpFieldsHelper') ) {
125
  */
126
  public static function text(
127
  $class = false, $label = false, $name = false, $id = false, $placeholder = false, $default_value = false,
128
- $autocomplete='off'
129
  ) {
130
- $attribute = self::escape_attributes($class, $label, $name, $id, $default_value, $placeholder);
 
 
 
 
131
 
132
  $container = "<div class='$attribute[class]'>";
133
  $label_string = "<label for='$attribute[id]'>$attribute[label]</label>";
134
- $input_text = "<input type='text' name='$attribute[name]' id='$attribute[id]' value='$attribute[value]'
135
- placeholder='$attribute[placeholder]' autocomplete='$autocomplete'>";
 
 
 
 
 
 
136
  $end_container = "</div>";
137
 
138
  return ($container . $label_string . $input_text . $end_container);
@@ -215,12 +225,21 @@ if (!class_exists('YasrPhpFieldsHelper') ) {
215
  * @param bool|string|int $default_value
216
  * @param bool|string|int $placeholder
217
  * @param string $autocomplete
 
 
218
  *
219
  * @return array
220
  */
221
  private static function escape_attributes(
222
- $class = false, $label = false, $name = false, $id = false, $default_value = false, $placeholder = false,
223
- $autocomplete = 'off'
 
 
 
 
 
 
 
224
  ) {
225
 
226
  $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
@@ -259,6 +278,14 @@ if (!class_exists('YasrPhpFieldsHelper') ) {
259
  $autocomplete = 'off';
260
  }
261
 
 
 
 
 
 
 
 
 
262
  return array(
263
  'class' => htmlspecialchars($class, ENT_QUOTES),
264
  'id' => htmlspecialchars($id, ENT_QUOTES),
@@ -267,6 +294,8 @@ if (!class_exists('YasrPhpFieldsHelper') ) {
267
  'placeholder' => htmlspecialchars($placeholder, ENT_QUOTES),
268
  'value' => htmlspecialchars($default_value, ENT_QUOTES),
269
  'autocomplete' => $autocomplete,
 
 
270
  );
271
  }
272
 
125
  */
126
  public static function text(
127
  $class = false, $label = false, $name = false, $id = false, $placeholder = false, $default_value = false,
128
+ $autocomplete = 'off', $disabled = false, $readonly = false
129
  ) {
130
+
131
+ $attribute = self::escape_attributes(
132
+ $class, $label, $name, $id, $default_value, $placeholder,
133
+ $autocomplete, $disabled, $readonly
134
+ );
135
 
136
  $container = "<div class='$attribute[class]'>";
137
  $label_string = "<label for='$attribute[id]'>$attribute[label]</label>";
138
+ $input_text = "<input type='text'
139
+ name='$attribute[name]'
140
+ id='$attribute[id]'
141
+ value='$attribute[value]'
142
+ placeholder='$attribute[placeholder]'
143
+ autocomplete='$autocomplete'
144
+ $attribute[disabled]
145
+ $attribute[readonly] />";
146
  $end_container = "</div>";
147
 
148
  return ($container . $label_string . $input_text . $end_container);
225
  * @param bool|string|int $default_value
226
  * @param bool|string|int $placeholder
227
  * @param string $autocomplete
228
+ * @param bool|string $disabled
229
+ * @param bool|string $readonly
230
  *
231
  * @return array
232
  */
233
  private static function escape_attributes(
234
+ $class = false,
235
+ $label = false,
236
+ $name = false,
237
+ $id = false,
238
+ $default_value = false,
239
+ $placeholder = false,
240
+ $autocomplete = 'off',
241
+ $disabled = false,
242
+ $readonly = false
243
  ) {
244
 
245
  $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
278
  $autocomplete = 'off';
279
  }
280
 
281
+ if($disabled !== false && $disabled !== '') {
282
+ $disabled = 'disabled';
283
+ }
284
+
285
+ if($readonly !== false) {
286
+ $readonly = 'readonly';
287
+ }
288
+
289
  return array(
290
  'class' => htmlspecialchars($class, ENT_QUOTES),
291
  'id' => htmlspecialchars($id, ENT_QUOTES),
294
  'placeholder' => htmlspecialchars($placeholder, ENT_QUOTES),
295
  'value' => htmlspecialchars($default_value, ENT_QUOTES),
296
  'autocomplete' => $autocomplete,
297
+ 'disabled' => $disabled,
298
+ 'readonly' => $readonly
299
  );
300
  }
301
 
includes/js/src/ranking.js CHANGED
@@ -207,7 +207,8 @@ class YasrRanking extends React.Component {
207
  data: [],
208
  tableId: props.tableId,
209
  source: props.source,
210
- rankingParams: props.params
 
211
  };
212
 
213
  }
@@ -306,8 +307,8 @@ class YasrRanking extends React.Component {
306
  returnRestUrl(){
307
  let queryParams = ((this.state.rankingParams !== '') ? this.state.rankingParams : '');
308
  let dataSource = this.state.source;
309
- let urlYasrRankingApi;
310
- const yasrRankingsApiPath = 'yet-another-stars-rating/v1/yasr-rankings/';
311
 
312
  let cleanedQuery = '';
313
 
@@ -322,6 +323,14 @@ class YasrRanking extends React.Component {
322
  cleanedQuery += '&limit='+params.get('limit');
323
  }
324
 
 
 
 
 
 
 
 
 
325
  if(params.get('ctg') !== null) {
326
  cleanedQuery += '&ctg='+params.get('ctg');
327
  }
@@ -345,7 +354,7 @@ class YasrRanking extends React.Component {
345
  }
346
 
347
  if(dataSource === 'author_ranking' || dataSource === 'author_multi') {
348
- urlYasrRankingApi = [yasrCommonData.restEndpoint + yasrRankingsApiPath + '?source=' + dataSource + cleanedQuery];
349
  }
350
  else {
351
  let requiredMost = '';
@@ -362,14 +371,14 @@ class YasrRanking extends React.Component {
362
  }
363
  }
364
 
365
- urlYasrRankingApi = [
366
- yasrCommonData.restEndpoint + yasrRankingsApiPath + '?show=most&source=' + dataSource + cleanedQuery + requiredMost,
367
- yasrCommonData.restEndpoint + yasrRankingsApiPath + '?show=highest&source=' + dataSource + cleanedQuery + requiredHighest
368
  ];
369
 
370
  }
371
 
372
- return urlYasrRankingApi;
373
  }
374
 
375
  /**
@@ -591,9 +600,10 @@ export function yasrDrawRankings () {
591
  const tableId = yasrRankingsInDom.item(i).id;
592
  const source = JSON.parse(yasrRankingsInDom.item(i).dataset.rankingSource);
593
  const params = JSON.parse(yasrRankingsInDom.item(i).dataset.rankingParams);
 
594
  const rankingTable = document.getElementById(tableId);
595
 
596
- render(<YasrRanking source={source} tableId={tableId} params={params}/>, rankingTable);
597
  }
598
  }
599
 
207
  data: [],
208
  tableId: props.tableId,
209
  source: props.source,
210
+ rankingParams: props.params,
211
+ nonce: props.nonce
212
  };
213
 
214
  }
307
  returnRestUrl(){
308
  let queryParams = ((this.state.rankingParams !== '') ? this.state.rankingParams : '');
309
  let dataSource = this.state.source;
310
+ const nonce = '&nonce_rankings='+this.state.nonce;
311
+ let urlYasrRanking;
312
 
313
  let cleanedQuery = '';
314
 
323
  cleanedQuery += '&limit='+params.get('limit');
324
  }
325
 
326
+ if(params.get('start_date') !== null && params.get('start_date') !== '0') {
327
+ cleanedQuery += '&start_date='+params.get('start_date');
328
+ }
329
+
330
+ if(params.get('end_date') !== null && params.get('end_date') !== '0') {
331
+ cleanedQuery += '&end_date='+params.get('end_date');
332
+ }
333
+
334
  if(params.get('ctg') !== null) {
335
  cleanedQuery += '&ctg='+params.get('ctg');
336
  }
354
  }
355
 
356
  if(dataSource === 'author_ranking' || dataSource === 'author_multi') {
357
+ urlYasrRanking = [yasrCommonData.ajaxurl + '?action=yasr_load_rankings&source=' + dataSource + cleanedQuery + nonce];
358
  }
359
  else {
360
  let requiredMost = '';
371
  }
372
  }
373
 
374
+ urlYasrRanking = [
375
+ yasrCommonData.ajaxurl + '?action=yasr_load_rankings&show=most&source=' + dataSource + cleanedQuery + requiredMost + nonce,
376
+ yasrCommonData.ajaxurl + '?action=yasr_load_rankings&show=highest&source=' + dataSource + cleanedQuery + requiredHighest + nonce
377
  ];
378
 
379
  }
380
 
381
+ return urlYasrRanking;
382
  }
383
 
384
  /**
600
  const tableId = yasrRankingsInDom.item(i).id;
601
  const source = JSON.parse(yasrRankingsInDom.item(i).dataset.rankingSource);
602
  const params = JSON.parse(yasrRankingsInDom.item(i).dataset.rankingParams);
603
+ const nonce = JSON.parse(yasrRankingsInDom.item(i).dataset.rankingNonce);
604
  const rankingTable = document.getElementById(tableId);
605
 
606
+ render(<YasrRanking source={source} tableId={tableId} params={params} nonce={nonce} />, rankingTable);
607
  }
608
  }
609
 
includes/js/src/yasr-front.js CHANGED
@@ -158,7 +158,6 @@ function yasrSetRating (yasrRatingsInDom) {
158
  function yasrVisitorVotesFront (yasrRaterVVInDom) {
159
  //Check in the object
160
  for (let i = 0; i < yasrRaterVVInDom.length; i++) {
161
-
162
  (function(i) {
163
  //yasr-star-rating is the class set by rater.js : so, if already exists,
164
  //means that rater already run for the element
@@ -190,9 +189,9 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
190
  let nonce = elem.getAttribute('data-rater-nonce');
191
  let isSingular = elem.getAttribute('data-issingular');
192
 
193
- let containerVotesNumberName = 'yasr-vv-votes-number-container-' + uniqueId;
194
- let containerAverageNumberName = 'yasr-vv-average-container-' + uniqueId;
195
- let bottomContainerName = 'yasr-vv-bottom-container-' + uniqueId;
196
  let loaderContainerName = 'yasr-vv-loader-' + uniqueId;
197
  const containerVotesNumber = document.getElementById(containerVotesNumberName);
198
  const containerAverageNumber = document.getElementById(containerAverageNumberName);
@@ -200,17 +199,17 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
200
  const loaderContainer = document.getElementById(loaderContainerName);
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
- if(loaderContainer !== null) {
211
- loaderContainer.innerHTML = yasrCommonData.loaderHtml;
212
- }
213
-
214
  jQuery.get(yasrCommonData.ajaxurl, data).done(
215
  function (response) {
216
  let data = JSON.parse(response);
@@ -267,7 +266,6 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
267
  }
268
 
269
  })(i);
270
-
271
  }//End for
272
 
273
  }
158
  function yasrVisitorVotesFront (yasrRaterVVInDom) {
159
  //Check in the object
160
  for (let i = 0; i < yasrRaterVVInDom.length; i++) {
 
161
  (function(i) {
162
  //yasr-star-rating is the class set by rater.js : so, if already exists,
163
  //means that rater already run for the element
189
  let nonce = elem.getAttribute('data-rater-nonce');
190
  let isSingular = elem.getAttribute('data-issingular');
191
 
192
+ let containerVotesNumberName = 'yasr-vv-votes-number-container-' + uniqueId;
193
+ let containerAverageNumberName = 'yasr-vv-average-container-' + uniqueId;
194
+ let bottomContainerName = 'yasr-vv-bottom-container-' + uniqueId;
195
  let loaderContainerName = 'yasr-vv-loader-' + uniqueId;
196
  const containerVotesNumber = document.getElementById(containerVotesNumberName);
197
  const containerAverageNumber = document.getElementById(containerAverageNumberName);
199
  const loaderContainer = document.getElementById(loaderContainerName);
200
 
201
  if(yasrCommonData.ajaxEnabled === 'yes') {
202
+ //show the loader
203
+ if(loaderContainer !== null) {
204
+ loaderContainer.innerHTML = yasrCommonData.loaderHtml;
205
+ }
206
+
207
  let data = {
208
  action: 'yasr_load_vv',
209
  post_id: postId,
210
  nonce_visitor: nonce
211
  };
212
 
 
 
 
 
 
213
  jQuery.get(yasrCommonData.ajaxurl, data).done(
214
  function (response) {
215
  let data = JSON.parse(response);
266
  }
267
 
268
  })(i);
 
269
  }//End for
270
 
271
  }
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 j})),r.d(e,"yasrSetRaterValue",(function(){return B}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,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 B(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 T=wp.i18n.__,x=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],L=0;L<x.length;L++)j(x[L]);function j(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;B(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="yasr-vv-loader-"+l,p=document.getElementById(m),v=document.getElementById(y),h=document.getElementById(g),b=document.getElementById(f);if("yes"===yasrCommonData.ajaxEnabled){var _={action:"yasr_load_vv",post_id:s,nonce_visitor:c};null!==b&&(b.innerHTML=yasrCommonData.loaderHtml),jQuery.get(yasrCommonData.ajaxurl,_).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,p,v,b,h),!0!==n&&(null!==p&&(p.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==v&&(v.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(t,e,r,m){console.info(T("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,a,s,o,i,l,c,d,p,v,b,h),!0!==n&&(h.style.display="")}))}else P(u,a,s,o,i,l,c,d,p,v,b,h)}}(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);B(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 B(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);null!==c&&(c.innerHTML="");B(t,n,m,1,a,e,(function(t,e){null!==c&&(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=""),null!==c&&(c.innerHTML="")})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var 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 a(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=t,a.c=e,a.d=function(t,e,r){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=0)}([function(t,e,a){t.exports=a(1)},function(t,e,a){"use strict";var r,n;a.r(e),a.d(e,"yasrSearchStarsDom",(function(){return L})),a.d(e,"yasrSetRaterValue",(function(){return B}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a};var m=function(t,e,a){var r=(t=t||{}).random||(t.rng||s)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return d(r)};function g(t){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function y(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,r=h(t);if(e){var n=h(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return v(this,a)}}function v(t,e){return!e||"object"!==g(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return B(a,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function k(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;var e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function I(t){var e="after",a=b("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:a}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:a}))}function w(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(k,{colClass:e,post:t.post}),React.createElement(I,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(o,React.Component);var e,a,r,n=p(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=o,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("start_date")&&"0"!==o.get("start_date")&&(n+="&start_date="+o.get("start_date")),null!==o.get("end_date")&&"0"!==o.get("end_date")&&(n+="&end_date="+o.get("end_date")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+s+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:r},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),":  ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,o="most-rated-posts-"+a,s="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(r);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(a,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:i,source:a}),React.createElement(C,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:l,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&y(e.prototype,a),r&&y(e,r),o}();for(var x=wp.i18n.__,j=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],T=0;T<j.length;T++)L(j[T]);function L(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id;B(a.getAttribute("data-rater-starsize"),r,a)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rating"),n=a.getAttribute("data-readonly-attribute"),o=a.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=a.getAttribute("data-rater-postid"),i=a.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(a.getAttribute("data-rater-starsize")),c=a.getAttribute("data-rater-nonce"),d=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y="yasr-vv-bottom-container-"+l,f="yasr-vv-loader-"+l,p=document.getElementById(m),v=document.getElementById(g),h=document.getElementById(y),b=document.getElementById(f);if("yes"===yasrCommonData.ajaxEnabled){null!==b&&(b.innerHTML=yasrCommonData.loaderHtml);var _={action:"yasr_load_vv",post_id:s,nonce_visitor:c};jQuery.get(yasrCommonData.ajaxurl,_).done((function(t){var e,a=JSON.parse(t);e=!0===n||a.yasr_visitor_votes.stars_attributes.read_only,r=(r=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),r=parseFloat(r),P(u,r,s,e,i,l,c,d,p,v,b,h),!0!==n&&(null!==p&&(p.innerHTML=a.yasr_visitor_votes.number_of_votes),null!==v&&(v.innerHTML=r),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=a.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(t,e,a,m){console.info(x("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,r,s,o,i,l,c,d,p,v,b,h),!0!==n&&(h.style.display="")}))}else P(u,r,s,o,i,l,c,d,p,v,b,h)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var a=document.getElementsByClassName("yasr-dashicons-visitor-stats");a&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var o="#"+t.item(n).id,s=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a)&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:s};tippy(o,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){o!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){r=o}})}(n)}(a)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",a=[],r=0;r<t.length;r++)!function(r){if(!1===t.item(r).classList.contains("yasr-star-rating")){var n=t.item(r),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);B(16,o,n,1,s,!1,(function(t,r){var o=n.getAttribute("data-rater-postid"),s=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:o,setid:s,field:i,rating:l},a.push(e),r()}))}}(r);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:a,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(a){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(a)}))}))}(e)}}function B(t,e){var a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:a,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,a,r,n,o,s,i,l,u,c,d){e=parseFloat(e),r=O(r);var m=document.getElementById(n);null!==c&&(c.innerHTML="");B(t,n,m,1,r,e,(function(t,e){null!==c&&(c.innerHTML=yasrCommonData.loaderHtml);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==d&&(d.innerHTML=t.rating_saved_text,d.style.display=""),null!==c&&(c.innerHTML="")})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=JSON.parse(t.item(e).dataset.rankingNonce),s=document.getElementById(a);_(React.createElement(S,{source:r,tableId:a,params:n,nonce:o}),s)}}()}]);
includes/rest/classes/YasrCustomEndpoint.php CHANGED
@@ -187,65 +187,8 @@ class YasrCustomEndpoint extends WP_REST_Controller {
187
  * Get cleaned params
188
  */
189
  $source = $request['source'];
190
- $sql_params = false;
191
 
192
- //hooks here to add params
193
- $sql_params = apply_filters('yasr_rest_filter_ranking_request', $sql_params, $request);
194
-
195
- $data_to_return = array(
196
- 'source' => $source
197
- );
198
-
199
- if($source === 'overall_rating') {
200
- $overall_data = YasrRankingData::rankingOverallGetResults($sql_params);
201
- if($overall_data === false){
202
- $data_to_return = false;
203
- }
204
- else {
205
- $data_to_return['data_overall'] = YasrRankings::rankingData($overall_data);
206
- }
207
- }
208
-
209
- if($source === 'visitor_votes') {
210
- //outside 'most', only 'highest' is allowed
211
- $ranking = ($request['show'] === 'highest') ? $request['show'] : 'most';
212
- $data_to_return['show'] = $ranking;
213
-
214
- $vv_data = YasrRankingData::rankingVVGetResults($sql_params, $ranking);
215
- if($vv_data === false){
216
- $data_to_return = false;
217
- }
218
- else {
219
- $data_to_return['data_vv'] = YasrRankings::rankingData($vv_data);
220
- }
221
- }
222
-
223
- if($source === 'author_multi') {
224
- $am_data = YasrRankingData::rankingMulti($request['setid'], $sql_params);
225
- if($am_data === false){
226
- $data_to_return = false;
227
- }
228
- else {
229
- $data_to_return['data_mv'] = YasrRankings::rankingData($am_data);
230
- }
231
- }
232
-
233
- if($source === 'visitor_multi') {
234
- //outside 'most', only 'highest' is allowed
235
- $ranking = ($request['show'] === 'highest') ? $request['show'] : 'most';
236
- $data_to_return['show'] = $ranking;
237
-
238
- $vm_data = YasrRankingData::rankingMultiVV($request['setid'], $ranking, $sql_params);
239
- if($vm_data === false){
240
- $data_to_return = false;
241
- }
242
- else {
243
- $data_to_return['data_vv'] = YasrRankings::rankingData($vm_data);
244
- }
245
- }
246
-
247
- //hook here to add other "source" params to check
248
- $data_to_return = apply_filters('yasr_rest_add_custom_endpoint', $data_to_return, $source, $request, $sql_params);
249
 
250
  if ($data_to_return === false) {
251
  return new WP_Error(
187
  * Get cleaned params
188
  */
189
  $source = $request['source'];
 
190
 
191
+ $data_to_return = YasrShortcodesAjax::rankingData($source, $request);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
  if ($data_to_return === false) {
194
  return new WP_Error(
includes/shortcodes/classes/YasrRankings.php CHANGED
@@ -29,6 +29,12 @@ class YasrRankings extends YasrShortcode {
29
  protected $query_highest_rated_overall;
30
  public $query_result_most_rated_visitor;
31
  public $query_result_highest_rated_visitor;
 
 
 
 
 
 
32
 
33
  /**
34
  * Returns the shortcode for yasr_ov_ranking
@@ -73,7 +79,6 @@ class YasrRankings extends YasrShortcode {
73
  $sql_atts = apply_filters('yasr_vv_rankings_atts', $this->shortcode_name, $atts);
74
 
75
  $this->query_result_most_rated_visitor = YasrRankingData::rankingVVGetResults($sql_atts, 'most');
76
-
77
  $this->query_result_highest_rated_visitor = YasrRankingData::rankingVVGetResults($sql_atts, 'highest');
78
 
79
  $this->returnDoubleTableRanking($this->urlencodeAtts($sql_atts), $source);
@@ -169,13 +174,14 @@ class YasrRankings extends YasrShortcode {
169
  data-ranking-source='".json_encode($source)."'
170
  data-ranking-params='$table_attributes'
171
  data-ranking-size='".$this->starSize()."'
 
172
  >";
173
 
174
  $this->shortcode_html .= "</table>";
175
  }
176
  else {
177
  $this->shortcode_html .= '<div style="padding: 20px">';
178
- $this->shortcode_html .= __('No data found', 'yet-another-stars-rating');
179
  $this->shortcode_html .= '</div>';
180
  }
181
 
@@ -205,17 +211,18 @@ class YasrRankings extends YasrShortcode {
205
 
206
  $this->shortcode_html .= "<table
207
  class='yasr-rankings yasr-stars-rankings'
208
- id=$table_id
209
  data-ranking-data='".json_encode($array_with_title)."'
210
  data-ranking-source='".json_encode($source)."'
211
  data-ranking-params='$table_attributes'
212
  data-ranking-size='".$this->starSize()."'
 
213
  >";
214
  $this->shortcode_html .= '</table>';
215
 
216
  } else {
217
  $this->shortcode_html .= '<div style="padding: 20px">';
218
- $this->shortcode_html .= __('No data found', 'yet-another-stars-rating');
219
  $this->shortcode_html .= '</div>';
220
  }
221
 
29
  protected $query_highest_rated_overall;
30
  public $query_result_most_rated_visitor;
31
  public $query_result_highest_rated_visitor;
32
+ protected $ajax_nonce_rankings;
33
+
34
+ public function __construct($atts, $shortcode_name) {
35
+ parent::__construct($atts, $shortcode_name);
36
+ $this->ajax_nonce_rankings = wp_create_nonce("yasr_nonce_rankings");
37
+ }
38
 
39
  /**
40
  * Returns the shortcode for yasr_ov_ranking
79
  $sql_atts = apply_filters('yasr_vv_rankings_atts', $this->shortcode_name, $atts);
80
 
81
  $this->query_result_most_rated_visitor = YasrRankingData::rankingVVGetResults($sql_atts, 'most');
 
82
  $this->query_result_highest_rated_visitor = YasrRankingData::rankingVVGetResults($sql_atts, 'highest');
83
 
84
  $this->returnDoubleTableRanking($this->urlencodeAtts($sql_atts), $source);
174
  data-ranking-source='".json_encode($source)."'
175
  data-ranking-params='$table_attributes'
176
  data-ranking-size='".$this->starSize()."'
177
+ data-ranking-nonce='".json_encode($this->ajax_nonce_rankings)."'
178
  >";
179
 
180
  $this->shortcode_html .= "</table>";
181
  }
182
  else {
183
  $this->shortcode_html .= '<div style="padding: 20px">';
184
+ $this->shortcode_html .= __('No posts found with these parameters. Try to remove some filters.', 'yet-another-stars-rating');
185
  $this->shortcode_html .= '</div>';
186
  }
187
 
211
 
212
  $this->shortcode_html .= "<table
213
  class='yasr-rankings yasr-stars-rankings'
214
+ id='$table_id'
215
  data-ranking-data='".json_encode($array_with_title)."'
216
  data-ranking-source='".json_encode($source)."'
217
  data-ranking-params='$table_attributes'
218
  data-ranking-size='".$this->starSize()."'
219
+ data-ranking-nonce='".json_encode($this->ajax_nonce_rankings)."'
220
  >";
221
  $this->shortcode_html .= '</table>';
222
 
223
  } else {
224
  $this->shortcode_html .= '<div style="padding: 20px">';
225
+ $this->shortcode_html .= __('No posts found with these parameters. Try to remove some filters.', 'yet-another-stars-rating');
226
  $this->shortcode_html .= '</div>';
227
  }
228
 
includes/shortcodes/classes/YasrShortcodesAjax.php CHANGED
@@ -35,6 +35,9 @@ class YasrShortcodesAjax {
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
@@ -45,9 +48,8 @@ class YasrShortcodesAjax {
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
  }
@@ -227,7 +229,7 @@ class YasrShortcodesAjax {
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
@@ -604,4 +606,94 @@ class YasrShortcodesAjax {
604
 
605
  }
606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  }
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
+ add_action('wp_ajax_yasr_load_rankings', array('YasrShortcodesAjax', 'rankingData'));
40
+ add_action('wp_ajax_nopriv_yasr_load_rankings', array('YasrShortcodesAjax', 'rankingData'));
41
  }
42
 
43
  //VV save rating
48
  add_action('wp_ajax_yasr_visitor_multiset_field_vote', array($this, 'saveMV'));
49
  add_action('wp_ajax_nopriv_yasr_visitor_multiset_field_vote', array($this, 'saveMV'));
50
 
 
51
  //VV load stats
52
+ if(YASR_VISITORS_STATS === 'yes') {
53
  add_action('wp_ajax_yasr_stats_visitors_votes', array($this, 'returnVVStats'));
54
  add_action('wp_ajax_nopriv_yasr_stats_visitors_votes', array($this, 'returnVVStats'));
55
  }
229
  public static function returnArrayVisitorVotes() {
230
  $post_id = false;
231
  if (isset($_GET['post_id'])) {
232
+ $post_id = (int)$_GET['post_id'];
233
  }
234
 
235
  //default values
606
 
607
  }
608
 
609
+
610
+ /**
611
+ * This function returns ranking data for both rest and ajax requests
612
+ *
613
+ * @author Dario Curvino <@dudo>
614
+ * @since 2.7.9
615
+ * @param bool|string $source
616
+ * @param bool|array $request
617
+ *
618
+ * @return array|false|false[]
619
+ */
620
+ public static function rankingData($source=false, $request=false) {
621
+ $is_ajax = false;
622
+
623
+ if (isset($_GET['action']) && isset($_GET['source']) && isset($_GET['nonce_rankings'])) {
624
+ if (!wp_verify_nonce($_GET['nonce_rankings'], 'yasr_nonce_rankings')) {
625
+ die('Security check');
626
+ }
627
+ $request = $_GET;
628
+ $source = (string)$_GET['source'];
629
+ $is_ajax = true;
630
+ }
631
+
632
+ $data_to_return = array(
633
+ 'source' => $source
634
+ );
635
+
636
+ //hook here to add more params
637
+ $sql_params = apply_filters('yasr_filter_ranking_request', false, $request);
638
+
639
+ if($source === 'overall_rating') {
640
+ $overall_data = YasrRankingData::rankingOverallGetResults($sql_params);
641
+ if($overall_data === false){
642
+ $data_to_return = false;
643
+ }
644
+ else {
645
+ $data_to_return['data_overall'] = YasrRankings::rankingData($overall_data);
646
+ }
647
+ }
648
+
649
+ if($source === 'visitor_votes') {
650
+ //outside 'most', only 'highest' is allowed
651
+ $ranking = ($request['show'] === 'highest') ? $request['show'] : 'most';
652
+ $data_to_return['show'] = $ranking;
653
+
654
+ $vv_data = YasrRankingData::rankingVVGetResults($sql_params, $ranking);
655
+ if ($vv_data === false) {
656
+ $data_to_return = false;
657
+ }
658
+ else {
659
+ $data_to_return['data_vv'] = YasrRankings::rankingData($vv_data);
660
+ }
661
+ }
662
+
663
+ if($source === 'author_multi') {
664
+ $am_data = YasrRankingData::rankingMulti($request['setid'], $sql_params);
665
+ if($am_data === false){
666
+ $data_to_return = false;
667
+ }
668
+ else {
669
+ $data_to_return['data_mv'] = YasrRankings::rankingData($am_data);
670
+ }
671
+ }
672
+
673
+ if($source === 'visitor_multi') {
674
+ //outside 'most', only 'highest' is allowed
675
+ $ranking = ($request['show'] === 'highest') ? $request['show'] : 'most';
676
+ $data_to_return['show'] = $ranking;
677
+
678
+ $vm_data = YasrRankingData::rankingMultiVV($request['setid'], $ranking, $sql_params);
679
+ if($vm_data === false){
680
+ $data_to_return = false;
681
+ }
682
+ else {
683
+ $data_to_return['data_vv'] = YasrRankings::rankingData($vm_data);
684
+ }
685
+ }
686
+
687
+ //Use this hook to works with more $sources
688
+ $data_to_return = apply_filters('yasr_add_sources_ranking_request', $data_to_return, $source, $request, $sql_params);
689
+
690
+ //if this is coming from an ajax request
691
+ if($is_ajax === true) {
692
+ echo json_encode($data_to_return);
693
+ die();
694
+ }
695
+
696
+ return $data_to_return;
697
+
698
+ }
699
  }
readme.txt CHANGED
@@ -3,9 +3,9 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
3
  Tags: rating, rate post, rate page, star rating, google rating, votes
4
  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.8
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
@@ -180,6 +180,9 @@ Also [read this](https://webmasters.googleblog.com/2019/09/making-review-rich-re
180
  If you set up everythings fine, in 99% of cases your stars will appear in a week.
181
  If doesn't, you should work on your seo reputation.
182
 
 
 
 
183
  == Screenshots ==
184
  1. Example of Yasr Overall Rating and Yast Visitor Votes shortcodes
185
  2. Yasr Multi Set
@@ -191,6 +194,9 @@ If doesn't, you should work on your seo reputation.
191
 
192
  The full changelog can be found in the plugin's directory. Recent entries:
193
 
 
 
 
194
  = 2.7.8 =
195
  * FIXED: error when "Load results with AJAX?" is enabled, and the attribute "readonly" is set to yasr_visitor_votes shortcode
196
  * TWEAKED: css minor changes
3
  Tags: rating, rate post, rate page, star rating, google rating, votes
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
+ Tested up to: 5.8
7
  Requires PHP: 5.4
8
+ Stable tag: 2.7.9
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
180
  If you set up everythings fine, in 99% of cases your stars will appear in a week.
181
  If doesn't, you should work on your seo reputation.
182
 
183
+ = Does it work with PHP 8? =
184
+ Yes, YASR is 100% fully compatible with PHP 8
185
+
186
  == Screenshots ==
187
  1. Example of Yasr Overall Rating and Yast Visitor Votes shortcodes
188
  2. Yasr Multi Set
194
 
195
  The full changelog can be found in the plugin's directory. Recent entries:
196
 
197
+ = 2.7.9 =
198
+ * FIXED: missing stats in some circumstances for yasr_visitor_votes shortcode
199
+
200
  = 2.7.8 =
201
  * FIXED: error when "Load results with AJAX?" is enabled, and the attribute "readonly" is set to yasr_visitor_votes shortcode
202
  * TWEAKED: css minor changes
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.8
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.8' );
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.9
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.9' );
80
  //Plugin absolute path
81
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
82
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );