Yasr – Yet Another Stars Rating - Version 3.0.3

Version Description

  • FIX: if parameter 'show_average' is enabled on a multi set, a duplicate query was run.
  • TWEAKED: loader image has height and width attributes set.
  • TWEAKED: minor changes
Download this release

Release Info

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

Code changes from version 3.0.2 to 3.0.3

admin/classes/YasrOnInstall.php CHANGED
@@ -22,7 +22,7 @@ if (!defined('ABSPATH')) {
22
  } // Exit if accessed directly
23
 
24
  if (!current_user_can('manage_options')) {
25
- wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
26
  }
27
 
28
  /**
@@ -192,4 +192,4 @@ class YasrOnInstall {
192
 
193
  }
194
 
195
- }
22
  } // Exit if accessed directly
23
 
24
  if (!current_user_can('manage_options')) {
25
+ wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
26
  }
27
 
28
  /**
192
 
193
  }
194
 
195
+ }
admin/classes/Yasr_WP_List_Table.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  /**
3
  * Base class for displaying a list of items in an ajaxified HTML table.
4
  *
1
  <?php
2
+
3
+ if (!defined('ABSPATH')) {
4
+ exit('You\'re not allowed to see this page');
5
+ } // Exit if accessed directly
6
+
7
  /**
8
  * Base class for displaying a list of items in an ajaxified HTML table.
9
  *
admin/editor/yasr-metabox-multiple-rating.php CHANGED
@@ -57,7 +57,7 @@ if ($n_multi_set > 1) {
57
 
58
  <?php
59
 
60
- } //End if if ($n_multi_set>1)
61
 
62
  ?>
63
 
@@ -69,9 +69,10 @@ if ($n_multi_set > 1) {
69
 
70
  <input type="hidden" name="yasr_multiset_author_votes" id="yasr-multiset-author-votes" value="">
71
  <input type="hidden" name="yasr_multiset_id" id="yasr-multiset-id" value="">
 
 
72
 
73
  <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin">
74
-
75
  </table>
76
 
77
  <div class="yasr-multi-set-admin-explain">
@@ -87,7 +88,6 @@ if ($n_multi_set > 1) {
87
 
88
  echo wp_kses_post($text_multiset);
89
  ?>
90
-
91
  </div>
92
  </div>
93
 
@@ -121,8 +121,8 @@ if ($n_multi_set > 1) {
121
  <div class="yasr-metabox-editor-pro-only-box-padding">
122
  <div class="yasr-metabox-editor-title-pro-only">
123
  <?php
124
- esc_html_e('Pro Only features', 'yet-another-stars-rating');
125
- echo '&nbsp;'.YASR_LOCKED_FEATURE;
126
  ?>
127
  </div>
128
 
@@ -130,7 +130,7 @@ if ($n_multi_set > 1) {
130
  <div class="yasr-settings-col-30">
131
  <div class="yasr-metabox-editor-title">
132
  <?php
133
- esc_html_e('Insert this Multi Set in the comment form?', 'yet-another-stars-rating');
134
  ?>
135
  </div>
136
  <div class="yasr-onoffswitch-big" id="yasr-pro-multiset-review-switcher-container">
@@ -140,11 +140,11 @@ if ($n_multi_set > 1) {
140
  value='yes'
141
  id="yasr-pro-multiset-review-switcher"
142
  <?php
143
- //required to check !== otherwise setid=0 is checked even if not enabled
144
- if ($post->yasr_pro_review_setid !== '' && (int)$post->yasr_pro_review_setid === $set_id) {
145
- echo " checked='checked' ";
146
- }
147
- echo YASR_LOCKED_FEATURE_HTML_ATTRIBUTE;
148
  ?>
149
  >
150
  <label class="yasr-onoffswitch-label" for="yasr-pro-multiset-review-switcher">
@@ -154,38 +154,54 @@ if ($n_multi_set > 1) {
154
  </div>
155
  <div class="yasr-element-row-container-description">
156
  <?php
157
- esc_html_e('By enabling this, all ratings fields will be mandatory.',
158
- 'yet-another-stars-rating')
159
  ?>
160
  </div>
161
  </div>
162
 
163
  <div class="yasr-settings-col-65">
164
  <div class="yasr-metabox-editor-title">
165
- <?php
166
- esc_html_e('Shortcodes', 'yet-another-stars-rating');
167
- ?>
168
  </div>
169
 
170
  <div>
171
- <span title="<?php esc_attr_e('Copy Shortcode', 'yet-another-stars-rating') ?>">
172
- <code id="yasr-editor-copy-average-multiset" class="yasr-copy-shortcode">
173
- [yasr_pro_average_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
174
- </span>
175
-
176
- <?php esc_html_e('Use this shortcode to print only the average of '); ?>
177
- [yasr_multiset setid=<span class="yasr-editor-multiset-id"></span>]
 
 
178
  </div>
179
 
180
  <p></p>
 
181
  <div>
182
- <span title="<?php esc_attr_e('Copy Shortcode', 'yet-another-stars-rating') ?>">
183
- <code id="yasr-editor-copy-average-vvmultiset" class="yasr-copy-shortcode">
184
- [yasr_pro_average_visitor_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
185
- </span>
 
 
 
 
 
 
186
 
187
- <?php esc_html_e('Use this shortcode to print only the average of '); ?>
188
- [yasr_visitor_multiset setid=<span class="yasr-editor-multiset-id"></span>]
 
 
 
 
 
 
 
 
 
189
  </div>
190
  </div>
191
  </div>
57
 
58
  <?php
59
 
60
+ } //End if ($n_multi_set>1)
61
 
62
  ?>
63
 
69
 
70
  <input type="hidden" name="yasr_multiset_author_votes" id="yasr-multiset-author-votes" value="">
71
  <input type="hidden" name="yasr_multiset_id" id="yasr-multiset-id" value="">
72
+ <input type="hidden" name="yasr_pro_review_setid" id="yasr-pro-review-setid"
73
+ value="<?php esc_attr_e($post->yasr_pro_review_setid) ?>">
74
 
75
  <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin">
 
76
  </table>
77
 
78
  <div class="yasr-multi-set-admin-explain">
88
 
89
  echo wp_kses_post($text_multiset);
90
  ?>
 
91
  </div>
92
  </div>
93
 
121
  <div class="yasr-metabox-editor-pro-only-box-padding">
122
  <div class="yasr-metabox-editor-title-pro-only">
123
  <?php
124
+ esc_html_e('Pro Only features', 'yet-another-stars-rating');
125
+ echo '&nbsp;'.YASR_LOCKED_FEATURE;
126
  ?>
127
  </div>
128
 
130
  <div class="yasr-settings-col-30">
131
  <div class="yasr-metabox-editor-title">
132
  <?php
133
+ esc_html_e('Insert this Multi Set in the comment form?', 'yet-another-stars-rating');
134
  ?>
135
  </div>
136
  <div class="yasr-onoffswitch-big" id="yasr-pro-multiset-review-switcher-container">
140
  value='yes'
141
  id="yasr-pro-multiset-review-switcher"
142
  <?php
143
+ //required to check !== otherwise setid=0 is checked even if not enabled
144
+ if ($post->yasr_pro_review_setid !== '' && (int)$post->yasr_pro_review_setid === $set_id) {
145
+ echo " checked='checked' ";
146
+ }
147
+ echo YASR_LOCKED_FEATURE_HTML_ATTRIBUTE;
148
  ?>
149
  >
150
  <label class="yasr-onoffswitch-label" for="yasr-pro-multiset-review-switcher">
154
  </div>
155
  <div class="yasr-element-row-container-description">
156
  <?php
157
+ esc_html_e('By enabling this, all ratings fields will be mandatory.',
158
+ 'yet-another-stars-rating')
159
  ?>
160
  </div>
161
  </div>
162
 
163
  <div class="yasr-settings-col-65">
164
  <div class="yasr-metabox-editor-title">
165
+ <?php esc_html_e('Shortcodes', 'yet-another-stars-rating'); ?>
 
 
166
  </div>
167
 
168
  <div>
169
+ <span title="<?php esc_attr_e('Copy Shortcode', 'yet-another-stars-rating') ?>">
170
+ <code id="yasr-editor-copy-average-multiset" class="yasr-copy-shortcode">
171
+ [yasr_pro_average_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
172
+ </span>
173
+
174
+ <span>
175
+ <?php esc_html_e('Use this shortcode to print only the average of '); ?>
176
+ [yasr_multiset setid=<span class="yasr-editor-multiset-id"></span>]
177
+ </span>
178
  </div>
179
 
180
  <p></p>
181
+
182
  <div>
183
+ <span title="<?php esc_attr_e('Copy Shortcode', 'yet-another-stars-rating') ?>">
184
+ <code id="yasr-editor-copy-average-vvmultiset" class="yasr-copy-shortcode">
185
+ [yasr_pro_average_visitor_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
186
+ </span>
187
+
188
+ <span>
189
+ <?php esc_html_e('Use this shortcode to print only the average of '); ?>
190
+ [yasr_visitor_multiset setid=<span class="yasr-editor-multiset-id"></span>]
191
+ </span>
192
+ </div>
193
 
194
+ <p></p>
195
+
196
+ <div>
197
+ <span title="<?php esc_attr_e('Copy Shortcode', 'yet-another-stars-rating') ?>">
198
+ <code id="yasr-editor-copy-comments-multiset" class="yasr-copy-shortcode">
199
+ [yasr_pro_average_comments_multiset setid=<span class="yasr-editor-multiset-id"></span>]</code>
200
+ </span>
201
+
202
+ <span>
203
+ <?php esc_html_e('This shortcode will print a Multi Set with all the ratings given through the comment form '); ?>
204
+ </span>
205
  </div>
206
  </div>
207
  </div>
admin/js/src/yasr-editor-screen.js CHANGED
@@ -209,16 +209,19 @@ function yasrSwitchItemTypeDiv (itemType) {
209
 
210
  function yasrAdminMultiSet() {
211
 
212
- let divContainer = document.getElementById('yasr-editor-multiset-container');
213
- let nMultiSet = parseInt(divContainer.getAttribute('data-nmultiset'));
214
- let setId = parseInt(divContainer.getAttribute('data-setid'));
215
- let postId = parseInt(divContainer.getAttribute('data-postid'));
216
- const copyRoMultiset = document.getElementById('yasr-editor-copy-readonly-multiset');
217
- const copyVisitorMultiset = document.getElementById('yasr-editor-copy-visitor-multiset');
218
- const copyAverageMultiSet = document.getElementById('yasr-editor-copy-average-multiset');
219
- const copyAverageVVMultiSet = document.getElementById('yasr-editor-copy-average-vvmultiset');
220
- const reviewsEnabled = document.getElementById('yasr-pro-comments-enabled-yes');
221
- const multiSetinReview = document.getElementById('yasr-pro-multiset-review-switcher');
 
 
 
222
 
223
 
224
  yasrPrintAdminMultiSet(setId, postId, nMultiSet);
@@ -243,6 +246,11 @@ function yasrAdminMultiSet() {
243
  copyToClipboard(el.textContent.trim());
244
  }
245
 
 
 
 
 
 
246
  //add event listener to synchronize switchers
247
  if(multiSetinReview !== null) {
248
 
@@ -258,7 +266,8 @@ function yasrAdminMultiSet() {
258
 
259
  //when multiset switcher is enabled, enable also reviews in comment switcher
260
  multiSetinReview.addEventListener('change', (event) => {
261
- if (event.currentTarget.checked) {
 
262
  //if it is classic editor, check reviewsEnabled on true
263
  if(reviewsEnabled !== null) {
264
  reviewsEnabled.checked = true;
@@ -266,6 +275,17 @@ function yasrAdminMultiSet() {
266
  //if this is gutenberg, use document.getElementById on change to get the current state and check it
267
  document.getElementById('yasr-comment-reviews-disabled-switch').checked = true;
268
  }
 
 
 
 
 
 
 
 
 
 
 
269
  }
270
  });
271
 
@@ -282,6 +302,18 @@ function yasrAdminMultiSet() {
282
 
283
  yasrPrintAdminMultiSet(setId, postId, nMultiSet);
284
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  return false; // prevent default click action from happening!
286
  });
287
 
@@ -339,12 +371,10 @@ function yasrReturnTableMultiset (yasrMultiSetValue, table, authorMultiset=true)
339
  for (let i = 0; i < yasrMultiSetValue.length; i++) {
340
  let valueName = yasrMultiSetValue[i]['name'];
341
  let valueRating = 0;
342
- let loader = '';
343
  let readonly = true;
344
 
345
  if(authorMultiset !== false) {
346
  valueRating = yasrMultiSetValue[i]['average_rating'];
347
- loader = '<img src="' + yasrCommonData.loaderHtml + '" alt="yasr-loader"></span>';
348
  readonly = false;
349
  }
350
 
@@ -368,11 +398,7 @@ function yasrReturnTableMultiset (yasrMultiSetValue, table, authorMultiset=true)
368
  }
369
 
370
  //Rater for multiset
371
- function yasrSetRaterAdminMulti(setId) {
372
-
373
- //update hidden field
374
- document.getElementById('yasr-multiset-id').value = setId;
375
-
376
  let yasrMultiSetAdmin = document.getElementsByClassName('yasr-multiset-admin');
377
 
378
  //an array with all the ratings objects
@@ -427,7 +453,6 @@ function yasrSetRaterAdminMulti(setId) {
427
  })(i);
428
 
429
  } //End for
430
-
431
  }//End function
432
 
433
  /****** End Yasr Metabox Multple Rating ******/
209
 
210
  function yasrAdminMultiSet() {
211
 
212
+ let divContainer = document.getElementById('yasr-editor-multiset-container');
213
+ let nMultiSet = parseInt(divContainer.getAttribute('data-nmultiset'));
214
+ let setId = parseInt(divContainer.getAttribute('data-setid'));
215
+ let postId = parseInt(divContainer.getAttribute('data-postid'));
216
+ //do not use parseInt here, or an empty value will be converted to 0
217
+ const yasrProReviewSetid = document.getElementById('yasr-pro-review-setid');
218
+ const copyRoMultiset = document.getElementById('yasr-editor-copy-readonly-multiset');
219
+ const copyVisitorMultiset = document.getElementById('yasr-editor-copy-visitor-multiset');
220
+ const copyAverageMultiSet = document.getElementById('yasr-editor-copy-average-multiset');
221
+ const copyAverageVVMultiSet = document.getElementById('yasr-editor-copy-average-vvmultiset');
222
+ const copyAverageCommentsMulti = document.getElementById('yasr-editor-copy-comments-multiset');
223
+ const reviewsEnabled = document.getElementById('yasr-pro-comments-enabled-yes');
224
+ const multiSetinReview = document.getElementById('yasr-pro-multiset-review-switcher');
225
 
226
 
227
  yasrPrintAdminMultiSet(setId, postId, nMultiSet);
246
  copyToClipboard(el.textContent.trim());
247
  }
248
 
249
+ copyAverageCommentsMulti.onclick = function (event) {
250
+ let el = document.getElementById(event.target.id);
251
+ copyToClipboard(el.textContent.trim());
252
+ }
253
+
254
  //add event listener to synchronize switchers
255
  if(multiSetinReview !== null) {
256
 
266
 
267
  //when multiset switcher is enabled, enable also reviews in comment switcher
268
  multiSetinReview.addEventListener('change', (event) => {
269
+ console.log(event.currentTarget);
270
+ if (event.currentTarget.checked === true) {
271
  //if it is classic editor, check reviewsEnabled on true
272
  if(reviewsEnabled !== null) {
273
  reviewsEnabled.checked = true;
275
  //if this is gutenberg, use document.getElementById on change to get the current state and check it
276
  document.getElementById('yasr-comment-reviews-disabled-switch').checked = true;
277
  }
278
+
279
+ //update the hidden field, if only one multiset is used
280
+ if(yasrProReviewSetid !== null) {
281
+ yasrProReviewSetid.value = setId;
282
+ }
283
+ }
284
+ else {
285
+ //update the hidden field, if only one multiset is used
286
+ if(yasrProReviewSetid !== null) {
287
+ yasrProReviewSetid.value = '';
288
+ }
289
  }
290
  });
291
 
302
 
303
  yasrPrintAdminMultiSet(setId, postId, nMultiSet);
304
 
305
+ //update hidden field
306
+ document.getElementById('yasr-multiset-id').value = setId;
307
+
308
+ if(yasrProReviewSetid !== null && yasrProReviewSetid !== '') {
309
+ if(yasrProReviewSetid.value === setId) {
310
+ //update hidden field
311
+ multiSetinReview.checked = true;
312
+ } else {
313
+ multiSetinReview.checked = false;
314
+ }
315
+ }
316
+
317
  return false; // prevent default click action from happening!
318
  });
319
 
371
  for (let i = 0; i < yasrMultiSetValue.length; i++) {
372
  let valueName = yasrMultiSetValue[i]['name'];
373
  let valueRating = 0;
 
374
  let readonly = true;
375
 
376
  if(authorMultiset !== false) {
377
  valueRating = yasrMultiSetValue[i]['average_rating'];
 
378
  readonly = false;
379
  }
380
 
398
  }
399
 
400
  //Rater for multiset
401
+ function yasrSetRaterAdminMulti() {
 
 
 
 
402
  let yasrMultiSetAdmin = document.getElementsByClassName('yasr-multiset-admin');
403
 
404
  //an array with all the ratings objects
453
  })(i);
454
 
455
  } //End for
 
456
  }//End function
457
 
458
  /****** End Yasr Metabox Multple Rating ******/
admin/js/src/yasr-settings-page.js CHANGED
@@ -146,8 +146,8 @@ if (activeTab === 'migration_tools') {
146
  jQuery('#yasr-import-ratemypost-submit').on('click', function () {
147
 
148
  //show loader on click
149
- document.getElementById('yasr-import-ratemypost-answer').innerHTML = '<img src="'
150
- + yasrCommonData.loaderHtml + '"</img>';
151
 
152
  var nonce = document.getElementById('yasr-import-rmp-nonce').value;
153
 
@@ -166,8 +166,8 @@ if (activeTab === 'migration_tools') {
166
  jQuery('#yasr-import-wppr-submit').on('click', function () {
167
 
168
  //show loader on click
169
- document.getElementById('yasr-import-wppr-answer').innerHTML = '<img src="'
170
- + yasrCommonData.loaderHtml + '"</img>';
171
 
172
  var nonce = document.getElementById('yasr-import-wppr-nonce').value;
173
 
@@ -186,8 +186,8 @@ if (activeTab === 'migration_tools') {
186
  jQuery('#yasr-import-kksr-submit').on('click', function () {
187
 
188
  //show loader on click
189
- document.getElementById('yasr-import-kksr-answer').innerHTML = '<img src="'
190
- + yasrCommonData.loaderHtml + '"</img>';
191
 
192
  var nonce = document.getElementById('yasr-import-kksr-nonce').value;
193
 
@@ -207,8 +207,8 @@ if (activeTab === 'migration_tools') {
207
  jQuery('#yasr-import-mr-submit').on('click', function () {
208
 
209
  //show loader on click
210
- document.getElementById('yasr-import-mr-answer').innerHTML = '<img src="'
211
- + yasrCommonData.loaderHtml + '"</img>';
212
 
213
  var nonce = document.getElementById('yasr-import-mr-nonce').value;
214
 
146
  jQuery('#yasr-import-ratemypost-submit').on('click', function () {
147
 
148
  //show loader on click
149
+ document.getElementById('yasr-import-ratemypost-answer').innerHTML =
150
+ '<img src="' + yasrCommonData.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
151
 
152
  var nonce = document.getElementById('yasr-import-rmp-nonce').value;
153
 
166
  jQuery('#yasr-import-wppr-submit').on('click', function () {
167
 
168
  //show loader on click
169
+ document.getElementById('yasr-import-wppr-answer').innerHTML =
170
+ '<img src="' + yasrCommonData.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
171
 
172
  var nonce = document.getElementById('yasr-import-wppr-nonce').value;
173
 
186
  jQuery('#yasr-import-kksr-submit').on('click', function () {
187
 
188
  //show loader on click
189
+ document.getElementById('yasr-import-kksr-answer').innerHTML =
190
+ '<img src="' + yasrCommonData.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
191
 
192
  var nonce = document.getElementById('yasr-import-kksr-nonce').value;
193
 
207
  jQuery('#yasr-import-mr-submit').on('click', function () {
208
 
209
  //show loader on click
210
+ document.getElementById('yasr-import-mr-answer').innerHTML =
211
+ '<img src="' + yasrCommonData.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
212
 
213
  var nonce = document.getElementById('yasr-import-mr-nonce').value;
214
 
admin/js/yasr-editor-screen.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";const e=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)};function t(e,t,n=!1,o=.1,a=!0,i=!1,s=!1){let r;r=n||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:r,step:o,readOnly:a,rating:i,rateCallback:s})}var n;tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var o=new Uint8Array(16);function a(){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)}const 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,s=function(e){return"string"==typeof e&&i.test(e)};for(var r=[],l=0;l<256;++l)r.push((l+256).toString(16).substr(1));const d=function(e,t,n){var o=(e=e||{}).random||(e.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=o[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n}(o)};function y(e){"Product"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"LocalBusiness"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Recipe"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"SoftwareApplication"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Book"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Movie"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none"):document.getElementById("yasr-metabox-info-snippet-container").style.display="none"}function c(e,n,o){const a={action:"yasr_send_id_nameset",set_id:e,post_id:n};return jQuery.post(ajaxurl,a,(function(n){o>1&&(document.getElementById("yasr-loader-select-multi-set").style.display="none");let a=JSON.parse(n),i=document.getElementById("yasr-table-multi-set-admin"),s=document.getElementById("yasr-table-multi-set-admin-visitor");m(a,i),m(a,s,!1),function(e){document.getElementById("yasr-multiset-id").value=e;let n=document.getElementsByClassName("yasr-multiset-admin"),o=[],a=!1;for(let e=0;e<n.length;e++)!function(e){let i=n.item(e).id,s=document.getElementById(i),r=parseInt(s.getAttribute("data-multi-idfield")),l=parseInt(s.getAttribute("data-rating")),d="true"===s.getAttribute("data-readonly"),y={field:r,rating:l};o.push(y),t(32,i,!1,.5,d,!1,(function(e,t){e=e.toFixed(1),e=parseFloat(e),this.setRating(e);for(let t=0;t<o.length;t++)o[t].field===r&&(o[t].rating=e);a=JSON.stringify(o),document.getElementById("yasr-multiset-author-votes").value=a,t()}))}(e)}(e);let r=document.getElementsByClassName("yasr-editor-multiset-id");for(let t=0;t<r.length;t++)r[t].innerText=e})),!1}function m(e,t,n=!0){let o="";for(let t=0;t<e.length;t++){let a=e[t].name,i=0,s="",r=!0;!1!==n&&(i=e[t].average_rating,s='<img src="'+yasrCommonData.loaderHtml+'" alt="yasr-loader"></span>',r=!1);let l=e[t].id;o+="<tr>",o+="<td>"+a+"</td>",o+='<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-'+d()+'" data-rating="'+i+'" data-multi-idfield="'+l+'" data-readonly="'+r+'"></div>',o+="</td>",o+="</tr>"}!1===n&&(o+='<tr><td colspan="2"><input type="submit" class="button button-primary" value="Submit!" disabled></td></tr>'),t.innerHTML=o}document.addEventListener("DOMContentLoaded",(function(t){var n;!0!==document.body.classList.contains("block-editor-page")&&(function(){let t=parseFloat(document.getElementById("yasr-overall-rating-value").value);const n=document.getElementById("yasr-editor-copy-overall");null!==n&&(n.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())}),raterJs({starSize:32,step:.1,showToolTip:!1,rating:t,readOnly:!1,element:document.getElementById("yasr-rater-overall"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),document.getElementById("yasr-overall-rating-value").value=e,this.setRating(e);document.getElementById("yasr_overall_text").textContent="You've rated "+e,t()}})}(),n={action:"yasr_create_shortcode"},jQuery.get(ajaxurl,n,(function(e){jQuery(e).appendTo("body").hide(),function(){let e=!1;null!==document.getElementById("yasr-editor-multiset-container")&&(e=!0);const t=document.getElementById("yasr-tinypopup-link-doc");jQuery("#yasr-link-tab-main").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-main").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-main").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-link-tab-charts").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-charts").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-charts").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-rankings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-overall").on("click",(function(){jQuery("#yasr-overall-choose-size").toggle("slow")})),jQuery("#yasr-visitor-votes").on("click",(function(){jQuery("#yasr-visitor-choose-size").toggle("slow")})),jQuery(".yasr-tinymce-shortcode-buttons").on("click",(function(){let e=this.getAttribute("data-shortcode");null==tinyMCE.activeEditor?jQuery("#content").append(e):tinyMCE.activeEditor.execCommand("mceInsertContent",0,e),tb_remove()})),!0===e&&jQuery("#yasr-insert-multiset-select").on("change",(function(){var e=jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();let t;t=jQuery("#yasr-allow-vote-multiset").is(":checked")?"[yasr_multiset setid=":"[yasr_visitor_multiset setid=",t+=e,jQuery("#yasr-hide-average-multiset").is(":checked")&&(t+=" show_average='no'"),t+="]",null==tinyMCE.activeEditor?jQuery("#content").append(t):tinyMCE.activeEditor.execCommand("mceInsertContent",0,t),tb_remove()}))}()}))),function(){jQuery("#yasr-metabox-below-editor-structured-data-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-structured-data-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-structured-data").show()})),jQuery("#yasr-metabox-below-editor-multiset-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-multiset-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-multiset").show()}));let t=document.getElementById("yasr-metabox-below-editor-select-schema").value;null!==document.getElementById("yasr-editor-multiset-container")&&function(){let t=document.getElementById("yasr-editor-multiset-container"),n=parseInt(t.getAttribute("data-nmultiset")),o=parseInt(t.getAttribute("data-setid")),a=parseInt(t.getAttribute("data-postid"));const i=document.getElementById("yasr-editor-copy-readonly-multiset"),s=document.getElementById("yasr-editor-copy-visitor-multiset"),r=document.getElementById("yasr-editor-copy-average-multiset"),l=document.getElementById("yasr-editor-copy-average-vvmultiset"),d=document.getElementById("yasr-pro-comments-enabled-yes"),y=document.getElementById("yasr-pro-multiset-review-switcher");c(o,a,n),i.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},s.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},r.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},l.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},null!==y&&(null!==d&&d.addEventListener("change",(e=>{e.currentTarget.checked||(y.checked=!1)})),y.addEventListener("change",(e=>{e.currentTarget.checked&&(null!==d?d.checked=!0:document.getElementById("yasr-comment-reviews-disabled-switch").checked=!0)}))),n>1&&jQuery("#yasr_select_set").on("change",(function(){return o=jQuery("#yasr_select_set").val(),jQuery("#yasr-loader-select-multi-set").show(),c(o,a,n),!1}))}(),y(t)}()})),document.getElementById("yasr-metabox-below-editor-select-schema").addEventListener("change",(function(){y(this.value)}))})();
1
+ (()=>{"use strict";const e=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)};function t(e,t,n=!1,o=.1,a=!0,i=!1,s=!1){let r;r=n||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:r,step:o,readOnly:a,rating:i,rateCallback:s})}var n;tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var o=new Uint8Array(16);function a(){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)}const 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,s=function(e){return"string"==typeof e&&i.test(e)};for(var r=[],l=0;l<256;++l)r.push((l+256).toString(16).substr(1));const d=function(e,t,n){var o=(e=e||{}).random||(e.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=o[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n}(o)};function y(e){"Product"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"LocalBusiness"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Recipe"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"SoftwareApplication"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Book"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="none"):"Movie"===e?(document.getElementById("yasr-metabox-info-snippet-container").style.display="",document.getElementById("yasr-metabox-info-snippet-container-movie").style.display="",document.getElementById("yasr-metabox-info-snippet-container-recipe").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-localbusiness").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-product").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-software").style.display="none",document.getElementById("yasr-metabox-info-snippet-container-book").style.display="none"):document.getElementById("yasr-metabox-info-snippet-container").style.display="none"}function c(e,n,o){const a={action:"yasr_send_id_nameset",set_id:e,post_id:n};return jQuery.post(ajaxurl,a,(function(n){o>1&&(document.getElementById("yasr-loader-select-multi-set").style.display="none");let a=JSON.parse(n),i=document.getElementById("yasr-table-multi-set-admin"),s=document.getElementById("yasr-table-multi-set-admin-visitor");m(a,i),m(a,s,!1),function(){let e=document.getElementsByClassName("yasr-multiset-admin"),n=[],o=!1;for(let a=0;a<e.length;a++)!function(a){let i=e.item(a).id,s=document.getElementById(i),r=parseInt(s.getAttribute("data-multi-idfield")),l=parseInt(s.getAttribute("data-rating")),d="true"===s.getAttribute("data-readonly"),y={field:r,rating:l};n.push(y),t(32,i,!1,.5,d,!1,(function(e,t){e=e.toFixed(1),e=parseFloat(e),this.setRating(e);for(let t=0;t<n.length;t++)n[t].field===r&&(n[t].rating=e);o=JSON.stringify(n),document.getElementById("yasr-multiset-author-votes").value=o,t()}))}(a)}();let r=document.getElementsByClassName("yasr-editor-multiset-id");for(let t=0;t<r.length;t++)r[t].innerText=e})),!1}function m(e,t,n=!0){let o="";for(let t=0;t<e.length;t++){let a=e[t].name,i=0,s=!0;!1!==n&&(i=e[t].average_rating,s=!1);let r=e[t].id;o+="<tr>",o+="<td>"+a+"</td>",o+='<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-'+d()+'" data-rating="'+i+'" data-multi-idfield="'+r+'" data-readonly="'+s+'"></div>',o+="</td>",o+="</tr>"}!1===n&&(o+='<tr><td colspan="2"><input type="submit" class="button button-primary" value="Submit!" disabled></td></tr>'),t.innerHTML=o}document.addEventListener("DOMContentLoaded",(function(t){var n;!0!==document.body.classList.contains("block-editor-page")&&(function(){let t=parseFloat(document.getElementById("yasr-overall-rating-value").value);const n=document.getElementById("yasr-editor-copy-overall");null!==n&&(n.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())}),raterJs({starSize:32,step:.1,showToolTip:!1,rating:t,readOnly:!1,element:document.getElementById("yasr-rater-overall"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),document.getElementById("yasr-overall-rating-value").value=e,this.setRating(e);document.getElementById("yasr_overall_text").textContent="You've rated "+e,t()}})}(),n={action:"yasr_create_shortcode"},jQuery.get(ajaxurl,n,(function(e){jQuery(e).appendTo("body").hide(),function(){let e=!1;null!==document.getElementById("yasr-editor-multiset-container")&&(e=!0);const t=document.getElementById("yasr-tinypopup-link-doc");jQuery("#yasr-link-tab-main").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-main").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-main").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-basics-shortcode/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-link-tab-charts").on("click",(function(){jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-link-tab-charts").addClass("nav-tab-active"),jQuery(".yasr-content-tab-tinymce").hide(),jQuery("#yasr-content-tab-charts").show(),t.setAttribute("href","https://yetanotherstarsrating.com/yasr-rankings/?utm_source=wp-plugin&utm_medium=tinymce-popup&utm_campaign=yasr_editor_screen")})),jQuery("#yasr-overall").on("click",(function(){jQuery("#yasr-overall-choose-size").toggle("slow")})),jQuery("#yasr-visitor-votes").on("click",(function(){jQuery("#yasr-visitor-choose-size").toggle("slow")})),jQuery(".yasr-tinymce-shortcode-buttons").on("click",(function(){let e=this.getAttribute("data-shortcode");null==tinyMCE.activeEditor?jQuery("#content").append(e):tinyMCE.activeEditor.execCommand("mceInsertContent",0,e),tb_remove()})),!0===e&&jQuery("#yasr-insert-multiset-select").on("change",(function(){var e=jQuery("input:radio[name=yasr_tinymce_pick_set]:checked").val();let t;t=jQuery("#yasr-allow-vote-multiset").is(":checked")?"[yasr_multiset setid=":"[yasr_visitor_multiset setid=",t+=e,jQuery("#yasr-hide-average-multiset").is(":checked")&&(t+=" show_average='no'"),t+="]",null==tinyMCE.activeEditor?jQuery("#content").append(t):tinyMCE.activeEditor.execCommand("mceInsertContent",0,t),tb_remove()}))}()}))),function(){jQuery("#yasr-metabox-below-editor-structured-data-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-structured-data-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-structured-data").show()})),jQuery("#yasr-metabox-below-editor-multiset-tab").on("click",(function(e){e.preventDefault(),jQuery(".yasr-nav-tab").removeClass("nav-tab-active"),jQuery("#yasr-metabox-below-editor-multiset-tab").addClass("nav-tab-active"),jQuery(".yasr-metabox-below-editor-content").hide(),jQuery("#yasr-metabox-below-editor-multiset").show()}));let t=document.getElementById("yasr-metabox-below-editor-select-schema").value;null!==document.getElementById("yasr-editor-multiset-container")&&function(){let t=document.getElementById("yasr-editor-multiset-container"),n=parseInt(t.getAttribute("data-nmultiset")),o=parseInt(t.getAttribute("data-setid")),a=parseInt(t.getAttribute("data-postid"));const i=document.getElementById("yasr-pro-review-setid"),s=document.getElementById("yasr-editor-copy-readonly-multiset"),r=document.getElementById("yasr-editor-copy-visitor-multiset"),l=document.getElementById("yasr-editor-copy-average-multiset"),d=document.getElementById("yasr-editor-copy-average-vvmultiset"),y=document.getElementById("yasr-editor-copy-comments-multiset"),m=document.getElementById("yasr-pro-comments-enabled-yes"),u=document.getElementById("yasr-pro-multiset-review-switcher");c(o,a,n),s.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},r.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},l.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},d.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},y.onclick=function(t){let n=document.getElementById(t.target.id);e(n.textContent.trim())},null!==u&&(null!==m&&m.addEventListener("change",(e=>{e.currentTarget.checked||(u.checked=!1)})),u.addEventListener("change",(e=>{console.log(e.currentTarget),!0===e.currentTarget.checked?(null!==m?m.checked=!0:document.getElementById("yasr-comment-reviews-disabled-switch").checked=!0,null!==i&&(i.value=o)):null!==i&&(i.value="")}))),n>1&&jQuery("#yasr_select_set").on("change",(function(){return o=jQuery("#yasr_select_set").val(),jQuery("#yasr-loader-select-multi-set").show(),c(o,a,n),document.getElementById("yasr-multiset-id").value=o,null!==i&&""!==i&&(i.value===o?u.checked=!0:u.checked=!1),!1}))}(),y(t)}()})),document.getElementById("yasr-metabox-below-editor-select-schema").addEventListener("change",(function(){y(this.value)}))})();
admin/js/yasr-settings.js CHANGED
@@ -1 +1 @@
1
- (()=>{var e;if(document.getElementsByClassName("nav-tab-active").length>0&&(e=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===e){var t=document.getElementById("yasr_auto_insert_switch").checked,a=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===t&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===a&&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-rating-saved").value="Rating saved!",document.getElementById("yasr-settings-custom-text-rating-updated").value="Rating updated!",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"===e&&(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"===e){var n=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===n){var r=jQuery("#yasr-edit-form-number-elements").attr("value");r++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(r>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 #'+r+' <input type="text" name="edit-multi-set-element-'+r+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),r++}))}else n>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>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 #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"migration_tools"===e&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})),wp.hooks.doAction("yasr_migration_page_bottom")),"rankings"===e&&wp.hooks.doAction("yasr_ranking_page_top")})(),(()=>{"use strict";let e;var t,a=new Uint8Array(16);function n(){if(!t&&!(t="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 t(a)}const r=/^(?:[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,s=function(e){return"string"==typeof e&&r.test(e)};for(var o=[],i=0;i<256;++i)o.push((i+256).toString(16).substr(1));const l=function(e,t,a){var r=(e=e||{}).random||(e.rng||n)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){a=a||0;for(var i=0;i<16;++i)t[a+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase();if(!s(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function d(e){return d="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},d(e)}function c(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function y(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}var p=wp.i18n.__,g=wp.element.render;function h(e){var t="yasr-ranking-element-"+l(),a=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:t,ref:function(){return function(e,t){var a,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=arguments.length>2&&void 0!==arguments[2]&&arguments[2]||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:a,step:n,readOnly:r,rating:s,rateCallback:o})}(a,t,!1,.1,!0,e.rating)}})}function f(e){if(void 0!==e.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",e.post.number_of_votes,"  ",p("Average:","yet-another-stars-rating")," ",e.post.rating,"]");var t=e.text;return React.createElement("span",{className:"yasr-highest-rated-text"},t," ",e.post.rating)}function v(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===e&&(e=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),e.innerHTML=t;const a=e.textContent;return e.innerHTML="",a}(t.post.title)))}function _(e){var t="after",a=p("Rating:","yet-another-stars-rating"),n=new URLSearchParams(e.rankingParams);return null!==n.get("text_position")&&(t=n.get("text_position")),null!==n.get("custom_txt")&&(a=n.get("custom_txt")),"before"===t?React.createElement("td",{className:e.colClass},React.createElement(f,{post:e.post,tableId:e.tableId,text:a}),React.createElement(h,{rating:e.post.rating,tableId:e.tableId})):React.createElement("td",{className:e.colClass},React.createElement(h,{rating:e.post.rating,tableId:e.tableId}),React.createElement(f,{post:e.post,tableId:e.tableId,text:a}))}function b(e){var t="",a="";return"author_ranking"===e.source?(t="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===e.source&&(t="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:e.trClass},React.createElement(v,{colClass:t,post:e.post}),React.createElement(_,{colClass:a,post:e.post,tableId:e.tableId,rankingParams:e.rankingParams}))}function E(e){return React.createElement("tbody",{id:e.tBodyId,style:{display:e.show}},e.data.map((function(t,a){var n="yasr-rankings-td-colored";return"author_ranking"===e.source&&(n="yasr-rankings-td-white"),a%2==0&&(n="yasr-rankings-td-white","author_ranking"===e.source&&(n="yasr-rankings-td-colored")),React.createElement(b,{key:t.post_id,source:e.source,tableId:e.tableId,rankingParams:e.rankingParams,post:t,trClass:n})})))}var k=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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(o,React.Component);var t,a,n,r,s=(n=o,r=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}}(),function(){var e,t=m(n);if(r){var a=m(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return y(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e)).state={error:null,isLoaded:!1,data:[],tableId:e.tableId,source:e.source,rankingParams:e.params,nonce:e.nonce},t}return t=o,a=[{key:"componentDidMount",value:function(){var e=this,t=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(p("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:t});else if(this.state.source){var n=this.returnRestUrl();Promise.all(n.map((function(e){return fetch(e).then((function(e){return!0===e.ok?e.json():(console.info(p("Ajax Call Failed. Getting data from source")),"KO")})).then((function(e){"KO"===e?a=t:"overall_rating"===e.source||"author_multi"===e.source?a="overall_rating"===e.source?e.data_overall:e.data_mv:a[e.show]=e.data_vv})).catch((function(e){a=t,console.info(p(e))}))}))).then((function(t){e.setState({isLoaded:!0,data:a})})).catch((function(t){console.info(p(t)),e.setState({isLoaded:!0,data:a})}))}else this.setState({error:p("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var e,t=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,n="&nonce_rankings="+this.state.nonce,r="";if(""!==t&&!1!==t){var s=new URLSearchParams(t);null!==s.get("order_by")&&(r+="order_by="+s.get("order_by")),null!==s.get("limit")&&(r+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(r+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(r+="&end_date="+s.get("end_date")),null!==s.get("ctg")?r+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(r+="&cpt="+s.get("cpt")),""!==r&&(r="&"+(r=r.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(r+="&setid="+s.get("setid"))}else r="";if("author_ranking"===a||"author_multi"===a)e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+r+n];else{var o="",i="";if(""!==t){var l=new URLSearchParams(t);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]"))}e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+r+o+n,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+r+i+n]}return e}},{key:"rankingTableHead",value:function(e,t){var a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a;if("author_ranking"!==e){var s=React.createElement("span",null,React.createElement("span",{id:n},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===t&&(s=React.createElement("span",null,React.createElement("span",{id:r},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("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,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(e){e.preventDefault();var t=e.target.id,a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(t),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),t===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)),t===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))}},{key:"rankingTableBody",value:function(){var e=this.state,t=e.data,a=e.source,n=e.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:t,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:n,show:"table-row-group",source:a});var r=t.most,s=t.highest,o="table-row-group",i="none",l="most",d=o,c=i,u=new URLSearchParams(n);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(d=i,c=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:r,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:n,show:d,source:a}),React.createElement(E,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:n,show:c,source:a}))}},{key:"render",value:function(){var e=this.state,t=e.error,a=e.isLoaded;return t?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(t),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}],a&&c(t.prototype,a),Object.defineProperty(t,"prototype",{writable:!1}),o}();function I(){var e=document.getElementsByClassName("yasr-stars-rankings");if(e.length>0)for(var t=0;t<e.length;t++){var a=e.item(t).id,n=JSON.parse(e.item(t).dataset.rankingSource),r=JSON.parse(e.item(t).dataset.rankingParams),s=JSON.parse(e.item(t).dataset.rankingNonce),o=document.getElementById(a);g(React.createElement(k,{source:n,tableId:a,params:r,nonce:s}),o)}}I(),tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var w,B=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(w=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===w){var R,j=function(e){var t=D.value,a=document.getElementById("yasr-builder-shortcode").textContent,n=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];n=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",n),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+t+"&full_shortcode="+a).then((function(e){return!0===e.ok?e.json():(console.info(B("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(e){console.info(e)})).then((function(e){if("KO"!==e){var t=document.createElement("div");t.innerHTML=e,M.childNodes.length>0?M.replaceChild(t,M.childNodes[0]):M.appendChild(t)}})).then((function(e){n.forEach((function(e){t===e&&I()}))}))},x=function(e,t,a,n,r,s,o,i,l){e.style.display="",t.style.display="",s.style.display="",l.style.display="",a.style.display="none",n.style.display="none",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},C=function(e,t,a,n,r,s,o,i,l){a.style.display="",n.style.display="",t.style.display="",s.style.display="",l.style.display="",e.style.display="none",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},Q=function(e,t,a,n,r,s,o,i,l){r.style.display="",l.style.display="none",e.style.display="none",a.style.display="none",n.style.display="none",t.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},T=function(e,t,a,n,r,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(F.className="",F.classList.add("yasr-settings-row-24"),a.style.display="",n.style.display="",e.style.display="none"):(a.style.display="none",n.style.display="none",e.style.display=""),s.style.display="",t.style.display="",d.style.display="",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")},L=".yasr-builder-elements-parents",S=".yasr-builder-elements-childs";jQuery(L).prop("disabled",!0),jQuery(S).prop("disabled",!0),jQuery(L).find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",L,S);var P=[],H={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};R=H.name,document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]");var O=document.getElementById("yasr-builder-button-preview"),N=document.getElementById("yasr-builder-copy-shortcode"),M=document.getElementById("yasr-builder-preview"),D=document.getElementById("yasr-ranking-source"),A=document.getElementById("yasr-ranking-multiset-select"),U=document.getElementById("yasr-builder-datepicker-start"),q=document.getElementById("yasr-builder-datepicker-end"),F=document.getElementById("yasr-builder-params-container"),z=document.getElementById("builder-vv-default-view"),J=document.getElementById("builder-vv-required-votes"),V=document.getElementById("builder-stars-size"),K=document.getElementById("builder-overall-text"),Y=document.getElementById("builder-username-options"),G=document.getElementById("builder-category"),$=document.getElementById("builder-cpt"),W=document.getElementById("yasr-ranking-multiset"),X=document.getElementById("yasr-builder-datepicker"),Z=D.value,ee=!1;U.value="",q.value="","yasr_ov_ranking"===Z?x(K,V,z,J,Y,G,$,W,X):"yasr_most_active_users"===Z||"yasr_top_reviewers"===Z?Q(K,V,z,J,Y,G,$,W,X):"yasr_multi_set_ranking"===Z?T(K,V,z,J,Y,G,$,W,!1,X):"yasr_visitor_multi_set_ranking"===Z?T(K,V,z,J,Y,G,$,W,!0,X):C(K,V,z,J,Y,G,$,W,X),document.addEventListener("change",(function(e){if("yasr-ranking-source"===e.target.id)F.className="",F.classList.add("yasr-settings-row-33"),M.innerHTML="",U.value="",q.value="",H={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"===e.target.value?x(K,V,z,J,Y,G,$,W,X):"yasr_most_active_users"===e.target.value||"yasr_top_reviewers"===e.target.value?Q(K,V,z,J,Y,G,$,W,X):"yasr_multi_set_ranking"===e.target.value?(T(K,V,z,J,Y,G,$,W,!1,X),H.setid=" setid="+A[0].value):"yasr_visitor_multi_set_ranking"===e.target.value?(T(K,V,z,J,Y,G,$,W,!0,X),H.setid=" setid="+A[0].value):C(K,V,z,J,Y,G,$,W,X),H.name=e.target.value,R=H.name+H.setid;else{"yasr-ranking-multiset-select"===e.target.id&&(H.setid=" setid="+e.target.value),P=wp.hooks.applyFilters("yasrBuilderFilterShortcode",H);for(var t=2;H.length;t++)P.hasOwnProperty(H[t])&&(H[t]=P[t]);R=H.name+H.setid+H.rows+H.view+H.minvotesmost+H.minvoteshg+H.size+H.txtPosition+H.txt+H.display+H.start_date+H.end_date+H.category+H.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]"),!0===ee&&"yasr-ranking-source"!==e.target.id&&"yasr-builder-category-radio"!==e.target.name&&j()})),N.onclick=function(e){var t,a;t=document.getElementById(e.target.id).getAttribute("data-shortcode"),(a=document.createElement("textarea")).value=t,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},O.onclick=function(e){j(),ee=!0}}})();
1
+ (()=>{var e;if(document.getElementsByClassName("nav-tab-active").length>0&&(e=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===e){var t=document.getElementById("yasr_auto_insert_switch").checked,a=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===t&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===a&&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-rating-saved").value="Rating saved!",document.getElementById("yasr-settings-custom-text-rating-updated").value="Rating updated!",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"===e&&(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"===e){var n=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===n){var r=jQuery("#yasr-edit-form-number-elements").attr("value");r++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(r>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 #'+r+' <input type="text" name="edit-multi-set-element-'+r+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),r++}))}else n>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>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 #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"migration_tools"===e&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})),wp.hooks.doAction("yasr_migration_page_bottom")),"rankings"===e&&wp.hooks.doAction("yasr_ranking_page_top")})(),(()=>{"use strict";let e;var t,a=new Uint8Array(16);function n(){if(!t&&!(t="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 t(a)}const r=/^(?:[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,s=function(e){return"string"==typeof e&&r.test(e)};for(var o=[],i=0;i<256;++i)o.push((i+256).toString(16).substr(1));const l=function(e,t,a){var r=(e=e||{}).random||(e.rng||n)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){a=a||0;for(var i=0;i<16;++i)t[a+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase();if(!s(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function d(e){return d="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},d(e)}function c(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function y(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}var p=wp.i18n.__,g=wp.element.render;function h(e){var t="yasr-ranking-element-"+l(),a=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:t,ref:function(){return function(e,t){var a,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];a=arguments.length>2&&void 0!==arguments[2]&&arguments[2]||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:a,step:n,readOnly:r,rating:s,rateCallback:o})}(a,t,!1,.1,!0,e.rating)}})}function f(e){if(void 0!==e.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",e.post.number_of_votes,"  ",p("Average:","yet-another-stars-rating")," ",e.post.rating,"]");var t=e.text;return React.createElement("span",{className:"yasr-highest-rated-text"},t," ",e.post.rating)}function v(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===e&&(e=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),e.innerHTML=t;const a=e.textContent;return e.innerHTML="",a}(t.post.title)))}function _(e){var t="after",a=p("Rating:","yet-another-stars-rating"),n=new URLSearchParams(e.rankingParams);return null!==n.get("text_position")&&(t=n.get("text_position")),null!==n.get("custom_txt")&&(a=n.get("custom_txt")),"before"===t?React.createElement("td",{className:e.colClass},React.createElement(f,{post:e.post,tableId:e.tableId,text:a}),React.createElement(h,{rating:e.post.rating,tableId:e.tableId})):React.createElement("td",{className:e.colClass},React.createElement(h,{rating:e.post.rating,tableId:e.tableId}),React.createElement(f,{post:e.post,tableId:e.tableId,text:a}))}function b(e){var t="",a="";return"author_ranking"===e.source?(t="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===e.source&&(t="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:e.trClass},React.createElement(v,{colClass:t,post:e.post}),React.createElement(_,{colClass:a,post:e.post,tableId:e.tableId,rankingParams:e.rankingParams}))}function E(e){return React.createElement("tbody",{id:e.tBodyId,style:{display:e.show}},e.data.map((function(t,a){var n="yasr-rankings-td-colored";return"author_ranking"===e.source&&(n="yasr-rankings-td-white"),a%2==0&&(n="yasr-rankings-td-white","author_ranking"===e.source&&(n="yasr-rankings-td-colored")),React.createElement(b,{key:t.post_id,source:e.source,tableId:e.tableId,rankingParams:e.rankingParams,post:t,trClass:n})})))}var k=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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(o,React.Component);var t,a,n,r,s=(n=o,r=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}}(),function(){var e,t=m(n);if(r){var a=m(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return y(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e)).state={error:null,isLoaded:!1,data:[],tableId:e.tableId,source:e.source,rankingParams:e.params,nonce:e.nonce},t}return t=o,a=[{key:"componentDidMount",value:function(){var e=this,t=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(p("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:t});else if(this.state.source){var n=this.returnRestUrl();Promise.all(n.map((function(e){return fetch(e).then((function(e){return!0===e.ok?e.json():(console.info(p("Ajax Call Failed. Getting data from source")),"KO")})).then((function(e){"KO"===e?a=t:"overall_rating"===e.source||"author_multi"===e.source?a="overall_rating"===e.source?e.data_overall:e.data_mv:a[e.show]=e.data_vv})).catch((function(e){a=t,console.info(p(e))}))}))).then((function(t){e.setState({isLoaded:!0,data:a})})).catch((function(t){console.info(p(t)),e.setState({isLoaded:!0,data:a})}))}else this.setState({error:p("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var e,t=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,n="&nonce_rankings="+this.state.nonce,r="";if(""!==t&&!1!==t){var s=new URLSearchParams(t);null!==s.get("order_by")&&(r+="order_by="+s.get("order_by")),null!==s.get("limit")&&(r+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(r+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(r+="&end_date="+s.get("end_date")),null!==s.get("ctg")?r+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(r+="&cpt="+s.get("cpt")),""!==r&&(r="&"+(r=r.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(r+="&setid="+s.get("setid"))}else r="";if("author_ranking"===a||"author_multi"===a)e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+r+n];else{var o="",i="";if(""!==t){var l=new URLSearchParams(t);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]"))}e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+r+o+n,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+r+i+n]}return e}},{key:"rankingTableHead",value:function(e,t){var a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a;if("author_ranking"!==e){var s=React.createElement("span",null,React.createElement("span",{id:n},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===t&&(s=React.createElement("span",null,React.createElement("span",{id:r},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("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,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(e){e.preventDefault();var t=e.target.id,a=this.state.tableId,n="link-most-rated-posts-"+a,r="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(t),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),t===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)),t===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))}},{key:"rankingTableBody",value:function(){var e=this.state,t=e.data,a=e.source,n=e.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:t,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:n,show:"table-row-group",source:a});var r=t.most,s=t.highest,o="table-row-group",i="none",l="most",d=o,c=i,u=new URLSearchParams(n);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(d=i,c=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:r,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:n,show:d,source:a}),React.createElement(E,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:n,show:c,source:a}))}},{key:"render",value:function(){var e=this.state,t=e.error,a=e.isLoaded;return t?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(t),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}],a&&c(t.prototype,a),Object.defineProperty(t,"prototype",{writable:!1}),o}();function w(){var e=document.getElementsByClassName("yasr-stars-rankings");if(e.length>0)for(var t=0;t<e.length;t++){var a=e.item(t).id,n=JSON.parse(e.item(t).dataset.rankingSource),r=JSON.parse(e.item(t).dataset.rankingParams),s=JSON.parse(e.item(t).dataset.rankingNonce),o=document.getElementById(a);g(React.createElement(k,{source:n,tableId:a,params:r,nonce:s}),o)}}w(),tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var I,B=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(I=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===I){var R,j=function(e){var t=D.value,a=document.getElementById("yasr-builder-shortcode").textContent,n=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];n=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",n),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+t+"&full_shortcode="+a).then((function(e){return!0===e.ok?e.json():(console.info(B("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(e){console.info(e)})).then((function(e){if("KO"!==e){var t=document.createElement("div");t.innerHTML=e,M.childNodes.length>0?M.replaceChild(t,M.childNodes[0]):M.appendChild(t)}})).then((function(e){n.forEach((function(e){t===e&&w()}))}))},x=function(e,t,a,n,r,s,o,i,l){e.style.display="",t.style.display="",s.style.display="",l.style.display="",a.style.display="none",n.style.display="none",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},C=function(e,t,a,n,r,s,o,i,l){a.style.display="",n.style.display="",t.style.display="",s.style.display="",l.style.display="",e.style.display="none",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},Q=function(e,t,a,n,r,s,o,i,l){r.style.display="",l.style.display="none",e.style.display="none",a.style.display="none",n.style.display="none",t.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},T=function(e,t,a,n,r,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(F.className="",F.classList.add("yasr-settings-row-24"),a.style.display="",n.style.display="",e.style.display="none"):(a.style.display="none",n.style.display="none",e.style.display=""),s.style.display="",t.style.display="",d.style.display="",r.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")},L=".yasr-builder-elements-parents",S=".yasr-builder-elements-childs";jQuery(L).prop("disabled",!0),jQuery(S).prop("disabled",!0),jQuery(L).find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",L,S);var P=[],O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};R=O.name,document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]");var N=document.getElementById("yasr-builder-button-preview"),H=document.getElementById("yasr-builder-copy-shortcode"),M=document.getElementById("yasr-builder-preview"),D=document.getElementById("yasr-ranking-source"),A=document.getElementById("yasr-ranking-multiset-select"),U=document.getElementById("yasr-builder-datepicker-start"),q=document.getElementById("yasr-builder-datepicker-end"),F=document.getElementById("yasr-builder-params-container"),z=document.getElementById("builder-vv-default-view"),J=document.getElementById("builder-vv-required-votes"),V=document.getElementById("builder-stars-size"),K=document.getElementById("builder-overall-text"),Y=document.getElementById("builder-username-options"),G=document.getElementById("builder-category"),$=document.getElementById("builder-cpt"),W=document.getElementById("yasr-ranking-multiset"),X=document.getElementById("yasr-builder-datepicker"),Z=D.value,ee=!1;U.value="",q.value="","yasr_ov_ranking"===Z?x(K,V,z,J,Y,G,$,W,X):"yasr_most_active_users"===Z||"yasr_top_reviewers"===Z?Q(K,V,z,J,Y,G,$,W,X):"yasr_multi_set_ranking"===Z?T(K,V,z,J,Y,G,$,W,!1,X):"yasr_visitor_multi_set_ranking"===Z?T(K,V,z,J,Y,G,$,W,!0,X):C(K,V,z,J,Y,G,$,W,X),document.addEventListener("change",(function(e){if("yasr-ranking-source"===e.target.id)F.className="",F.classList.add("yasr-settings-row-33"),M.innerHTML="",U.value="",q.value="",O={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"===e.target.value?x(K,V,z,J,Y,G,$,W,X):"yasr_most_active_users"===e.target.value||"yasr_top_reviewers"===e.target.value?Q(K,V,z,J,Y,G,$,W,X):"yasr_multi_set_ranking"===e.target.value?(T(K,V,z,J,Y,G,$,W,!1,X),O.setid=" setid="+A[0].value):"yasr_visitor_multi_set_ranking"===e.target.value?(T(K,V,z,J,Y,G,$,W,!0,X),O.setid=" setid="+A[0].value):C(K,V,z,J,Y,G,$,W,X),O.name=e.target.value,R=O.name+O.setid;else{"yasr-ranking-multiset-select"===e.target.id&&(O.setid=" setid="+e.target.value),P=wp.hooks.applyFilters("yasrBuilderFilterShortcode",O);for(var t=2;O.length;t++)P.hasOwnProperty(O[t])&&(O[t]=P[t]);R=O.name+O.setid+O.rows+O.view+O.minvotesmost+O.minvoteshg+O.size+O.txtPosition+O.txt+O.display+O.start_date+O.end_date+O.category+O.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]"),!0===ee&&"yasr-ranking-source"!==e.target.id&&"yasr-builder-category-radio"!==e.target.name&&j()})),H.onclick=function(e){var t,a;t=document.getElementById(e.target.id).getAttribute("data-shortcode"),(a=document.createElement("textarea")).value=t,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},N.onclick=function(e){j(),ee=!0}}})();
admin/settings/classes/YasrStats.php CHANGED
@@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License
18
  along with this program. If not, see <http://www.gnu.org/licenses/>
19
  */
20
 
21
- if ( ! defined( 'ABSPATH' ) ) {
22
- exit( 'You\'re not allowed to see this page' );
23
  } // Exit if accessed directly
24
 
25
  /**
@@ -180,8 +180,8 @@ class YasrStats extends Yasr_WP_List_Table {
180
  case 'set_type':
181
  $data = $wpdb->get_results(
182
  $wpdb->prepare(
183
- "SELECT set_name
184
- FROM " . YASR_MULTI_SET_NAME_TABLE . "
185
  WHERE set_id = %d", $set_id),
186
  ARRAY_A);
187
 
@@ -195,8 +195,8 @@ class YasrStats extends Yasr_WP_List_Table {
195
  $field_id = $item[$column_name];
196
  $data = $wpdb->get_results(
197
  $wpdb->prepare(
198
- "SELECT field_name
199
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
200
  WHERE parent_set_id = %d
201
  AND field_id = %d",
202
  $set_id, $field_id),
@@ -256,10 +256,9 @@ class YasrStats extends Yasr_WP_List_Table {
256
 
257
 
258
  protected function get_bulk_actions() {
259
- $actions = array(
260
  'delete' => 'Delete'
261
  );
262
- return $actions;
263
  }
264
 
265
  protected function column_cb($item) {
@@ -306,4 +305,4 @@ class YasrStats extends Yasr_WP_List_Table {
306
 
307
  }
308
 
309
- }
18
  along with this program. If not, see <http://www.gnu.org/licenses/>
19
  */
20
 
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
  } // Exit if accessed directly
24
 
25
  /**
180
  case 'set_type':
181
  $data = $wpdb->get_results(
182
  $wpdb->prepare(
183
+ "SELECT set_name
184
+ FROM " . YASR_MULTI_SET_NAME_TABLE . "
185
  WHERE set_id = %d", $set_id),
186
  ARRAY_A);
187
 
195
  $field_id = $item[$column_name];
196
  $data = $wpdb->get_results(
197
  $wpdb->prepare(
198
+ "SELECT field_name
199
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
200
  WHERE parent_set_id = %d
201
  AND field_id = %d",
202
  $set_id, $field_id),
256
 
257
 
258
  protected function get_bulk_actions() {
259
+ return array(
260
  'delete' => 'Delete'
261
  );
 
262
  }
263
 
264
  protected function column_cb($item) {
305
 
306
  }
307
 
308
+ }
admin/settings/migrations/yasr-settings-migration-functions.php CHANGED
@@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License
18
  along with this program. If not, see <http://www.gnu.org/licenses/>
19
  */
20
 
21
- if ( ! defined( 'ABSPATH' ) ) {
22
- exit( 'You\'re not allowed to see this page' );
23
  } // Exit if accessed directly
24
 
25
  add_action( 'wp_ajax_yasr_import_wppr', 'yasr_import_wppr_callback' );
18
  along with this program. If not, see <http://www.gnu.org/licenses/>
19
  */
20
 
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
  } // Exit if accessed directly
24
 
25
  add_action( 'wp_ajax_yasr_import_wppr', 'yasr_import_wppr_callback' );
admin/settings/rankings/yasr-ranking-builder.php CHANGED
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
19
  */
20
 
21
  if (!defined('ABSPATH')) {
22
- exit('You\'re not allowed to see this page');
23
  } // Exit if accessed directly
24
 
25
  $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
@@ -93,4 +93,4 @@ $cr_setting = new YasrSettingsRankings($custom_post_types);
93
 
94
  </tr>
95
 
96
- </table>
19
  */
20
 
21
  if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
  } // Exit if accessed directly
24
 
25
  $custom_post_types = YasrCustomPostTypes::getCustomPostTypes();
93
 
94
  </tr>
95
 
96
+ </table>
admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -1,5 +1,9 @@
1
  <?php
2
 
 
 
 
 
3
  /**Drow settings tab*/
4
  function yasr_settings_tabs( $active_tab )
5
  {
@@ -91,9 +95,9 @@ function yasr_settings_tabs( $active_tab )
91
  */
92
  function yasr_description_auto_insert()
93
  {
94
- $name = __( 'Auto Insert Options', 'yet-another-stars-rating' );
95
  $div_desc = '<div class="yasr-settings-description">';
96
- $description = sprintf( __( 'Automatically adds YASR in your posts or pages. %s
97
  Disable this if you prefer to use shortcodes.', 'yet-another-stars-rating' ), '<br />' );
98
  $end_div = '</div>';
99
  return $name . $div_desc . $description . $end_div;
@@ -107,9 +111,11 @@ function yasr_description_auto_insert()
107
  */
108
  function yasr_description_stars_title()
109
  {
110
- $name = __( 'Enable stars next to the title?', 'yet-another-stars-rating' );
111
  $div_desc = '<div class="yasr-settings-description">';
112
- $description = __( 'Enable this if you want to show stars next to the title', 'yet-another-stars-rating' );
 
 
113
  $end_div = '.</div>';
114
  return $name . $div_desc . $description . $end_div;
115
  }
@@ -121,9 +127,9 @@ function yasr_description_stars_title()
121
  */
122
  function yasr_description_archive_page()
123
  {
124
- $name = __( 'Archive Pages', 'yet-another-stars-rating' );
125
  $div_desc = '<div class="yasr-settings-description">';
126
- $description = __( 'Enable or disable these settings if you want to show ratings in archive pages (categories, tags, etc.)', 'yet-another-stars-rating' );
127
  $end_div = '.</div>';
128
  return $name . $div_desc . $description . $end_div;
129
  }
@@ -135,9 +141,9 @@ function yasr_description_archive_page()
135
  */
136
  function yasr_description_vv_stats()
137
  {
138
- $name = __( 'Show stats for visitors votes?', 'yet-another-stars-rating' );
139
  $div_desc = '<div class="yasr-settings-description">';
140
- $description = sprintf( __( 'Enable or disable the chart bar icon (and tooltip hover it) next to the %syasr_visitor_votes%s shortcode', 'yet-another-stars-rating' ), '<em>', '</em>' );
141
  $end_div = '.</div>';
142
  return $name . $div_desc . $description . $end_div;
143
  }
@@ -149,10 +155,10 @@ function yasr_description_vv_stats()
149
  */
150
  function yasr_description_allow_vote()
151
  {
152
- $name = __( 'Who is allowed to vote?', 'yet-another-stars-rating' );
153
  $div_desc = '<div class="yasr-settings-description">';
154
  $description = sprintf(
155
- __( 'Select who can rate your posts for %syasr_visitor_votes%s and %syasr_visitor_multiset%s shortcodes', 'yet-another-stars-rating' ),
156
  '<em>',
157
  '</em>',
158
  '<em>',
@@ -169,9 +175,9 @@ function yasr_description_allow_vote()
169
  */
170
  function yasr_description_cstm_txt()
171
  {
172
- $name = __( 'Custom texts', 'yet-another-stars-rating' );
173
  $div_desc = '<div class="yasr-settings-description">';
174
- $description = __( 'Auto insert custom texts to show before or after the stars', 'yet-another-stars-rating' );
175
  $end_div = '.</div>';
176
  return $name . $div_desc . $description . $end_div;
177
  }
@@ -183,13 +189,13 @@ function yasr_description_cstm_txt()
183
  */
184
  function yasr_description_strucutured_data()
185
  {
186
- $name = __( 'Stuctured data options', 'yet-another-stars-rating' );
187
  $div_desc = '<div class="yasr-settings-description">';
188
- $description = __( 'If ratings in a post or page are found, YASR will create structured data to show them in search results
189
  (SERP)', 'yet-another-stars-rating' );
190
- $description .= '<br /><a href="https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_rischnippets_desc"
191
  target="_blank">';
192
- $description .= __( 'More info here', 'yet-another-stars-rating' );
193
  $description .= '</a>';
194
  $end_div = '.</div>';
195
  return $name . $div_desc . $description . $end_div;
@@ -309,13 +315,13 @@ function yasr_resources_box()
309
  */
310
  function yasr_buy_cofee()
311
  {
312
- $buymecofeetext = __( 'Coffee is vital to make YASR development going on!', 'yet-another-stars-rating' );
313
  $buymecofeetext .= '<br />';
314
 
315
  if ( yasr_fs()->is_free_plan() ) {
316
- $buymecofeetext .= __( 'If you are enjoying YASR, and you don\'t need the pro version, please consider to buy me a coffee, thanks!', 'yet-another-stars-rating' );
317
  } else {
318
- $buymecofeetext .= __( 'If you are enjoying YASR, please consider to buy me a coffee, thanks!', 'yet-another-stars-rating' );
319
  }
320
 
321
  $div = "<div class='yasr-donatedivdx' id='yasr-buy-cofee'>";
@@ -340,7 +346,7 @@ function yasr_buy_cofee()
340
  function yasr_related_plugins()
341
  {
342
  $div = "<div class='yasr-donatedivdx' id='yasr-related-plugins'>";
343
- $text = '<div class="yasr-donate-title">' . __( 'You may also like...', 'yet-another-stars-rating' ) . '</div>';
344
  $text .= yasr_movie_helper();
345
  $text .= '<hr />';
346
  $text .= yasr_cnrt();
@@ -355,7 +361,7 @@ function yasr_related_plugins()
355
  */
356
  function yasr_movie_helper()
357
  {
358
- $movie_helper_description = __( 'Movie Helper allows you to easily add links to movie and tv shows, just by searching
359
  them while you\'re writing your content. Search, click, done!', 'yet-another-stars-rating' );
360
  $text = '<div style="text-align: center">';
361
  $text .= '<a href="https://wordpress.org/plugins/yet-another-movie/" target="_blank">
@@ -382,7 +388,7 @@ function yasr_cnrt()
382
  $text .= '</a>';
383
  $text .= '</div>';
384
  $text .= '<div style="margin-top: 15px;">';
385
- $text .= __( '"Comments Not Replied To" introduces a new area in the administrative dashboard that allows you to
386
  see what comments to which you - as the site author - have not yet replied.', 'yet-another-stars-rating' );
387
  $text .= '</div>';
388
  return $text;
@@ -394,7 +400,7 @@ function yasr_cnrt()
394
  function yasr_ask_rating()
395
  {
396
  $div = "<div class='yasr-donatedivdx' id='yasr-ask-five-stars'>";
397
- $text = '<div class="yasr-donate-title">' . __( 'Can I ask your help?', 'yet-another-stars-rating' ) . '</div>';
398
  $text .= '<div style="font-size: 32px; color: #F1CB32; text-align:center; margin-bottom: 20px; margin-top: -5px;">
399
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
400
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
@@ -402,10 +408,10 @@ function yasr_ask_rating()
402
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
403
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
404
  </div>';
405
- $text .= __( 'Please rate YASR 5 stars on', 'yet-another-stars-rating' );
406
  $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">
407
  WordPress.org.</a><br />';
408
- $text .= __( ' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating' );
409
  $text .= "<br /><br />";
410
  $text .= "<em>> Dario Curvino</em>";
411
  $div_and_text = $div . $text . '</div>';
1
  <?php
2
 
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit( 'You\'re not allowed to see this page' );
5
+ }
6
+ // Exit if accessed directly
7
  /**Drow settings tab*/
8
  function yasr_settings_tabs( $active_tab )
9
  {
95
  */
96
  function yasr_description_auto_insert()
97
  {
98
+ $name = esc_html__( 'Auto Insert Options', 'yet-another-stars-rating' );
99
  $div_desc = '<div class="yasr-settings-description">';
100
+ $description = sprintf( esc_html__( 'Automatically adds YASR in your posts or pages. %s
101
  Disable this if you prefer to use shortcodes.', 'yet-another-stars-rating' ), '<br />' );
102
  $end_div = '</div>';
103
  return $name . $div_desc . $description . $end_div;
111
  */
112
  function yasr_description_stars_title()
113
  {
114
+ $name = esc_html__( 'Enable stars next to the title?', 'yet-another-stars-rating' );
115
  $div_desc = '<div class="yasr-settings-description">';
116
+ $description = esc_html__( 'Enable this if you want to show stars next to the title.', 'yet-another-stars-rating' );
117
+ $description .= '<br />';
118
+ $description .= esc_html__( 'Please note that this may not work with all themes', 'yet-another-stars-rating' );
119
  $end_div = '.</div>';
120
  return $name . $div_desc . $description . $end_div;
121
  }
127
  */
128
  function yasr_description_archive_page()
129
  {
130
+ $name = esc_html__( 'Archive Pages', 'yet-another-stars-rating' );
131
  $div_desc = '<div class="yasr-settings-description">';
132
+ $description = esc_html__( 'Enable or disable these settings if you want to show ratings in archive pages (categories, tags, etc.)', 'yet-another-stars-rating' );
133
  $end_div = '.</div>';
134
  return $name . $div_desc . $description . $end_div;
135
  }
141
  */
142
  function yasr_description_vv_stats()
143
  {
144
+ $name = esc_html__( 'Show stats for visitors votes?', 'yet-another-stars-rating' );
145
  $div_desc = '<div class="yasr-settings-description">';
146
+ $description = sprintf( esc_html__( 'Enable or disable the chart bar icon (and tooltip hover it) next to the %syasr_visitor_votes%s shortcode', 'yet-another-stars-rating' ), '<em>', '</em>' );
147
  $end_div = '.</div>';
148
  return $name . $div_desc . $description . $end_div;
149
  }
155
  */
156
  function yasr_description_allow_vote()
157
  {
158
+ $name = esc_html__( 'Who is allowed to vote?', 'yet-another-stars-rating' );
159
  $div_desc = '<div class="yasr-settings-description">';
160
  $description = sprintf(
161
+ esc_html__( 'Select who can rate your posts for %syasr_visitor_votes%s and %syasr_visitor_multiset%s shortcodes', 'yet-another-stars-rating' ),
162
  '<em>',
163
  '</em>',
164
  '<em>',
175
  */
176
  function yasr_description_cstm_txt()
177
  {
178
+ $name = esc_html__( 'Custom texts', 'yet-another-stars-rating' );
179
  $div_desc = '<div class="yasr-settings-description">';
180
+ $description = esc_html__( 'Auto insert custom texts to show before or after the stars', 'yet-another-stars-rating' );
181
  $end_div = '.</div>';
182
  return $name . $div_desc . $description . $end_div;
183
  }
189
  */
190
  function yasr_description_strucutured_data()
191
  {
192
+ $name = esc_html__( 'Stuctured data options', 'yet-another-stars-rating' );
193
  $div_desc = '<div class="yasr-settings-description">';
194
+ $description = esc_html__( 'If ratings in a post or page are found, YASR will create structured data to show them in search results
195
  (SERP)', 'yet-another-stars-rating' );
196
+ $description .= '<br /><a href="https://yetanotherstarsrating.com/docs/rich-snippet/reviewrating-and-aggregaterating/?utm_source=wp-plugin&utm_medium=settings_resources&utm_campaign=yasr_settings&utm_content=yasr_rischnippets_desc"
197
  target="_blank">';
198
+ $description .= esc_html__( 'More info here', 'yet-another-stars-rating' );
199
  $description .= '</a>';
200
  $end_div = '.</div>';
201
  return $name . $div_desc . $description . $end_div;
315
  */
316
  function yasr_buy_cofee()
317
  {
318
+ $buymecofeetext = esc_html__( 'Coffee is vital to make YASR development going on!', 'yet-another-stars-rating' );
319
  $buymecofeetext .= '<br />';
320
 
321
  if ( yasr_fs()->is_free_plan() ) {
322
+ $buymecofeetext .= esc_html__( 'If you are enjoying YASR, and you don\'t need the pro version, please consider to buy me a coffee, thanks!', 'yet-another-stars-rating' );
323
  } else {
324
+ $buymecofeetext .= esc_html__( 'If you are enjoying YASR, please consider to buy me a coffee, thanks!', 'yet-another-stars-rating' );
325
  }
326
 
327
  $div = "<div class='yasr-donatedivdx' id='yasr-buy-cofee'>";
346
  function yasr_related_plugins()
347
  {
348
  $div = "<div class='yasr-donatedivdx' id='yasr-related-plugins'>";
349
+ $text = '<div class="yasr-donate-title">' . esc_html__( 'You may also like...', 'yet-another-stars-rating' ) . '</div>';
350
  $text .= yasr_movie_helper();
351
  $text .= '<hr />';
352
  $text .= yasr_cnrt();
361
  */
362
  function yasr_movie_helper()
363
  {
364
+ $movie_helper_description = esc_html__( 'Movie Helper allows you to easily add links to movie and tv shows, just by searching
365
  them while you\'re writing your content. Search, click, done!', 'yet-another-stars-rating' );
366
  $text = '<div style="text-align: center">';
367
  $text .= '<a href="https://wordpress.org/plugins/yet-another-movie/" target="_blank">
388
  $text .= '</a>';
389
  $text .= '</div>';
390
  $text .= '<div style="margin-top: 15px;">';
391
+ $text .= esc_html__( '"Comments Not Replied To" introduces a new area in the administrative dashboard that allows you to
392
  see what comments to which you - as the site author - have not yet replied.', 'yet-another-stars-rating' );
393
  $text .= '</div>';
394
  return $text;
400
  function yasr_ask_rating()
401
  {
402
  $div = "<div class='yasr-donatedivdx' id='yasr-ask-five-stars'>";
403
+ $text = '<div class="yasr-donate-title">' . esc_html__( 'Can I ask your help?', 'yet-another-stars-rating' ) . '</div>';
404
  $text .= '<div style="font-size: 32px; color: #F1CB32; text-align:center; margin-bottom: 20px; margin-top: -5px;">
405
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
406
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
408
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
409
  <span class="dashicons dashicons-star-filled" style="font-size: 26px;"></span>
410
  </div>';
411
+ $text .= esc_html__( 'Please rate YASR 5 stars on', 'yet-another-stars-rating' );
412
  $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">
413
  WordPress.org.</a><br />';
414
+ $text .= esc_html__( ' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating' );
415
  $text .= "<br /><br />";
416
  $text .= "<em>> Dario Curvino</em>";
417
  $div_and_text = $div . $text . '</div>';
admin/yasr-admin-actions-ajax.php CHANGED
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
- if ( ! defined( 'ABSPATH' ) ) {
21
- exit( 'You\'re not allowed to see this page' );
22
  } // Exit if accessed directly
23
 
24
  //ajax action
@@ -60,4 +60,4 @@ function yasr_rankings_preview_shortcode() {
60
  echo json_encode(do_shortcode($full_shortcode));
61
 
62
  die();
63
- }
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
  } // Exit if accessed directly
23
 
24
  //ajax action
60
  echo json_encode(do_shortcode($full_shortcode));
61
 
62
  die();
63
+ }
admin/yasr-admin-filters.php CHANGED
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
- if ( ! defined( 'ABSPATH' ) ) {
21
- exit( 'You\'re not allowed to see this page' );
22
  } // Exit if accessed directly
23
 
24
  add_filter('yasr_filter_style_options', 'yasr_filter_style_options_callback');
@@ -29,4 +29,4 @@ function yasr_filter_style_options_callback($style_options) {
29
  }
30
 
31
  return $style_options;
32
- }
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
  } // Exit if accessed directly
23
 
24
  add_filter('yasr_filter_style_options', 'yasr_filter_style_options_callback');
29
  }
30
 
31
  return $style_options;
32
+ }
admin/yasr-update-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit( 'You\'re not allowed to see this page' );
5
  } // Exit if accessed directly
6
 
7
  //Update version number and backward compatibility functions
@@ -63,4 +63,4 @@ function yasr_update_version() {
63
 
64
  }
65
 
66
- }
1
  <?php
2
 
3
+ if (!defined('ABSPATH')) {
4
+ exit('You\'re not allowed to see this page');
5
  } // Exit if accessed directly
6
 
7
  //Update version number and backward compatibility functions
63
 
64
  }
65
 
66
+ }
includes/classes/YasrIncludesFilters.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit( 'You\'re not allowed to see this page' );
5
  } // Exit if accessed directly
6
 
7
  /**
@@ -271,10 +271,11 @@ class YasrIncludesFilters {
271
  }
272
 
273
  //cache enabler support
274
- if(method_exists('Cache_Enabler', 'clear_page_cache_by_post_id')) {
 
275
  Cache_Enabler::clear_page_cache_by_post_id($post_id);
276
  }
277
 
278
  }
279
 
280
- }
1
  <?php
2
 
3
+ if (!defined('ABSPATH')) {
4
+ exit('You\'re not allowed to see this page');
5
  } // Exit if accessed directly
6
 
7
  /**
271
  }
272
 
273
  //cache enabler support
274
+ if(class_exists('Cache_Enabler') &&
275
+ method_exists('Cache_Enabler', 'clear_page_cache_by_post_id')) {
276
  Cache_Enabler::clear_page_cache_by_post_id($post_id);
277
  }
278
 
279
  }
280
 
281
+ }
includes/classes/YasrMultiSetData.php CHANGED
@@ -74,7 +74,6 @@ class YasrMultiSetData {
74
 
75
  global $wpdb;
76
 
77
-
78
  $result = $wpdb->get_results(
79
  $wpdb->prepare(
80
  "SELECT f.field_id AS id
@@ -161,14 +160,14 @@ class YasrMultiSetData {
161
  *
162
  * array (
163
  * array (
164
- * 'value_id' => 0,
165
- * 'value_name' => 'Field 1',
166
- * 'value_rating' => 3.5,
167
  * ),
168
  * array (
169
- * 'value_id' => 1,
170
- * 'value_name' => 'Field 2',
171
- * 'value_rating' => 3,
172
  * )
173
  *
174
  * @param integer $set_id the set id
@@ -228,14 +227,16 @@ class YasrMultiSetData {
228
  *
229
  * array (
230
  * array (
231
- * 'value_id' => 0,
232
- * 'value_name' => 'Field 1',
233
- * 'value_rating' => 3.5,
 
234
  * ),
235
  * array (
236
- * 'value_id' => 1,
237
- * 'value_name' => 'Field 2',
238
- * 'value_rating' => 3,
 
239
  * )
240
  *
241
  * @param int $set_id the set id
@@ -286,7 +287,7 @@ class YasrMultiSetData {
286
  $array_to_return[$i]['average_rating'] = 0;
287
  $array_to_return[$i]['number_of_votes'] = 0;
288
 
289
- //if there is post meta
290
  if ($ratings) {
291
  //loop the saved arrays
292
  foreach ($ratings as $single_value) {
@@ -306,22 +307,27 @@ class YasrMultiSetData {
306
  }
307
 
308
  /**
309
- * @param int $post_id
310
- * @param int $set_id
311
- * @param bool $visitor_multiset
312
  *
313
- * Get the post_id and the set id, return the average (float)
 
 
 
314
  *
315
  * @return float|int
316
  */
317
- public static function returnMultiSetAverage($post_id, $set_id, $visitor_multiset) {
318
- $post_id = (int)$post_id;
319
- $set_id = (int)$set_id;
 
320
 
321
- if ($visitor_multiset === true) {
322
- $multiset_content = self::returnMultisetContent($post_id, $set_id, true);
323
- } else {
324
- $multiset_content = self::returnMultisetContent($post_id, $set_id);
 
 
325
  }
326
 
327
  if (!is_array($multiset_content)) {
74
 
75
  global $wpdb;
76
 
 
77
  $result = $wpdb->get_results(
78
  $wpdb->prepare(
79
  "SELECT f.field_id AS id
160
  *
161
  * array (
162
  * array (
163
+ * 'id' => 0,
164
+ * 'name' => 'Field 1',
165
+ * 'average_rating' => 3.5,
166
  * ),
167
  * array (
168
+ * 'id' => 1,
169
+ * 'name' => 'Field 2',
170
+ * 'average_rating' => 3,
171
  * )
172
  *
173
  * @param integer $set_id the set id
227
  *
228
  * array (
229
  * array (
230
+ * 'id' => 0,
231
+ * 'name' => 'Field 1',
232
+ * 'average_rating' => 3.5
233
+ * 'number_of_votes' => 3
234
  * ),
235
  * array (
236
+ * 'id' => 1,
237
+ * 'name' => 'Field 2',
238
+ * 'average_rating' => 3,
239
+ * 'number_of_votes' => 3,
240
  * )
241
  *
242
  * @param int $set_id the set id
287
  $array_to_return[$i]['average_rating'] = 0;
288
  $array_to_return[$i]['number_of_votes'] = 0;
289
 
290
+ //if there are ratings
291
  if ($ratings) {
292
  //loop the saved arrays
293
  foreach ($ratings as $single_value) {
307
  }
308
 
309
  /**
310
+ * Return an average of a given multiset_content if provided.
311
+ * Otherwise, it will get the average using the post_id and set_id
 
312
  *
313
+ * @param int $post_id
314
+ * @param int $set_id
315
+ * @param bool $visitor_multiset
316
+ * @param bool|array $multiset_content | This is useful to avoid double query
317
  *
318
  * @return float|int
319
  */
320
+ public static function returnMultiSetAverage($post_id, $set_id, $visitor_multiset, $multiset_content=false) {
321
+ if($multiset_content === false) {
322
+ $post_id = (int)$post_id;
323
+ $set_id = (int)$set_id;
324
 
325
+ if ($visitor_multiset === true) {
326
+ $multiset_content = self::returnMultisetContent($post_id, $set_id, true);
327
+ }
328
+ else {
329
+ $multiset_content = self::returnMultisetContent($post_id, $set_id);
330
+ }
331
  }
332
 
333
  if (!is_array($multiset_content)) {
includes/shortcodes/classes/YasrMultiSet.php CHANGED
@@ -25,6 +25,27 @@ if (!defined('ABSPATH')) {
25
  * Class YasrMultiSet
26
  */
27
  class YasrMultiSet extends YasrShortcode {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * @return string | bool
30
  */
@@ -35,17 +56,17 @@ class YasrMultiSet extends YasrShortcode {
35
  $multiset_content = YasrMultiSetData::returnMultisetContent($this->post_id, $this->set_id);
36
 
37
  if ($multiset_content === false) {
38
- $string = __('No Set Found with this ID', 'yet-another-stars-rating');
39
- return $this->shortcode_html . $string;
40
  }
41
 
42
- $this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
43
- $this->shortcode_html .= '<table class="yasr_table_multi_set_shortcode">';
44
  $this->star_readonly = 'true';
45
 
46
- $this->printMultisetRows($multiset_content);
 
 
47
 
48
- $this->shortcode_html .= "</table>";
49
  $this->shortcode_html .= '<!--End Yasr Multi Set Shortcode-->';
50
 
51
  YasrShortcode::enqueueReadonlyAndMultisetScript();
@@ -55,63 +76,124 @@ class YasrMultiSet extends YasrShortcode {
55
 
56
 
57
  /**
 
58
  *
59
- * This function insert into $this->shortcode_html the rows of both multisets (average included)
 
 
 
 
 
 
 
 
 
 
60
  *
61
  * @param $multiset_content
62
- * @param bool $visitor_multiset
63
  *
64
- * @return void
65
  *
66
  */
67
- protected function printMultisetRows($multiset_content, $visitor_multiset=false) {
 
68
 
69
- $multiset_string = 'yasr-average-multiset-';
70
- if ($visitor_multiset === true) {
71
- $multiset_string = 'yasr-visitor-multi-set-average-';
72
- }
73
 
74
  foreach ($multiset_content as $set_content) {
75
- $unique_id_identifier = 'yasr-multiset-' . str_shuffle(uniqid());
76
-
77
- $average_rating = round($set_content['average_rating'], 1);
78
-
79
- $html_stars = "<div class='yasr-multiset-visitors-rater'
80
- id='$unique_id_identifier'
81
- data-rater-postid='$this->post_id'
82
- data-rater-setid='$this->set_id'
83
- data-rater-set-field-id='$set_content[id]'
84
- data-rating='$average_rating'
85
- data-rater-readonly='$this->star_readonly'>
86
- </div>";
87
-
88
- $span_container_number_of_votes = '';
89
- if ($visitor_multiset === true) {
90
- $span_container_number_of_votes = '<span class="yasr-visitor-multiset-vote-count">'
91
- . $set_content['number_of_votes'] .
92
- '</span>';
93
  }
94
 
95
- $this->shortcode_html .= '<tr>
96
- <td>
97
- <span class="yasr-multi-set-name-field">' . $set_content['name'] . '</span>
98
- </td>
99
- <td>'
100
- . $html_stars . $span_container_number_of_votes .
101
- '</td>
102
- </tr>';
103
 
 
 
 
104
  } //End foreach
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  //If average row should be showed
107
- if ($this->show_average_multiset() === true) {
108
  //get the average of the multiset
109
- $multiset_average = YasrMultiSetData::returnMultiSetAverage($this->post_id, $this->set_id, $visitor_multiset);
110
 
111
- //print it
112
- $this->shortcode_html .= $this->printAverageRowMultiSet($multiset_average, $multiset_string);
113
  }
114
 
 
115
  }
116
 
117
  /**
@@ -120,29 +202,26 @@ class YasrMultiSet extends YasrShortcode {
120
  * @since 2.1.0
121
  *
122
  * @param $multiset_average
123
- * @param $multiset_string
124
  *
125
  * @return string
126
  */
127
- protected function printAverageRowMultiSet($multiset_average, $multiset_string) {
128
- $average_txt = __("Average", "yet-another-stars-rating");
129
  $html_average = null;
130
 
131
  //Show average row
132
- if ($this->show_average_multiset() === true) {
133
- $unique_id_identifier = $multiset_string . str_shuffle(uniqid());
134
-
135
- $html_average = "<tr>
136
- <td colspan='2' class='yasr-multiset-average'>
137
- <div class='yasr-multiset-average'>
138
- <span class='yasr-multiset-average-text'>$average_txt</span>
139
- <div class='yasr-rater-stars' id='$unique_id_identifier'
140
- data-rating='$multiset_average' data-rater-readonly='true'
141
- data-rater-starsize='24'></div>
142
- </div>
143
- </td>
144
- </tr>";
145
- }
146
 
147
  return $html_average;
148
  }
@@ -152,7 +231,7 @@ class YasrMultiSet extends YasrShortcode {
152
  *
153
  * @return bool
154
  */
155
- public function show_average_multiset() {
156
  if ( ( $this->show_average === '' && YASR_MULTI_SHOW_AVERAGE !== 'no' ) ||
157
  ( $this->show_average !== '' && $this->show_average !== 'no' ) ) {
158
  return true;
25
  * Class YasrMultiSet
26
  */
27
  class YasrMultiSet extends YasrShortcode {
28
+
29
+ public $set_id; //1
30
+ public $show_average; //null
31
+
32
+ public function __construct($atts, $shortcode_name) {
33
+ parent::__construct($atts, $shortcode_name);
34
+
35
+ $atts = shortcode_atts(
36
+ array(
37
+ 'setid' => YASR_FIRST_SETID,
38
+ 'show_average' => null
39
+ ),
40
+ $atts,
41
+ $shortcode_name
42
+ );
43
+
44
+ $this->set_id = (int)$atts['setid'];
45
+ $this->show_average = sanitize_text_field($atts['show_average']);
46
+
47
+ }
48
+
49
  /**
50
  * @return string | bool
51
  */
56
  $multiset_content = YasrMultiSetData::returnMultisetContent($this->post_id, $this->set_id);
57
 
58
  if ($multiset_content === false) {
59
+ return $this->returnErrorData('<!-- Yasr Multi Set Shortcode-->');
 
60
  }
61
 
62
+ $this->shortcode_html .= '<table class="yasr_table_multi_set_shortcode">';
 
63
  $this->star_readonly = 'true';
64
 
65
+ $this->shortcode_html .= $this->returnMultisetRows($multiset_content);
66
+
67
+ $this->shortcode_html .= $this->returnAverageRowIfEnabled(false, $multiset_content);
68
 
69
+ $this->shortcode_html .= '</table>';
70
  $this->shortcode_html .= '<!--End Yasr Multi Set Shortcode-->';
71
 
72
  YasrShortcode::enqueueReadonlyAndMultisetScript();
76
 
77
 
78
  /**
79
+ * Return Error if no data is found
80
  *
81
+ * @author Dario Curvino <@dudo>
82
+ * @since 2.9.8
83
+ * @return string
84
+ */
85
+ protected function returnErrorData($shortcode_html) {
86
+ $string = esc_html__('No Set Found with this ID', 'yet-another-stars-rating');
87
+ return $shortcode_html . $string;
88
+ }
89
+
90
+ /**
91
+ * Loop the multiset content and return the table rows
92
  *
93
  * @param $multiset_content
 
94
  *
95
+ * @return string
96
  *
97
  */
98
+ protected function returnMultisetRows($multiset_content) {
99
+ $shortcode_html = '';
100
 
101
+ $span_container_number_of_votes = '';
 
 
 
102
 
103
  foreach ($multiset_content as $set_content) {
104
+ if (isset($set_content['number_of_votes'])) {
105
+ $span_container_number_of_votes = $this->returnContainerNOfVotes($set_content['number_of_votes']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
 
108
+ $average_rating = round($set_content['average_rating'], 1);
 
 
 
 
 
 
 
109
 
110
+ $html_stars = $this->returnStarsDiv($set_content['id'], $average_rating, $this->star_readonly);
111
+
112
+ $shortcode_html .= $this->returnTableRow($set_content['name'], $html_stars, $span_container_number_of_votes);
113
  } //End foreach
114
 
115
+ return $shortcode_html;
116
+
117
+ }
118
+
119
+ /**
120
+ * return the div of the stars
121
+ *
122
+ * @author Dario Curvino <@dudo>
123
+ * @since 2.9.8
124
+ *
125
+ * @param $field_id
126
+ * @param $average_rating
127
+ * @param $readonly
128
+ *
129
+ * @return string
130
+ */
131
+ public function returnStarsDiv ($field_id, $average_rating, $readonly) {
132
+ $unique_id_identifier = 'yasr-multiset-' . str_shuffle(uniqid());
133
+
134
+ return "<div class='yasr-multiset-visitors-rater'
135
+ id='$unique_id_identifier'
136
+ data-rater-postid='$this->post_id'
137
+ data-rater-setid='$this->set_id'
138
+ data-rater-set-field-id='$field_id'
139
+ data-rating='$average_rating'
140
+ data-rater-readonly='$readonly'>
141
+ </div>";
142
+ }
143
+
144
+ /**
145
+ * @author Dario Curvino <@dudo>
146
+ * @since 2.9.8
147
+ * @param $number
148
+ *
149
+ * @return string
150
+ */
151
+ private function returnContainerNOfVotes($number) {
152
+ return '<span class="yasr-visitor-multiset-vote-count">'
153
+ . (int)$number .
154
+ '</span>';
155
+ }
156
+
157
+ /**
158
+ * @author Dario Curvino <@dudo>
159
+ * @since 2.9.8
160
+ * @param $field_name
161
+ * @param $div_stars
162
+ * @param $span_container_number_of_votes
163
+ *
164
+ * @return string
165
+ */
166
+ private function returnTableRow($field_name, $div_stars, $span_container_number_of_votes) {
167
+ return '<tr>
168
+ <td>
169
+ <span class="yasr-multi-set-name-field">' . $field_name . '</span>
170
+ </td>
171
+ <td>'
172
+ . $div_stars . $span_container_number_of_votes .
173
+ '</td>
174
+ </tr>';
175
+ }
176
+
177
+ /**
178
+ * Check if the average is enabled, get the data and return it
179
+ *
180
+ * @author Dario Curvino <@dudo>
181
+ * @since 2.9.8
182
+ * @param $visitor_multiset
183
+ *
184
+ * @return false|string
185
+ */
186
+ protected function returnAverageRowIfEnabled($visitor_multiset, $multiset_content) {
187
  //If average row should be showed
188
+ if ($this->showAverageMultiset() === true) {
189
  //get the average of the multiset
190
+ $multiset_average = YasrMultiSetData::returnMultiSetAverage($this->post_id, $this->set_id, $visitor_multiset, $multiset_content);
191
 
192
+ //return it
193
+ return $this->returnAverageRowMultiSet($multiset_average);
194
  }
195
 
196
+ return false;
197
  }
198
 
199
  /**
202
  * @since 2.1.0
203
  *
204
  * @param $multiset_average
 
205
  *
206
  * @return string
207
  */
208
+ protected function returnAverageRowMultiSet($multiset_average) {
209
+ $average_txt = esc_html__('Average', 'yet-another-stars-rating');
210
  $html_average = null;
211
 
212
  //Show average row
213
+ $unique_id_identifier = 'yasr-multiset-' . str_shuffle(uniqid());
214
+
215
+ $html_average = "<tr>
216
+ <td colspan='2' class='yasr-multiset-average'>
217
+ <div class='yasr-multiset-average'>
218
+ <span class='yasr-multiset-average-text'>$average_txt</span>
219
+ <div class='yasr-rater-stars' id='$unique_id_identifier'
220
+ data-rating='$multiset_average' data-rater-readonly='true'
221
+ data-rater-starsize='24'></div>
222
+ </div>
223
+ </td>
224
+ </tr>";
 
 
225
 
226
  return $html_average;
227
  }
231
  *
232
  * @return bool
233
  */
234
+ protected function showAverageMultiset() {
235
  if ( ( $this->show_average === '' && YASR_MULTI_SHOW_AVERAGE !== 'no' ) ||
236
  ( $this->show_average !== '' && $this->show_average !== 'no' ) ) {
237
  return true;
includes/shortcodes/classes/YasrShortcode.php CHANGED
@@ -36,10 +36,6 @@ abstract class YasrShortcode
36
  //large
37
  public $readonly ;
38
  //false
39
- public $set_id ;
40
- //1
41
- public $show_average ;
42
- //null
43
  public $shortcode_name ;
44
  public function __construct( $atts, $shortcode_name )
45
  {
@@ -54,11 +50,9 @@ abstract class YasrShortcode
54
 
55
  if ( $atts !== false ) {
56
  $atts = shortcode_atts( array(
57
- 'size' => 'large',
58
- 'postid' => false,
59
- 'readonly' => false,
60
- 'setid' => YASR_FIRST_SETID,
61
- 'show_average' => null,
62
  ), $atts, $shortcode_name );
63
 
64
  if ( $atts['postid'] === false ) {
@@ -69,8 +63,6 @@ abstract class YasrShortcode
69
 
70
  $this->size = sanitize_text_field( $atts['size'] );
71
  $this->readonly = sanitize_text_field( $atts['readonly'] );
72
- $this->set_id = (int) $atts['setid'];
73
- $this->show_average = sanitize_text_field( $atts['show_average'] );
74
  }
75
 
76
  }
@@ -117,26 +109,22 @@ abstract class YasrShortcode
117
  if ( $is_user_logged_in === true ) {
118
  return 'true_logged';
119
  }
 
 
120
  //If only logged in users can vote
121
  if ( YASR_ALLOWED_USER === 'logged_only' ) {
122
- //IF user is not logged in
123
- if ( $is_user_logged_in === false ) {
124
- return 'false_not_logged';
125
- }
126
  }
127
  //if anonymous are allowed to vote
 
128
  if ( YASR_ALLOWED_USER === 'allow_anonymous' ) {
129
- //I've to check if is user is not logged in
130
-
131
- if ( $is_user_logged_in === false ) {
132
- //if cookie !== false means that exists, and user can't vote
133
- if ( $cookie_value !== false ) {
134
- return 'false_already_voted';
135
- }
136
- return 'true_not_logged';
137
  }
138
-
139
  }
 
140
  //end if YASR_ALLOWED_USER === 'allow_anonymous'
141
  //this should never happen
142
  return false;
36
  //large
37
  public $readonly ;
38
  //false
 
 
 
 
39
  public $shortcode_name ;
40
  public function __construct( $atts, $shortcode_name )
41
  {
50
 
51
  if ( $atts !== false ) {
52
  $atts = shortcode_atts( array(
53
+ 'size' => 'large',
54
+ 'postid' => false,
55
+ 'readonly' => false,
 
 
56
  ), $atts, $shortcode_name );
57
 
58
  if ( $atts['postid'] === false ) {
63
 
64
  $this->size = sanitize_text_field( $atts['size'] );
65
  $this->readonly = sanitize_text_field( $atts['readonly'] );
 
 
66
  }
67
 
68
  }
109
  if ( $is_user_logged_in === true ) {
110
  return 'true_logged';
111
  }
112
+ //user is never logged-in here
113
+ //$is_user_logged_in is always false
114
  //If only logged in users can vote
115
  if ( YASR_ALLOWED_USER === 'logged_only' ) {
116
+ return 'false_not_logged';
 
 
 
117
  }
118
  //if anonymous are allowed to vote
119
+
120
  if ( YASR_ALLOWED_USER === 'allow_anonymous' ) {
121
+ //if cookie !== false means that exists, and user can't vote
122
+ if ( $cookie_value !== false ) {
123
+ return 'false_already_voted';
 
 
 
 
 
124
  }
125
+ return 'true_not_logged';
126
  }
127
+
128
  //end if YASR_ALLOWED_USER === 'allow_anonymous'
129
  //this should never happen
130
  return false;
includes/shortcodes/classes/YasrVisitorMultiSet.php CHANGED
@@ -77,14 +77,15 @@ class YasrVisitorMultiSet extends YasrMultiSet {
77
  $multiset_content = YasrMultiSetData::returnMultisetContent($this->post_id, $this->set_id, true);
78
 
79
  if ($multiset_content === false) {
80
- $string = __('No Set Found with this ID', 'yet-another-stars-rating');
81
- return $this->shortcode_html . $string;
82
  }
83
 
84
  $this->shortcode_html .= "<table class='yasr_table_multi_set_shortcode'>";
85
 
86
- //print the single rows
87
- $this->printMultisetRows($multiset_content, true);
 
 
88
 
89
  //Submit row and button
90
  $this->shortcode_html .="<tr>
@@ -93,8 +94,7 @@ class YasrVisitorMultiSet extends YasrMultiSet {
93
  $this->loader_html
94
  <span class='yasr-visitor-multiset-message'>$this->span_message_content</span>
95
  </td>
96
- </tr>
97
- ";
98
 
99
  $this->shortcode_html .= "</table>";
100
  $this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
@@ -104,8 +104,14 @@ class YasrVisitorMultiSet extends YasrMultiSet {
104
  return $this->shortcode_html;
105
  }
106
 
 
 
 
 
 
 
107
  public function checkCookie() {
108
- //custommize cookie name for yasr_multi_visitor_cookie
109
  $yasr_cookiename = apply_filters('yasr_mv_cookie', 'yasr_multi_visitor_cookie');
110
 
111
  //Check cookie and if voting is allowed only to logged in users
@@ -145,8 +151,6 @@ class YasrVisitorMultiSet extends YasrMultiSet {
145
  *
146
  */
147
  protected function multisetAttributes() {
148
- $this->checkCookie();
149
-
150
  $set_enabled = YasrShortcode::starsEnalbed($this->checkCookie());
151
 
152
  if($set_enabled === 'true_logged' || $set_enabled === 'true_not_logged') {
@@ -157,7 +161,7 @@ class YasrVisitorMultiSet extends YasrMultiSet {
157
  else if($set_enabled === 'false_already_voted') {
158
  $this->button = "";
159
  $this->star_readonly = 'true';
160
- $this->span_message_content = __('Thank you for voting!', 'yet-another-stars-rating');
161
  }
162
  elseif ($set_enabled === 'false_not_logged') {
163
  $this->button = $this->button_html_disabled;
77
  $multiset_content = YasrMultiSetData::returnMultisetContent($this->post_id, $this->set_id, true);
78
 
79
  if ($multiset_content === false) {
80
+ return $this->returnErrorData('<!-- Yasr Visitor Multi Set Shortcode-->');
 
81
  }
82
 
83
  $this->shortcode_html .= "<table class='yasr_table_multi_set_shortcode'>";
84
 
85
+ //print the single row
86
+ $this->shortcode_html .= $this->returnMultisetRows($multiset_content);
87
+
88
+ $this->shortcode_html .= $this->returnAverageRowIfEnabled(true, $multiset_content);
89
 
90
  //Submit row and button
91
  $this->shortcode_html .="<tr>
94
  $this->loader_html
95
  <span class='yasr-visitor-multiset-message'>$this->span_message_content</span>
96
  </td>
97
+ </tr>";
 
98
 
99
  $this->shortcode_html .= "</table>";
100
  $this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
104
  return $this->shortcode_html;
105
  }
106
 
107
+
108
+ /**
109
+ * @author Dario Curvino <@dudo>
110
+ * @since
111
+ * @return bool
112
+ */
113
  public function checkCookie() {
114
+ //customize cookie name for yasr_multi_visitor_cookie
115
  $yasr_cookiename = apply_filters('yasr_mv_cookie', 'yasr_multi_visitor_cookie');
116
 
117
  //Check cookie and if voting is allowed only to logged in users
151
  *
152
  */
153
  protected function multisetAttributes() {
 
 
154
  $set_enabled = YasrShortcode::starsEnalbed($this->checkCookie());
155
 
156
  if($set_enabled === 'true_logged' || $set_enabled === 'true_not_logged') {
161
  else if($set_enabled === 'false_already_voted') {
162
  $this->button = "";
163
  $this->star_readonly = 'true';
164
+ $this->span_message_content = esc_html__('Thank you for voting!', 'yet-another-stars-rating');
165
  }
166
  elseif ($set_enabled === 'false_not_logged') {
167
  $this->button = $this->button_html_disabled;
includes/yasr-includes-db-functions.php CHANGED
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
- if ( ! defined( 'ABSPATH' ) ) {
21
- exit( 'You\'re not allowed to see this page' );
22
  } // Exit if accessed directly
23
 
24
  /**
@@ -72,4 +72,4 @@ function yasr_get_itemType($term_id=false) {
72
  }
73
 
74
  return $snippet_type;
75
- }
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
  } // Exit if accessed directly
23
 
24
  /**
72
  }
73
 
74
  return $snippet_type;
75
+ }
includes/yasr-includes-functions.php CHANGED
@@ -32,8 +32,12 @@ function yasr_add_scripts_includes() {
32
  wp_register_script( 'yasr-global-data', '', [], '', true );
33
  wp_enqueue_script( 'yasr-global-data' );
34
 
35
- $yasr_visitor_votes_loader = '<div id="loader-visitor-rating" style="display: inline-block">&nbsp; '.
36
- ' <img src="' . esc_url(YASR_IMG_DIR . 'loader.gif').'" title="yasr-loader" alt="yasr-loader"></div>';
 
 
 
 
37
 
38
  $yasr_common_data = array(
39
  'siteUrl' => site_url(),
@@ -42,6 +46,7 @@ function yasr_add_scripts_includes() {
42
  'visitorStatsEnabled' => YASR_VISITORS_STATS,
43
  'ajaxEnabled' => YASR_ENABLE_AJAX,
44
  'loaderHtml' => $yasr_visitor_votes_loader,
 
45
  );
46
 
47
  //check if wp_localize_script has already run before
@@ -55,7 +60,7 @@ function yasr_add_scripts_includes() {
55
  $yasr_common_data
56
  );
57
 
58
- //use a constant to be sure that yasr-global-data is not loaded twice
59
  define ('YASR_GLOBAL_DATA_EXISTS', true);
60
  }
61
 
@@ -121,7 +126,6 @@ function yasr_rtl_support() {
121
  $yasr_rtl_css = '.yasr-star-rating .yasr-star-value {
122
  -moz-transform: scaleX(-1);
123
  -o-transform: scaleX(-1);
124
-
125
  -webkit-transform: scaleX(-1);
126
  transform: scaleX(-1);
127
  filter: FlipH;
@@ -427,4 +431,4 @@ function yasr_is_catch_infinite_sroll_installed () {
427
  return true;
428
  }
429
  return false;
430
- }
32
  wp_register_script( 'yasr-global-data', '', [], '', true );
33
  wp_enqueue_script( 'yasr-global-data' );
34
 
35
+ $yasr_visitor_votes_loader =
36
+ '<div id="loader-visitor-rating" style="display: inline-block">&nbsp; '.
37
+ '<img src="' . esc_url(YASR_IMG_DIR . 'loader.gif').'"
38
+ title="yasr-loader" alt="yasr-loader" height="16" width="16">'.
39
+ '</div>';
40
+
41
 
42
  $yasr_common_data = array(
43
  'siteUrl' => site_url(),
46
  'visitorStatsEnabled' => YASR_VISITORS_STATS,
47
  'ajaxEnabled' => YASR_ENABLE_AJAX,
48
  'loaderHtml' => $yasr_visitor_votes_loader,
49
+ 'loaderUrl' => esc_url(YASR_IMG_DIR . 'loader.gif')
50
  );
51
 
52
  //check if wp_localize_script has already run before
60
  $yasr_common_data
61
  );
62
 
63
+ //use a constant to be sure that yasrCommonData is not loaded twice
64
  define ('YASR_GLOBAL_DATA_EXISTS', true);
65
  }
66
 
126
  $yasr_rtl_css = '.yasr-star-rating .yasr-star-value {
127
  -moz-transform: scaleX(-1);
128
  -o-transform: scaleX(-1);
 
129
  -webkit-transform: scaleX(-1);
130
  transform: scaleX(-1);
131
  filter: FlipH;
431
  return true;
432
  }
433
  return false;
434
+ }
includes/yasr-includes-init.php CHANGED
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
- if ( ! defined( 'ABSPATH' ) ) {
21
- exit( 'You\'re not allowed to see this page' );
22
  } // Exit if accessed directly
23
 
24
  //e.g. http://localhost/plugin_development/wp-content/plugins/yet-another-stars-rating/includes/js/
@@ -315,4 +315,4 @@ add_action('plugins_loaded', static function () {
315
  });
316
 
317
  //Load rest API
318
- require YASR_ABSOLUTE_PATH_INCLUDES . '/rest/yasr-rest.php';
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
  } // Exit if accessed directly
23
 
24
  //e.g. http://localhost/plugin_development/wp-content/plugins/yet-another-stars-rating/includes/js/
315
  });
316
 
317
  //Load rest API
318
+ require YASR_ABSOLUTE_PATH_INCLUDES . '/rest/yasr-rest.php';
public/classes/YasrPublicFilters.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit( 'You\'re not allowed to see this page' );
5
  } // Exit if accessed directly
6
-
7
  /**
8
  * Public filters
9
  *
@@ -244,7 +243,7 @@ class YasrPublicFilters {
244
  id='$htmlid'
245
  data-rating='$average_rating'
246
  data-rater-starsize='16'
247
- data-rater-postid='$post_id'
248
  data-rater-readonly='true'
249
  data-readonly-attribute='true'
250
  ></div>";
@@ -312,4 +311,4 @@ class YasrPublicFilters {
312
  return $more_link_element;
313
  },9999,1);
314
  }
315
- }
1
  <?php
2
 
3
+ if (!defined('ABSPATH')) {
4
+ exit('You\'re not allowed to see this page');
5
  } // Exit if accessed directly
 
6
  /**
7
  * Public filters
8
  *
243
  id='$htmlid'
244
  data-rating='$average_rating'
245
  data-rater-starsize='16'
246
+ data-rater-postid='$post_id'
247
  data-rater-readonly='true'
248
  data-readonly-attribute='true'
249
  ></div>";
311
  return $more_link_element;
312
  },9999,1);
313
  }
314
+ }
public/classes/YasrRichSnippets.php CHANGED
@@ -1,5 +1,9 @@
1
  <?php
2
 
 
 
 
 
3
  /**
4
  * This class hook to yasr_filter_existing_schema, get the post meta
5
  * yasr_schema_additional_fields, and depending of the itemType selected
@@ -272,15 +276,13 @@ class YasrRichSnippets {
272
  $average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
273
  $average_rating = round($average_rating, 1);
274
 
275
- $rich_snippet = array(
276
  '@type' => 'AggregateRating',
277
  'ratingValue' => $average_rating,
278
  'ratingCount' => $visitor_votes['number_of_votes'],
279
  'bestRating' => 5,
280
  'worstRating' => 1,
281
  );
282
-
283
- return $rich_snippet;
284
  }
285
  return false;
286
  }
@@ -617,4 +619,4 @@ class YasrRichSnippets {
617
  }
618
  return $schema_title;
619
  }
620
- }
1
  <?php
2
 
3
+ if (!defined('ABSPATH')) {
4
+ exit('You\'re not allowed to see this page');
5
+ } // Exit if accessed directly
6
+
7
  /**
8
  * This class hook to yasr_filter_existing_schema, get the post meta
9
  * yasr_schema_additional_fields, and depending of the itemType selected
276
  $average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
277
  $average_rating = round($average_rating, 1);
278
 
279
+ return array(
280
  '@type' => 'AggregateRating',
281
  'ratingValue' => $average_rating,
282
  'ratingCount' => $visitor_votes['number_of_votes'],
283
  'bestRating' => 5,
284
  'worstRating' => 1,
285
  );
 
 
286
  }
287
  return false;
288
  }
619
  }
620
  return $schema_title;
621
  }
622
+ }
public/yasr-public-actions.php CHANGED
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
- if ( ! defined( 'ABSPATH' ) ) {
21
- exit( 'You\'re not allowed to see this page' );
22
  } // Exit if accessed directly
23
 
24
  /***** Adding javascript and css *****/
@@ -44,4 +44,4 @@ function yasr_add_scripts() {
44
 
45
  do_action('yasr_add_front_script_js');
46
 
47
- }
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
  } // Exit if accessed directly
23
 
24
  /***** Adding javascript and css *****/
44
 
45
  do_action('yasr_add_front_script_js');
46
 
47
+ }
public/yasr-public-init.php CHANGED
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
- if ( ! defined( 'ABSPATH' ) ) {
21
- exit( 'You\'re not allowed to see this page' );
22
  } // Exit if accessed directly
23
 
24
  //e.g. http://localhost/plugin_development/wp-content/plugins/yet-another-stars-rating/includes/js/
17
  along with this program. If not, see <http://www.gnu.org/licenses/>
18
  */
19
 
20
+ if (!defined('ABSPATH')) {
21
+ exit('You\'re not allowed to see this page');
22
  } // Exit if accessed directly
23
 
24
  //e.g. http://localhost/plugin_development/wp-content/plugins/yet-another-stars-rating/includes/js/
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.9.2
7
- Stable tag: 3.0.2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  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
@@ -203,6 +203,12 @@ Yes, YASR is 100% fully compatible with PHP 8
203
 
204
  The full changelog can be found in the plugin's directory. Recent entries:
205
 
 
 
 
 
 
 
206
  = 3.0.2 =
207
  * Updated Freemius SDK
208
 
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.9.2
7
+ Stable tag: 3.0.3
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  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
203
 
204
  The full changelog can be found in the plugin's directory. Recent entries:
205
 
206
+ = 3.0.3 =
207
+ * FIX: if parameter 'show_average' is enabled on a multi set, a duplicate query was run.
208
+ * TWEAKED: loader image has height and width attributes set.
209
+ * TWEAKED: minor changes
210
+
211
+
212
  = 3.0.2 =
213
  * Updated Freemius SDK
214
 
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: 3.0.2
8
  * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
@@ -78,7 +78,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
- define( 'YASR_VERSION_NUM', '3.0.2' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  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: 3.0.3
8
  * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
+ define( 'YASR_VERSION_NUM', '3.0.3' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );