Yasr – Yet Another Stars Rating - Version 2.7.3

Version Description

  • NEW FEATURE: new shortcode: yasr_multi_set_ranking : this will show rankings from yasr_multiset
  • TWEAKED: code cleanup.
Download this release

Release Info

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

Code changes from version 2.7.2 to 2.7.3

admin/editor/YasrOnSavePost.php CHANGED
@@ -204,8 +204,8 @@ class YasrOnSavePost {
204
  private function saveMultisetEditor() {
205
  if (isset($_POST['yasr_multiset_author_votes']) && isset($_POST['yasr_multiset_id'])) {
206
  $field_and_vote_array = json_decode(sanitize_text_field(stripslashes($_POST['yasr_multiset_author_votes'])));
207
- $set_id = (int) $_POST['yasr_multiset_id'];
208
- $nonce = $_POST['yasr_nonce_save_multi_values'];
209
 
210
  if (!is_int($set_id) || $field_and_vote_array == '') {
211
  return;
204
  private function saveMultisetEditor() {
205
  if (isset($_POST['yasr_multiset_author_votes']) && isset($_POST['yasr_multiset_id'])) {
206
  $field_and_vote_array = json_decode(sanitize_text_field(stripslashes($_POST['yasr_multiset_author_votes'])));
207
+ $set_id = (int) $_POST['yasr_multiset_id'];
208
+ $nonce = $_POST['yasr_nonce_save_multi_values'];
209
 
210
  if (!is_int($set_id) || $field_and_vote_array == '') {
211
  return;
admin/js/src/yasr-editor-screen.js CHANGED
@@ -241,7 +241,6 @@ function yasrPrintAdminMultiSet(setId, postid, nMultiSet) {
241
  var content = '';
242
 
243
  for (var i = 0; i < yasrMultiSetValue.length; i++) {
244
-
245
  var valueName = yasrMultiSetValue[i]['name'];
246
  var valueRating = yasrMultiSetValue[i]['average_rating'];
247
  var valueID = yasrMultiSetValue[i]['id'];
@@ -286,23 +285,23 @@ function yasrSetRaterAdminMulti(setId) {
286
  //update hidden field
287
  document.getElementById('yasr-multiset-id').value = setId;
288
 
289
- var yasrMultiSetAdmin = document.getElementsByClassName('yasr-multiset-admin');
290
 
291
  //an array with all the ratings objects
292
- var ratingArray = [];
293
- var ratingValue = false;
294
 
295
- for (var i = 0; i < yasrMultiSetAdmin.length; i++) {
296
 
297
  (function (i) {
298
 
299
- var htmlId = yasrMultiSetAdmin.item(i).id;
300
- var elem = document.getElementById(htmlId);
301
 
302
- var setIdField = parseInt(elem.getAttribute('data-multi-idfield'));
303
- var ratingOnLoad = parseInt(elem.getAttribute('data-rating'));
304
 
305
- var ratingObjectOnLoad = {
306
  field: setIdField,
307
  rating: ratingOnLoad
308
  };
@@ -310,7 +309,6 @@ function yasrSetRaterAdminMulti(setId) {
310
  //creating rating array
311
  ratingArray.push(ratingObjectOnLoad);
312
 
313
-
314
  raterJs({
315
  starSize: 32,
316
  step: 0.5,
@@ -324,13 +322,14 @@ function yasrSetRaterAdminMulti(setId) {
324
  rating = parseFloat(rating);
325
  this.setRating(rating); //Set the rating
326
 
327
- var ratingObject = {
328
- field: setIdField,
329
- rating: rating
330
- };
331
-
332
- //creating rating array
333
- ratingArray.push(ratingObject);
 
334
 
335
  ratingValue = JSON.stringify(ratingArray);
336
 
241
  var content = '';
242
 
243
  for (var i = 0; i < yasrMultiSetValue.length; i++) {
 
244
  var valueName = yasrMultiSetValue[i]['name'];
245
  var valueRating = yasrMultiSetValue[i]['average_rating'];
246
  var valueID = yasrMultiSetValue[i]['id'];
285
  //update hidden field
286
  document.getElementById('yasr-multiset-id').value = setId;
287
 
288
+ let yasrMultiSetAdmin = document.getElementsByClassName('yasr-multiset-admin');
289
 
290
  //an array with all the ratings objects
291
+ let ratingArray = [];
292
+ let ratingValue = false;
293
 
294
+ for (let i = 0; i < yasrMultiSetAdmin.length; i++) {
295
 
296
  (function (i) {
297
 
298
+ let htmlId = yasrMultiSetAdmin.item(i).id;
299
+ let elem = document.getElementById(htmlId);
300
 
301
+ let setIdField = parseInt(elem.getAttribute('data-multi-idfield'));
302
+ let ratingOnLoad = parseInt(elem.getAttribute('data-rating'));
303
 
304
+ let ratingObjectOnLoad = {
305
  field: setIdField,
306
  rating: ratingOnLoad
307
  };
309
  //creating rating array
310
  ratingArray.push(ratingObjectOnLoad);
311
 
 
312
  raterJs({
313
  starSize: 32,
314
  step: 0.5,
322
  rating = parseFloat(rating);
323
  this.setRating(rating); //Set the rating
324
 
325
+ //loop the array with existing rates
326
+ for (let j = 0; j < ratingArray.length; j++) {
327
+ //if the field of the array is the same of the rated field, get the rating
328
+ if(ratingArray[j].field === setIdField) {
329
+ //the selected rating overwrite the existing one
330
+ ratingArray[j].rating = rating;
331
+ }
332
+ }
333
 
334
  ratingValue = JSON.stringify(ratingArray);
335
 
admin/js/src/yasr-settings-rankings.js CHANGED
@@ -51,15 +51,19 @@ if (activeTab === 'rankings') {
51
  let dataSource = selectDataSource.value;
52
  let previewClicked = false;
53
 
54
- //if on page load is overall_rating (e.g. on page refresh) text div must be displayed
55
- if(dataSource === 'yasr_ov_ranking') {
 
56
  yasrBuilderOvOptions(divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
57
  }
58
  else if(dataSource === 'yasr_most_active_users' || dataSource === 'yasr_top_reviewers') {
59
  yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
60
  }
 
 
 
61
  else if(dataSource === 'yasr_visitor_multi_set_ranking') {
62
- yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
63
  }
64
  else {
65
  yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet)
@@ -84,8 +88,13 @@ if (activeTab === 'rankings') {
84
  else if(event.target.value === 'yasr_most_active_users' || event.target.value === 'yasr_top_reviewers') {
85
  yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
86
  }
 
 
 
 
 
87
  else if(event.target.value === 'yasr_visitor_multi_set_ranking') {
88
- yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
89
  //get the value of the first option(array key 0) in the select
90
  shortcodeAttributes['setid'] = ' setid='+selectMultiset[0].value;
91
  }
@@ -164,6 +173,7 @@ if (activeTab === 'rankings') {
164
  let shortcodesDrawRankings = [
165
  'yasr_ov_ranking',
166
  'yasr_most_or_highest_rated_posts',
 
167
  'yasr_visitor_multi_set_ranking'
168
  ];
169
 
@@ -227,7 +237,17 @@ if (activeTab === 'rankings') {
227
  };
228
  }
229
 
230
-
 
 
 
 
 
 
 
 
 
 
231
  function yasrBuilderOvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
232
  //Here the div must not be 33 but 24
233
  divParamsContainer.className = '';
@@ -248,6 +268,17 @@ if (activeTab === 'rankings') {
248
  }
249
  }
250
 
 
 
 
 
 
 
 
 
 
 
 
251
  function yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
252
  divView.style.display = ''
253
  divVotes.style.display = '';
@@ -263,6 +294,17 @@ if (activeTab === 'rankings') {
263
  }
264
  }
265
 
 
 
 
 
 
 
 
 
 
 
 
266
  function yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
267
  divUsername.style.display = '';
268
  divOverallTxt.style.display = 'none';
@@ -278,19 +320,47 @@ if (activeTab === 'rankings') {
278
  }
279
  }
280
 
281
- function yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
282
- divView.style.display = ''
283
- divVotes.style.display = '';
284
- divSize.style.display = '';
285
- divCategory.style.display = '';
286
- divOverallTxt.style.display = 'none';
287
- divUsername.style.display = 'none';
288
- if(divCpt !== null) {
289
- divCpt.style.display = '';
290
- }
291
- if(divMultiSet !== null) {
292
- divMultiSet.style.display = '';
293
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  }
295
 
296
  }
51
  let dataSource = selectDataSource.value;
52
  let previewClicked = false;
53
 
54
+ //if on page load is selected something else from the default ranking (yasr_most_or_highest_rated_posts)
55
+ //show the proper fields
56
+ if(dataSource === 'yasr_ov_ranking' ) {
57
  yasrBuilderOvOptions(divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
58
  }
59
  else if(dataSource === 'yasr_most_active_users' || dataSource === 'yasr_top_reviewers') {
60
  yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
61
  }
62
+ else if(dataSource === 'yasr_multi_set_ranking') {
63
+ yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, false);
64
+ }
65
  else if(dataSource === 'yasr_visitor_multi_set_ranking') {
66
+ yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, true);
67
  }
68
  else {
69
  yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet)
88
  else if(event.target.value === 'yasr_most_active_users' || event.target.value === 'yasr_top_reviewers') {
89
  yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet);
90
  }
91
+ else if(event.target.value === 'yasr_multi_set_ranking') {
92
+ yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, false);
93
+ //get the value of the first option(array key 0) in the select
94
+ shortcodeAttributes['setid'] = ' setid='+selectMultiset[0].value;
95
+ }
96
  else if(event.target.value === 'yasr_visitor_multi_set_ranking') {
97
+ yasrBuilderMultisetOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet, true);
98
  //get the value of the first option(array key 0) in the select
99
  shortcodeAttributes['setid'] = ' setid='+selectMultiset[0].value;
100
  }
173
  let shortcodesDrawRankings = [
174
  'yasr_ov_ranking',
175
  'yasr_most_or_highest_rated_posts',
176
+ 'yasr_multi_set_ranking',
177
  'yasr_visitor_multi_set_ranking'
178
  ];
179
 
237
  };
238
  }
239
 
240
+ /**
241
+ *
242
+ * @param divOverallTxt
243
+ * @param divSize
244
+ * @param divView
245
+ * @param divVotes
246
+ * @param divUsername
247
+ * @param divCategory
248
+ * @param divCpt
249
+ * @param divMultiSet
250
+ */
251
  function yasrBuilderOvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
252
  //Here the div must not be 33 but 24
253
  divParamsContainer.className = '';
268
  }
269
  }
270
 
271
+ /**
272
+ *
273
+ * @param divOverallTxt
274
+ * @param divSize
275
+ * @param divView
276
+ * @param divVotes
277
+ * @param divUsername
278
+ * @param divCategory
279
+ * @param divCpt
280
+ * @param divMultiSet
281
+ */
282
  function yasrBuilderVvOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
283
  divView.style.display = ''
284
  divVotes.style.display = '';
294
  }
295
  }
296
 
297
+ /**
298
+ *
299
+ * @param divOverallTxt
300
+ * @param divSize
301
+ * @param divView
302
+ * @param divVotes
303
+ * @param divUsername
304
+ * @param divCategory
305
+ * @param divCpt
306
+ * @param divMultiSet
307
+ */
308
  function yasrBuilderNoStarsOptions (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt, divMultiSet) {
309
  divUsername.style.display = '';
310
  divOverallTxt.style.display = 'none';
320
  }
321
  }
322
 
323
+ /**
324
+ *
325
+ * @param divOverallTxt
326
+ * @param divSize
327
+ * @param divView
328
+ * @param divVotes
329
+ * @param divUsername
330
+ * @param divCategory
331
+ * @param divCpt
332
+ * @param divMultiSet
333
+ * @param visitor
334
+ */
335
+ function yasrBuilderMultisetOptions
336
+ (divOverallTxt, divSize, divView, divVotes, divUsername, divCategory, divCpt,
337
+ divMultiSet, visitor=false
338
+ ) {
339
+ //common params for both
340
+ divCategory.style.display = '';
341
+ divSize.style.display = '';
342
+ divUsername.style.display = 'none';
343
+
344
+ if(divCpt !== null) {
345
+ divCpt.style.display = '';
346
+ }
347
+ if(divMultiSet !== null) {
348
+ divMultiSet.style.display = '';
349
+ }
350
+
351
+ //params for yasr_visitor_multi_set_ranking
352
+ if(visitor === true) {
353
+ divView.style.display = ''
354
+ divVotes.style.display = '';
355
+ divOverallTxt.style.display = 'none';
356
+ }
357
+ //params for yasr_visitor_multi_set_ranking
358
+ else {
359
+ //common params for both
360
+ divView.style.display = 'none'
361
+ divVotes.style.display = 'none';
362
+ divOverallTxt.style.display = '';
363
+ }
364
  }
365
 
366
  }
admin/js/yasr-editor-screen.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){e.exports=n(1)},function(e,t){function n(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 a(e,t,n){const a={action:"yasr_send_id_nameset",set_id:e,post_id:t};return jQuery.post(ajaxurl,a,(function(t){n>1&&(document.getElementById("yasr-loader-select-multi-set").style.display="none");for(var a=JSON.parse(t),o="",i=0;i<a.length;i++){var s=a[i].name,r=a[i].average_rating,l=a[i].id;o+="<tr>",o+="<td>"+s+"</td>",o+='<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-'+l+'" data-rating="'+r+'" data-multi-idfield="'+l+'"></div>',o+='<span id="yasr-loader-multi-set-field-'+l+'" style="display: none">',o+='<img src="'+yasrCommonData.loaderHtml+'" alt="yasr-loader"></span>',o+="</span>",o+="</td>",o+="</tr>",document.getElementById("yasr-table-multi-set-admin").innerHTML=o}document.getElementById("yasr-multi-set-admin-choose-text").style.display="block",function(e){document.getElementById("yasr-multiset-id").value=e;for(var t=document.getElementsByClassName("yasr-multiset-admin"),n=[],a=!1,o=0;o<t.length;o++)!function(e){var o=t.item(e).id,i=document.getElementById(o),s=parseInt(i.getAttribute("data-multi-idfield")),r=parseInt(i.getAttribute("data-rating")),l={field:s,rating:r};n.push(l),raterJs({starSize:32,step:.5,showToolTip:!1,readOnly:!1,element:i,rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),this.setRating(e);var o={field:s,rating:e};n.push(o),a=JSON.stringify(n),document.getElementById("yasr-multiset-author-votes").value=a,t()}})}(o)}(e),document.getElementById("yasr-multi-set-admin-explain").style.display="block",document.getElementById("yasr-multi-set-admin-explain-with-id-readonly").innerHTML="<strong>[yasr_multiset setid="+e+"]</strong>",document.getElementById("yasr-multi-set-admin-explain-with-id-visitor").innerHTML="<strong>[yasr_visitor_multiset setid="+e+"]</strong>"})),!1}document.addEventListener("DOMContentLoaded",(function(e){!0!==document.body.classList.contains("block-editor-page")&&(!function(){let e=parseFloat(document.getElementById("yasr-overall-rating-value").value);raterJs({starSize:32,step:.1,showToolTip:!1,rating:e,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()}})}(),jQuery.get(ajaxurl,{action:"yasr_create_shortcode"},(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("click",(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 e=document.getElementById("yasr-metabox-below-editor-select-schema").value;null!==document.getElementById("yasr-editor-multiset-container")&&function(){let e=document.getElementById("yasr-editor-multiset-container"),t=parseInt(e.getAttribute("data-nmultiset")),n=parseInt(e.getAttribute("data-setid")),o=parseInt(e.getAttribute("data-postid"));a(n,o,t),t>1&&jQuery("#yasr-button-select-set").on("click",(function(){return n=jQuery("#select_set").val(),jQuery("#yasr-loader-select-multi-set").show(),a(n,o,t),!1}))}();n(e)}()})),document.getElementById("yasr-metabox-below-editor-select-schema").addEventListener("change",(function(){n(this.value)}))}]);
1
+ !function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){e.exports=n(1)},function(e,t){function n(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 a(e,t,n){const a={action:"yasr_send_id_nameset",set_id:e,post_id:t};return jQuery.post(ajaxurl,a,(function(t){n>1&&(document.getElementById("yasr-loader-select-multi-set").style.display="none");for(var a=JSON.parse(t),o="",i=0;i<a.length;i++){var s=a[i].name,r=a[i].average_rating,l=a[i].id;o+="<tr>",o+="<td>"+s+"</td>",o+='<td><div class="yasr-multiset-admin" id="yasr-multiset-admin-'+l+'" data-rating="'+r+'" data-multi-idfield="'+l+'"></div>',o+='<span id="yasr-loader-multi-set-field-'+l+'" style="display: none">',o+='<img src="'+yasrCommonData.loaderHtml+'" alt="yasr-loader"></span>',o+="</span>",o+="</td>",o+="</tr>",document.getElementById("yasr-table-multi-set-admin").innerHTML=o}document.getElementById("yasr-multi-set-admin-choose-text").style.display="block",function(e){document.getElementById("yasr-multiset-id").value=e;let t=document.getElementsByClassName("yasr-multiset-admin"),n=[],a=!1;for(let e=0;e<t.length;e++)!function(e){let o=t.item(e).id,i=document.getElementById(o),s=parseInt(i.getAttribute("data-multi-idfield")),r=parseInt(i.getAttribute("data-rating")),l={field:s,rating:r};n.push(l),raterJs({starSize:32,step:.5,showToolTip:!1,readOnly:!1,element:i,rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),this.setRating(e);for(let t=0;t<n.length;t++)n[t].field===s&&(n[t].rating=e);a=JSON.stringify(n),document.getElementById("yasr-multiset-author-votes").value=a,t()}})}(e)}(e),document.getElementById("yasr-multi-set-admin-explain").style.display="block",document.getElementById("yasr-multi-set-admin-explain-with-id-readonly").innerHTML="<strong>[yasr_multiset setid="+e+"]</strong>",document.getElementById("yasr-multi-set-admin-explain-with-id-visitor").innerHTML="<strong>[yasr_visitor_multiset setid="+e+"]</strong>"})),!1}document.addEventListener("DOMContentLoaded",(function(e){!0!==document.body.classList.contains("block-editor-page")&&(!function(){let e=parseFloat(document.getElementById("yasr-overall-rating-value").value);raterJs({starSize:32,step:.1,showToolTip:!1,rating:e,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()}})}(),jQuery.get(ajaxurl,{action:"yasr_create_shortcode"},(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("click",(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 e=document.getElementById("yasr-metabox-below-editor-select-schema").value;null!==document.getElementById("yasr-editor-multiset-container")&&function(){let e=document.getElementById("yasr-editor-multiset-container"),t=parseInt(e.getAttribute("data-nmultiset")),n=parseInt(e.getAttribute("data-setid")),o=parseInt(e.getAttribute("data-postid"));a(n,o,t),t>1&&jQuery("#yasr-button-select-set").on("click",(function(){return n=jQuery("#select_set").val(),jQuery("#yasr-loader-select-multi-set").show(),a(n,o,t),!1}))}();n(e)}()})),document.getElementById("yasr-metabox-below-editor-select-schema").addEventListener("change",(function(){n(this.value)}))}]);
admin/js/yasr-settings.js CHANGED
@@ -1 +1 @@
1
- !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(2)},function(t,e){var r;if(document.getElementsByClassName("nav-tab-active").length>0&&(r=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===r){var a=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked,s=document.getElementById("yasr-general-options-text-before-stars-switch").checked;!1===a&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),!1===s&&jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!0),document.getElementById("yasr-general-options-text-before-stars-switch").addEventListener("change",(function(){this.checked?(jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!1),jQuery("#yasr-general-options-custom-text-before-overall").val("Our Score"),jQuery("#yasr-general-options-custom-text-before-visitor").val("Click to rate this post!"),jQuery("#yasr-general-options-custom-text-after-visitor").val("[Total: %total_count% Average: %average%]"),jQuery("#yasr-general-options-custom-text-must-sign-in").val("You must sign in to vote"),jQuery("#yasr-general-options-custom-text-already-rated").val("You have already voted for this article with %rating%")):jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!0)}))}if("style_options"===r&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===r){var o=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===o){var i=jQuery("#yasr-edit-form-number-elements").attr("value");i++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(i>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 #'+i+' <input type="text" name="edit-multi-set-element-'+i+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),i++}))}else o>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===r&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,r){"use strict";var a,n;r.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},d=[],u=0;u<256;++u)d.push((u+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(d[t[e+0]]+d[t[e+1]]+d[t[e+2]]+d[t[e+3]]+"-"+d[t[e+4]]+d[t[e+5]]+"-"+d[t[e+6]]+d[t[e+7]]+"-"+d[t[e+8]]+d[t[e+9]]+"-"+d[t[e+10]]+d[t[e+11]]+d[t[e+12]]+d[t[e+13]]+d[t[e+14]]+d[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};for(var y=function(t,e,r){var a=(t=t||{}).random||(t.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return c(a)},m=wp.i18n.__,p=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],g=0;g<p.length;g++)f(p[g]);function f(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;v(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),s=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=b(n),s=b(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),d=parseInt(r.getAttribute("data-rater-starsize")),u=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),y="yasr-vv-votes-number-container-"+l,p="yasr-vv-average-container-"+l,g=document.getElementById(y),f=document.getElementById(p),v="yasr-vv-loader-"+l,_=!1;if("yes"===yasrCommonData.ajaxEnabled){var E=r.getAttribute("data-cpt");""===E&&(E="posts");var k="wp/v2/"+E+"/"+o+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+k).done((function(t){var e;(e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),h(d,a,o,e,i,l,u,c,g,f,v),!0!==n)&&(null!==g&&(g.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&(_=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(v).innerHTML=_))})).fail((function(t,e,r,y){console.info(m("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(d,a,o,s,i,l,u,c,g,f,v),!0!==n&&(document.getElementById("yasr-below-stars-hidden-"+l).style.display="")}))}else h(d,a,o,s,i,l,u,c,g,f,v)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),s=n.id,o=n.getAttribute("data-rater-readonly");o=b(o);v(16,s,n,1,o,!1,(function(t,a){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function v(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:s,rating:o,rateCallback:i})}function h(t,e,r,a,n,s,o,i,l,d,u){e=parseFloat(e),a=b(a);v(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(u).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==d&&(d.innerHTML=t.average_rating),document.getElementById(u).innerHTML=t.rating_saved_text})),e()}))}function b(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function _(t){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function w(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=j(t);if(e){var n=j(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return I(this,r)}}function I(t,e){return!e||"object"!==_(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function j(t){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}M();var B=wp.i18n.__,R=wp.element.render;function x(t){var e="yasr-ranking-element-"+y(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return v(r,e,!1,.1,!0,t.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",B("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",B("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function Q(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function L(t){var e="after",r=B("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:r}),React.createElement(x,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(x,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:r}))}function T(t){var e="",r="";return"overall_rating"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(Q,{colClass:e,post:t.post}),React.createElement(L,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"overall_rating"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","overall_rating"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(T,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var H=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}(s,React.Component);var e,r,a,n=w(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=s,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(B("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(B("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source?r=t:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(B(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(B(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:B("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"===r&&null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("overall_rating"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+o,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("overall_rating"!==t){var s=React.createElement("span",null,React.createElement("span",{id:a},B("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},B("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},B("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},B("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,B("Order By","yet-another-stars-rating-pro"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,s="most-rated-posts-"+r,o="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r)return React.createElement(S,{data:e.data_overall,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",d=new URLSearchParams(a);return null!==d.get("view")&&(o=d.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(S,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,B("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,r),a&&E(e,a),s}();function M(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=document.getElementById(r);R(React.createElement(H,{source:a,tableId:r,params:n}),s)}}var O,P=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(O=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===O){var A,N=function(t){var e=G.value,r=document.getElementById("yasr-builder-shortcode").textContent,a=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_visitor_multi_set_ranking"];a=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",a),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+r).then((function(t){return!0===t.ok?t.json():(console.info(P("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,Y.childNodes.length>0?Y.replaceChild(e,Y.childNodes[0]):Y.appendChild(e)}})).then((function(t){a.forEach((function(t){e===t&&M()}))}))},D=function(t,e,r,a,n,s,o,i){W.className="",W.classList.add("yasr-settings-row-24"),t.style.display="",e.style.display="",s.style.display="",r.style.display="none",a.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},F=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,r,a,n,s,o,i){n.style.display="",t.style.display="none",r.style.display="none",a.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},U=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var q=[],J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""};A=J.name,document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]");var V=document.getElementById("yasr-builder-button-preview"),K=document.getElementById("yasr-builder-copy-shortcode"),Y=document.getElementById("yasr-builder-preview"),G=document.getElementById("yasr-ranking-source"),$=document.getElementById("yasr-ranking-multiset-select"),W=document.getElementById("yasr-builder-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),rt=document.getElementById("builder-username-options"),at=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=G.value,it=!1;"yasr_ov_ranking"===ot?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===ot||"yasr_top_reviewers"===ot?z(et,tt,X,Z,rt,at,nt,st):"yasr_visitor_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st):F(et,tt,X,Z,rt,at,nt,st),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),Y.innerHTML="",J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(et,tt,X,Z,rt,at,nt,st):"yasr_visitor_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st),J.setid=" setid="+$[0].value):F(et,tt,X,Z,rt,at,nt,st),J.name=t.target.value,A=J.name+J.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(J.setid=" setid="+t.target.value),q=wp.hooks.applyFilters("yasrBuilderFilterShortcode",J);for(var e=2;J.length;e++)q.hasOwnProperty(J[e])&&(J[e]=q[e]);A=J.name+J.setid+J.rows+J.view+J.minvotesmost+J.minvoteshg+J.size+J.txtPosition+J.txt+J.display+J.category+J.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]"),!0===it&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&N()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){N(),it=!0}}}]);
1
+ !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(2)},function(t,e){var r;if(document.getElementsByClassName("nav-tab-active").length>0&&(r=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===r){var a=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked,s=document.getElementById("yasr-general-options-text-before-stars-switch").checked;!1===a&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),!1===s&&jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!0),document.getElementById("yasr-general-options-text-before-stars-switch").addEventListener("change",(function(){this.checked?(jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!1),jQuery("#yasr-general-options-custom-text-before-overall").val("Our Score"),jQuery("#yasr-general-options-custom-text-before-visitor").val("Click to rate this post!"),jQuery("#yasr-general-options-custom-text-after-visitor").val("[Total: %total_count% Average: %average%]"),jQuery("#yasr-general-options-custom-text-must-sign-in").val("You must sign in to vote"),jQuery("#yasr-general-options-custom-text-already-rated").val("You have already voted for this article with %rating%")):jQuery(".yasr-general-options-text-before").find(":input").prop("disabled",!0)}))}if("style_options"===r&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===r){var o=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===o){var i=jQuery("#yasr-edit-form-number-elements").attr("value");i++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(i>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 #'+i+' <input type="text" name="edit-multi-set-element-'+i+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),i++}))}else o>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===r&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,r){"use strict";var a,n;r.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};for(var y=function(t,e,r){var a=(t=t||{}).random||(t.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return c(a)},m=wp.i18n.__,p=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],g=0;g<p.length;g++)f(p[g]);function f(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;v(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),s=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=_(n),s=_(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),d=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),y="yasr-vv-votes-number-container-"+l,p="yasr-vv-average-container-"+l,g=document.getElementById(y),f=document.getElementById(p),v="yasr-vv-loader-"+l,b=!1;if("yes"===yasrCommonData.ajaxEnabled){var E=r.getAttribute("data-cpt");""===E&&(E="posts");var k="wp/v2/"+E+"/"+o+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+k).done((function(t){var e;(e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),h(u,a,o,e,i,l,d,c,g,f,v),!0!==n)&&(null!==g&&(g.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&(b=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(v).innerHTML=b))})).fail((function(t,e,r,y){console.info(m("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(u,a,o,s,i,l,d,c,g,f,v),!0!==n&&(document.getElementById("yasr-below-stars-hidden-"+l).style.display="")}))}else h(u,a,o,s,i,l,d,c,g,f,v)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),s=n.id,o=n.getAttribute("data-rater-readonly");o=_(o);v(16,s,n,1,o,!1,(function(t,a){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function v(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:s,rating:o,rateCallback:i})}function h(t,e,r,a,n,s,o,i,l,u,d){e=parseFloat(e),a=_(a);v(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(d).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),document.getElementById(d).innerHTML=t.rating_saved_text})),e()}))}function _(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function b(t){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function w(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=j(t);if(e){var n=j(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return I(this,r)}}function I(t,e){return!e||"object"!==b(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function j(t){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}M();var B=wp.i18n.__,R=wp.element.render;function x(t){var e="yasr-ranking-element-"+y(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return v(r,e,!1,.1,!0,t.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",B("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",B("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function Q(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function L(t){var e="after",r=B("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:r}),React.createElement(x,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(x,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:r}))}function T(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(Q,{colClass:e,post:t.post}),React.createElement(L,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(T,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var H=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}(s,React.Component);var e,r,a,n=w(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=s,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(B("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(B("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(B(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(B(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:B("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+o,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:a},B("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},B("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},B("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},B("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,B("Order By","yet-another-stars-rating-pro"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,s="most-rated-posts-"+r,o="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(S,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(o=u.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(S,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,B("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,r),a&&E(e,a),s}();function M(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=document.getElementById(r);R(React.createElement(H,{source:a,tableId:r,params:n}),s)}}var O,P=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(O=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===O){var A,N=function(t){var e=G.value,r=document.getElementById("yasr-builder-shortcode").textContent,a=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];a=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",a),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+r).then((function(t){return!0===t.ok?t.json():(console.info(P("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,Y.childNodes.length>0?Y.replaceChild(e,Y.childNodes[0]):Y.appendChild(e)}})).then((function(t){a.forEach((function(t){e===t&&M()}))}))},D=function(t,e,r,a,n,s,o,i){W.className="",W.classList.add("yasr-settings-row-24"),t.style.display="",e.style.display="",s.style.display="",r.style.display="none",a.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},F=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,r,a,n,s,o,i){n.style.display="",t.style.display="none",r.style.display="none",a.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},U=function(t,e,r,a,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8];s.style.display="",e.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display=""),!0===l?(r.style.display="",a.style.display="",t.style.display="none"):(r.style.display="none",a.style.display="none",t.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var q=[],J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""};A=J.name,document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]");var V=document.getElementById("yasr-builder-button-preview"),K=document.getElementById("yasr-builder-copy-shortcode"),Y=document.getElementById("yasr-builder-preview"),G=document.getElementById("yasr-ranking-source"),$=document.getElementById("yasr-ranking-multiset-select"),W=document.getElementById("yasr-builder-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),rt=document.getElementById("builder-username-options"),at=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=G.value,it=!1;"yasr_ov_ranking"===ot?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===ot||"yasr_top_reviewers"===ot?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!1):"yasr_visitor_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!0):F(et,tt,X,Z,rt,at,nt,st),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),Y.innerHTML="",J={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!1),J.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!0),J.setid=" setid="+$[0].value):F(et,tt,X,Z,rt,at,nt,st),J.name=t.target.value,A=J.name+J.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(J.setid=" setid="+t.target.value),q=wp.hooks.applyFilters("yasrBuilderFilterShortcode",J);for(var e=2;J.length;e++)q.hasOwnProperty(J[e])&&(J[e]=q[e]);A=J.name+J.setid+J.rows+J.view+J.minvotesmost+J.minvoteshg+J.size+J.txtPosition+J.txt+J.display+J.category+J.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+A+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+A+"]"),!0===it&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&N()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){N(),it=!0}}}]);
admin/settings/aspect_style/yasr-settings-style-actions.php CHANGED
@@ -26,7 +26,6 @@ if (!defined('ABSPATH')) {
26
  add_action('yasr_style_options_add_settings_field', 'yasr_style_options_add_settings_field_callback');
27
 
28
  function yasr_style_options_add_settings_field_callback($style_options) {
29
-
30
  add_settings_field(
31
  'yasr_style_options_choose_stars_lite',
32
  __('Choose Stars Set', 'yet-another-stars-rating'),
@@ -35,7 +34,6 @@ function yasr_style_options_add_settings_field_callback($style_options) {
35
  'yasr_style_options_section_id',
36
  $style_options
37
  );
38
-
39
  }
40
 
41
  function yasr_style_options_choose_stars_lite_callback($style_options) {
@@ -109,12 +107,10 @@ function yasr_style_options_choose_stars_lite_callback($style_options) {
109
  </div>
110
 
111
  <script type="text/javascript">
112
-
113
  jQuery('#yasr-settings-stylish-stars').mouseover(function () {
114
  jQuery('#yasr-settings-stylish-text').css("visibility", "visible");
115
  jQuery('#yasr-settings-stylish-image').css("opacity", 0.4);
116
  });
117
-
118
  </script>
119
 
120
  <?php
26
  add_action('yasr_style_options_add_settings_field', 'yasr_style_options_add_settings_field_callback');
27
 
28
  function yasr_style_options_add_settings_field_callback($style_options) {
 
29
  add_settings_field(
30
  'yasr_style_options_choose_stars_lite',
31
  __('Choose Stars Set', 'yet-another-stars-rating'),
34
  'yasr_style_options_section_id',
35
  $style_options
36
  );
 
37
  }
38
 
39
  function yasr_style_options_choose_stars_lite_callback($style_options) {
107
  </div>
108
 
109
  <script type="text/javascript">
 
110
  jQuery('#yasr-settings-stylish-stars').mouseover(function () {
111
  jQuery('#yasr-settings-stylish-text').css("visibility", "visible");
112
  jQuery('#yasr-settings-stylish-image').css("opacity", 0.4);
113
  });
 
114
  </script>
115
 
116
  <?php
admin/settings/classes/YasrSettingsRankings.php CHANGED
@@ -54,6 +54,7 @@ class YasrSettingsRankings {
54
  );
55
 
56
  if($this->n_multi_set > 0) {
 
57
  $source_array[] = 'yasr_visitor_multi_set_ranking';
58
  }
59
 
54
  );
55
 
56
  if($this->n_multi_set > 0) {
57
+ $source_array[] = 'yasr_multi_set_ranking';
58
  $source_array[] = 'yasr_visitor_multi_set_ranking';
59
  }
60
 
admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -344,7 +344,7 @@ function yasr_ask_rating($position = false) {
344
 
345
 
346
  /****
347
- Yasr Right settings panel, since version 1.9.5
348
  ****/
349
  function yasr_right_settings_panel($position = false) {
350
  do_action('yasr_right_settings_panel_box', $position);
344
 
345
 
346
  /****
347
+ Yasr Right settings panel, since version 1.9.5
348
  ****/
349
  function yasr_right_settings_panel($position = false) {
350
  do_action('yasr_right_settings_panel_box', $position);
admin/settings/yasr-settings-page.php CHANGED
@@ -103,7 +103,7 @@ if (!current_user_can('manage_options')) {
103
  <div class="">
104
  </div>
105
 
106
- <?php
107
  yasr_right_settings_panel('bottom');
108
  ?>
109
  <!--End div wrap-->
103
  <div class="">
104
  </div>
105
 
106
+ <?php
107
  yasr_right_settings_panel('bottom');
108
  ?>
109
  <!--End div wrap-->
changelog.txt CHANGED
@@ -1,3 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 2.4.7 =
2
  * NEW FEATURE: Added new fields for these itemTypes:
3
  #### Book
1
+ = 2.6.2 =
2
+ * TWEAK: yasr_top_ten_highest_rated is now depcrecated. yasr_ov_ranking will take its place
3
+ * TWEAK: yasr_top_5_reviewers is now depcrecated. yasr_top_reviewers will take its place
4
+ * TWEAK: yasr_top_ten_active_users is now depcrecated. yasr_most_active_users will take its place
5
+ * FIX: yasr_visitor_votes didn't work on CPT if AJAX is enabled and CPT is registred without _base parameter
6
+ * FIX: Couldn't add new element in MultiSet if only one is used
7
+ * Updated freemius to version 2.4.2
8
+
9
+ = 2.6.1 =
10
+ * FIX: Visitor rating broken if custom text is enabled. (thanks to @raulpopi)
11
+ * FIX: In some themes (Twenty Twenty, Twenty One and most likely many others) if a post contains the <!--more--> tag, and
12
+ stars next to the title is active, the excpert layout get broken
13
+
14
+ = 2.6.0 =
15
+ * FIX: if load results with ajax is enabled, and for some reason an api call fails, span below the stars didn't shows up
16
+ * TWEAK: containerAfterStars method is now public
17
+
18
+ = 2.5.9 =
19
+ * TWEAK: when a rating is saved, ajax answer returns an array instead of the html. This will no overwrite the actual text but just update it.
20
+ * FIX: "0" Showing up at the end of the titles in some circumstances.
21
+ * Minor changes
22
+
23
+ = 2.5.8 =
24
+ * FIX: wrong css style for rankings yasr_top_5_reviewers and yasr_top_ten_active_users
25
+
26
+ = 2.5.7 =
27
+ * TWEAK: Rankings have been rewritten: now are build in REACT, this will allow much more flexibility
28
+
29
+ = 2.5.6 =
30
+ * FIX: register_rest_route called incorrectly in Gutenberg
31
+ * FIX: random js error into dashboard (thanks to @lwangaman)
32
+ * TWEAK: On stars hover, cursor is now displayed an an hand
33
+ * FIX: minor changes to support older versions
34
+
35
+ = 2.5.5 =
36
+ * FIX: rich snippet's attribute name returns the post_id instead of the title in some circumstances
37
+
38
+ = 2.5.4 =
39
+ * FIX: yasr_visitor_multiset data didn't save correctly if more than one were used in the same page.
40
+
41
+ = 2.5.3 =
42
+ * FIX: in Yet Another Stars Rating: Stats -> Overall Rating only posts with rating > 0 are shown
43
+
44
+ = 2.5.2 =
45
+ * NEW FEATURE: is now possible delete overall rating data in Yet Another Stars Rating -> Stats -> Overall Rating
46
+ * FIXED: Schema title come with rating string if "Enable stars next to the title?" is enabled
47
+ * TWEAKED: all rankings functions has been rewritten to work with REST API. Documentation will come soon.
48
+ * TWEAKED: a lot of minor changes.
49
+
50
+ = 2.5.1 =
51
+ * TWEAKED: added new hooks: yasr_vv_shortcode, yasr_vv_ro_shortcode and yasr_overall_shortcode. These hooks can
52
+ be used to customize the shortcodes.
53
+
54
+ = 2.5.0 =
55
+ * TWEAKED: minor changes. Nothing to be excited about
56
+
57
+ = 2.4.9 =
58
+ * FIXED: Removed unnecessary closing div for yasr_visitor_votes shortcode
59
+
60
+ = 2.4.8 =
61
+ * Removed YasrSettings file from svn repo
62
+
63
+
64
  = 2.4.7 =
65
  * NEW FEATURE: Added new fields for these itemTypes:
66
  #### Book
includes/classes/YasrMultiSetData.php CHANGED
@@ -144,7 +144,7 @@ class YasrMultiSetData {
144
  * )
145
  *
146
  * @param integer $set_id the set id
147
- * @param array $set_fields an array with fields names and id
148
  * @param integer|bool $post_id the post_id
149
  *
150
  * @return bool | array
@@ -247,7 +247,6 @@ class YasrMultiSetData {
247
  $i = 0;
248
  //always returns field id and name
249
  foreach ($set_fields as $fields_ids_and_names) {
250
-
251
  $array_to_return[$i]['id'] = (int) $fields_ids_and_names['id'];
252
  $array_to_return[$i]['name'] = $fields_ids_and_names['name'];
253
  $array_to_return[$i]['average_rating'] = 0;
@@ -273,13 +272,13 @@ class YasrMultiSetData {
273
  }
274
 
275
  /**
276
- * @param int $post_id
277
- * @param int $set_id
278
  * @param bool $visitor_multiset
279
  *
280
  * Get the post_id and the set id, return the average (float)
281
  *
282
- * @return float|int|false|
283
  */
284
  public static function returnMultiSetAverage($post_id, $set_id, $visitor_multiset) {
285
  $post_id = (int)$post_id;
@@ -299,13 +298,42 @@ class YasrMultiSetData {
299
  $multiset_rows_number = 0;
300
 
301
  foreach ($multiset_content as $set_content) {
302
- $multiset_vote_sum = $multiset_vote_sum + $set_content['average_rating'];
303
  $multiset_rows_number = $multiset_rows_number+1;
304
  }
305
 
306
  return round( $multiset_vote_sum / $multiset_rows_number, 1);
307
  }
308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  /**
310
  * Returns *ALL* multiset votes in YASR_LOG_MULTI_SET
311
  * used in stats page
144
  * )
145
  *
146
  * @param integer $set_id the set id
147
+ * @param array $set_fields an array with fields names and id
148
  * @param integer|bool $post_id the post_id
149
  *
150
  * @return bool | array
247
  $i = 0;
248
  //always returns field id and name
249
  foreach ($set_fields as $fields_ids_and_names) {
 
250
  $array_to_return[$i]['id'] = (int) $fields_ids_and_names['id'];
251
  $array_to_return[$i]['name'] = $fields_ids_and_names['name'];
252
  $array_to_return[$i]['average_rating'] = 0;
272
  }
273
 
274
  /**
275
+ * @param int $post_id
276
+ * @param int $set_id
277
  * @param bool $visitor_multiset
278
  *
279
  * Get the post_id and the set id, return the average (float)
280
  *
281
+ * @return float|int
282
  */
283
  public static function returnMultiSetAverage($post_id, $set_id, $visitor_multiset) {
284
  $post_id = (int)$post_id;
298
  $multiset_rows_number = 0;
299
 
300
  foreach ($multiset_content as $set_content) {
301
+ $multiset_vote_sum = $multiset_vote_sum + $set_content['average_rating'];
302
  $multiset_rows_number = $multiset_rows_number+1;
303
  }
304
 
305
  return round( $multiset_vote_sum / $multiset_rows_number, 1);
306
  }
307
 
308
+ /**
309
+ * This function loops an array of post_id that that has yasr_multiset_author_votes as meta key.
310
+ * Returns an ordered array by rating's average for each post id
311
+ *
312
+ * @author Dario Curvino <@dudo>
313
+ * @since 2.7.3
314
+ * @param $array_post_id
315
+ * @return array
316
+ */
317
+ public static function returnMultiAuthorAverageArray ($array_post_id, $set_id) {
318
+ $average_array = array();
319
+
320
+ $i = 0;
321
+ //loop the array
322
+ foreach ($array_post_id as $post_id) {
323
+ $average = self::returnMultiSetAverage($post_id->id, $set_id, false);
324
+ if ($average > 0) {
325
+ $average_array[$i]['post_id'] = $post_id->id;
326
+ $average_array[$i]['rating'] = $average;
327
+ }
328
+ $i++;
329
+ }
330
+
331
+ //order the array by average rating
332
+ array_multisort(array_column($average_array, 'rating'), SORT_DESC, SORT_NUMERIC, $average_array);
333
+
334
+ return $average_array;
335
+ }
336
+
337
  /**
338
  * Returns *ALL* multiset votes in YASR_LOG_MULTI_SET
339
  * used in stats page
includes/classes/YasrRankingData.php CHANGED
@@ -199,6 +199,65 @@ class YasrRankingData {
199
  return false;
200
  }
201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  /**
203
  * @author Dario Curvino <@dudo>
204
  * @since 2.7.2
@@ -211,7 +270,6 @@ class YasrRankingData {
211
  */
212
  public static function rankingMultiVV ($set_id, $ranking='most', $sql_atts=false) {
213
  global $wpdb;
214
-
215
  //if set_id is not set (e.g. in rest parameter setid is not set)
216
  if($set_id === NULL) {
217
  $set_id = YASR_FIRST_SETID;
199
  return false;
200
  }
201
 
202
+ /**
203
+ * @author Dario Curvino <@dudo>
204
+ * @since 2.7.2
205
+ *
206
+ * @param $set_id
207
+ * @param false $sql_atts
208
+ *
209
+ * @return bool|array
210
+ */
211
+ public static function rankingMulti($set_id, $sql_atts=false) {
212
+ global $wpdb;
213
+ if($set_id === NULL) {
214
+ $set_id = YASR_FIRST_SETID;
215
+ }
216
+
217
+ $set_id = (int)$set_id;
218
+
219
+ //hooks here to return a query
220
+ $query_result = apply_filters('yasr_rankings_multi_query', $sql_atts, $set_id);
221
+
222
+ //if hook has run
223
+ if ($query_result !== $sql_atts) {
224
+ //but don't return an array or array is empty, return false
225
+ if (!is_array($query_result) || empty($query_result)) {
226
+ return false;
227
+ }
228
+ //else return hooks result
229
+ return $query_result;
230
+ }
231
+
232
+ //if no hook is found in $query_result, return default ranking
233
+ if($query_result === $sql_atts) {
234
+ //Create an array of post_id that has meta key = yasr_multiset_author_votes
235
+ $array_post_id
236
+ = $wpdb->get_results(
237
+ "SELECT pm.post_id AS id
238
+ FROM $wpdb->postmeta AS pm,
239
+ $wpdb->posts AS p
240
+ WHERE pm.post_id = p.ID
241
+ AND p.post_status = 'publish'
242
+ AND pm.meta_key = 'yasr_multiset_author_votes'
243
+ ORDER BY pm.post_id"
244
+ );
245
+
246
+ if (!is_array($array_post_id) || empty($array_post_id)) {
247
+ return false;
248
+ }
249
+
250
+ //set fields name and ids
251
+ $average_array = YasrMultiSetData::returnMultiAuthorAverageArray($array_post_id, $set_id);
252
+
253
+ //Limit the array to N results
254
+ return array_slice($average_array, 0, 10);
255
+ }
256
+
257
+ //should never happens
258
+ return false;
259
+ }
260
+
261
  /**
262
  * @author Dario Curvino <@dudo>
263
  * @since 2.7.2
270
  */
271
  public static function rankingMultiVV ($set_id, $ranking='most', $sql_atts=false) {
272
  global $wpdb;
 
273
  //if set_id is not set (e.g. in rest parameter setid is not set)
274
  if($set_id === NULL) {
275
  $set_id = YASR_FIRST_SETID;
includes/css/yasr.css CHANGED
@@ -95,9 +95,6 @@
95
  font-size: 12px;
96
  }
97
 
98
- .yasr-highest-rated-text{
99
- display: block;
100
- }
101
  .yasr-most-rated-text{
102
  display: block;
103
  }
95
  font-size: 12px;
96
  }
97
 
 
 
 
98
  .yasr-most-rated-text{
99
  display: block;
100
  }
includes/js/src/ranking.js CHANGED
@@ -46,7 +46,7 @@ function YasrTextAfterStars (props) {
46
  </span>
47
  )
48
  }
49
- const text = props.text;
50
 
51
  return (
52
  <span className='yasr-highest-rated-text'>
@@ -133,7 +133,7 @@ function YasrRankingTableRow(props) {
133
  let leftClass = '';
134
  let rightClass = '';
135
 
136
- if (props.source === 'overall_rating') {
137
  leftClass = 'yasr-top-10-overall-left';
138
  rightClass = 'yasr-top-10-overall-right'
139
  }
@@ -167,12 +167,12 @@ function YasrRankingTableRowMap(props) {
167
  }
168
  {props.data.map(function (post, i) {
169
  let trClass = 'yasr-rankings-td-colored';
170
- if(props.source === 'overall_rating') {
171
  trClass = 'yasr-rankings-td-white';
172
  }
173
  if (i % 2 === 0) {
174
  trClass = 'yasr-rankings-td-white';
175
- if(props.source === 'overall_rating') {
176
  trClass = 'yasr-rankings-td-colored';
177
  }
178
  }
@@ -252,8 +252,12 @@ class YasrRanking extends React.Component {
252
  if (response === 'KO') {
253
  data = rankingData;
254
  } else {
255
- if(response.source === 'overall_rating') {
256
- data = response;
 
 
 
 
257
  }
258
  //if data is from visitor votes, create an array like this
259
  //data[most]
@@ -330,7 +334,7 @@ class YasrRanking extends React.Component {
330
  cleanedQuery = '&'+cleanedQuery;
331
  }
332
 
333
- if(dataSource === 'visitor_multi') {
334
  if(params.get('setid') !== null) {
335
  cleanedQuery += '&setid=' + params.get('setid');
336
  }
@@ -340,7 +344,7 @@ class YasrRanking extends React.Component {
340
  cleanedQuery = '';
341
  }
342
 
343
- if(dataSource === 'overall_rating') {
344
  urlYasrRankingApi = [yasrCommonData.restEndpoint + yasrRankingsApiPath + '?source=' + dataSource + cleanedQuery];
345
  }
346
  else {
@@ -381,7 +385,7 @@ class YasrRanking extends React.Component {
381
  const idLinkMost = 'link-most-rated-posts-'+tableId;
382
  const idLinkHighest = 'link-highest-rated-posts-'+tableId;
383
 
384
- if(source !== 'overall_rating') {
385
  let containerLink = <span>
386
  <span id={idLinkMost}>
387
  {__('Most Rated', 'yet-another-stars-rating')}
@@ -481,10 +485,10 @@ class YasrRanking extends React.Component {
481
  */
482
  rankingTableBody() {
483
  const {data, source, rankingParams} = this.state;
484
- if(source === 'overall_rating') {
485
  return (
486
  <YasrRankingTableRowMap
487
- data={data.data_overall}
488
  tableId={this.state.tableId}
489
  tBodyId={'overall_'+this.state.tableId}
490
  rankingParams={rankingParams}
46
  </span>
47
  )
48
  }
49
+ let text = props.text;
50
 
51
  return (
52
  <span className='yasr-highest-rated-text'>
133
  let leftClass = '';
134
  let rightClass = '';
135
 
136
+ if (props.source === 'author_ranking') {
137
  leftClass = 'yasr-top-10-overall-left';
138
  rightClass = 'yasr-top-10-overall-right'
139
  }
167
  }
168
  {props.data.map(function (post, i) {
169
  let trClass = 'yasr-rankings-td-colored';
170
+ if(props.source === 'author_ranking') {
171
  trClass = 'yasr-rankings-td-white';
172
  }
173
  if (i % 2 === 0) {
174
  trClass = 'yasr-rankings-td-white';
175
+ if(props.source === 'author_ranking') {
176
  trClass = 'yasr-rankings-td-colored';
177
  }
178
  }
252
  if (response === 'KO') {
253
  data = rankingData;
254
  } else {
255
+ if(response.source === 'overall_rating' || response.source === 'author_multi') {
256
+ if(response.source === 'overall_rating') {
257
+ data = response.data_overall;
258
+ } else {
259
+ data = response.data_mv;
260
+ }
261
  }
262
  //if data is from visitor votes, create an array like this
263
  //data[most]
334
  cleanedQuery = '&'+cleanedQuery;
335
  }
336
 
337
+ if(dataSource === 'visitor_multi' || dataSource === 'author_multi') {
338
  if(params.get('setid') !== null) {
339
  cleanedQuery += '&setid=' + params.get('setid');
340
  }
344
  cleanedQuery = '';
345
  }
346
 
347
+ if(dataSource === 'author_ranking' || dataSource === 'author_multi') {
348
  urlYasrRankingApi = [yasrCommonData.restEndpoint + yasrRankingsApiPath + '?source=' + dataSource + cleanedQuery];
349
  }
350
  else {
385
  const idLinkMost = 'link-most-rated-posts-'+tableId;
386
  const idLinkHighest = 'link-highest-rated-posts-'+tableId;
387
 
388
+ if(source !== 'author_ranking') {
389
  let containerLink = <span>
390
  <span id={idLinkMost}>
391
  {__('Most Rated', 'yet-another-stars-rating')}
485
  */
486
  rankingTableBody() {
487
  const {data, source, rankingParams} = this.state;
488
+ if(source === 'overall_rating' || source === 'author_multi') {
489
  return (
490
  <YasrRankingTableRowMap
491
+ data={data}
492
  tableId={this.state.tableId}
493
  tBodyId={'overall_'+this.state.tableId}
494
  rankingParams={rankingParams}
includes/js/yasr-front.js CHANGED
@@ -1 +1 @@
1
- !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";var a,n;r.r(e),r.d(e,"yasrSearchStarsDom",(function(){return j})),r.d(e,"yasrSetRaterValue",(function(){return L}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||s)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return d(a)};function y(t){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function g(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=h(t);if(e){var n=h(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return v(this,r)}}function v(t,e){return!e||"object"!==y(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return L(r,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function I(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function k(t){var e="after",r=b("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:r}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:r}))}function w(t){var e="",r="";return"overall_rating"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(I,{colClass:e,post:t.post}),React.createElement(k,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"overall_rating"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","overall_rating"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(o,React.Component);var e,r,a,n=p(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=o,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source?r=t:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"===r&&null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("overall_rating"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+s,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("overall_rating"!==t){var o=React.createElement("span",null,React.createElement("span",{id:a},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),":  ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,o="most-rated-posts-"+r,s="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r)return React.createElement(C,{data:e.data_overall,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",c=new URLSearchParams(a);return null!==c.get("view")&&(s=c.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(C,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,r),a&&g(e,a),o}();for(var x=wp.i18n.__,B=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],T=0;T<B.length;T++)j(B[T]);function j(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;L(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),o=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),c=parseInt(r.getAttribute("data-rater-starsize")),u=r.getAttribute("data-rater-nonce"),d=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,y="yasr-vv-average-container-"+l,g=document.getElementById(m),f=document.getElementById(y),p="yasr-vv-loader-"+l,v=!1;if("yes"===yasrCommonData.ajaxEnabled){var h=r.getAttribute("data-cpt");""===h&&(h="posts");var b="wp/v2/"+h+"/"+s+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+b).done((function(t){var e;(e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),P(c,a,s,e,i,l,u,d,g,f,p),!0!==n)&&(null!==g&&(g.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&(v=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(p).innerHTML=v))})).fail((function(t,e,r,m){console.info(x("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(c,a,s,o,i,l,u,d,g,f,p),!0!==n&&(document.getElementById("yasr-below-stars-hidden-"+l).style.display="")}))}else P(c,a,s,o,i,l,u,d,g,f,p)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);L(16,o,n,1,s,!1,(function(t,a){var o=n.getAttribute("data-rater-postid"),s=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:o,setid:s,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function L(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,r,a,n,o,s,i,l,c,u){e=parseFloat(e),a=O(a);L(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(u).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==c&&(c.innerHTML=t.average_rating),document.getElementById(u).innerHTML=t.rating_saved_text})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=document.getElementById(r);_(React.createElement(S,{source:a,tableId:r,params:n}),o)}}()}]);
1
+ !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";var a,n;r.r(e),r.d(e,"yasrSearchStarsDom",(function(){return j})),r.d(e,"yasrSetRaterValue",(function(){return L}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||s)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return d(a)};function g(t){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function y(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=h(t);if(e){var n=h(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return v(this,r)}}function v(t,e){return!e||"object"!==g(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return L(r,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function I(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function k(t){var e="after",r=b("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:r}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:r}))}function w(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(I,{colClass:e,post:t.post}),React.createElement(k,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(o,React.Component);var e,r,a,n=p(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=o,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+s,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:a},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),":  ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,o="most-rated-posts-"+r,s="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(C,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&y(e.prototype,r),a&&y(e,a),o}();for(var x=wp.i18n.__,B=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],T=0;T<B.length;T++)j(B[T]);function j(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;L(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),o=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),c=r.getAttribute("data-rater-nonce"),d=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,y=document.getElementById(m),f=document.getElementById(g),p="yasr-vv-loader-"+l,v=!1;if("yes"===yasrCommonData.ajaxEnabled){var h=r.getAttribute("data-cpt");""===h&&(h="posts");var b="wp/v2/"+h+"/"+s+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+b).done((function(t){var e;(e=!0===n||t.yasr_visitor_votes.stars_attributes.read_only,a=(a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),P(u,a,s,e,i,l,c,d,y,f,p),!0!==n)&&(null!==y&&(y.innerHTML=t.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom&&(v=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(p).innerHTML=v))})).fail((function(t,e,r,m){console.info(x("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,a,s,o,i,l,c,d,y,f,p),!0!==n&&(document.getElementById("yasr-below-stars-hidden-"+l).style.display="")}))}else P(u,a,s,o,i,l,c,d,y,f,p)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);L(16,o,n,1,s,!1,(function(t,a){var o=n.getAttribute("data-rater-postid"),s=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:o,setid:s,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function L(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,r,a,n,o,s,i,l,u,c){e=parseFloat(e),a=O(a);L(t,n,document.getElementById(n),1,a,e,(function(t,e){document.getElementById(c).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),document.getElementById(c).innerHTML=t.rating_saved_text})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=document.getElementById(r);_(React.createElement(S,{source:a,tableId:r,params:n}),o)}}()}]);
includes/rest/classes/YasrCustomEndpoint.php CHANGED
@@ -220,6 +220,16 @@ class YasrCustomEndpoint extends WP_REST_Controller {
220
  }
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
223
  if($source === 'visitor_multi') {
224
  //outside 'most', only 'highest' is allowed
225
  $ranking = ($request['show'] === 'highest') ? $request['show'] : 'most';
@@ -298,7 +308,10 @@ class YasrCustomEndpoint extends WP_REST_Controller {
298
  }
299
 
300
  if($key === 'source') {
301
- if($param === 'overall_rating' || $param === 'visitor_votes' || $param = 'visitor_multi' ) {
 
 
 
302
  return trim($param);
303
  }
304
  }
220
  }
221
  }
222
 
223
+ if($source === 'author_multi') {
224
+ $am_data = YasrRankingData::rankingMulti($request['setid'], $sql_params);
225
+ if($am_data === false){
226
+ $data_to_return = false;
227
+ }
228
+ else {
229
+ $data_to_return['data_mv'] = YasrRankings::rankingData($am_data);
230
+ }
231
+ }
232
+
233
  if($source === 'visitor_multi') {
234
  //outside 'most', only 'highest' is allowed
235
  $ranking = ($request['show'] === 'highest') ? $request['show'] : 'most';
308
  }
309
 
310
  if($key === 'source') {
311
+ if( $param === 'overall_rating'
312
+ || $param === 'visitor_votes'
313
+ || $param === 'author_multi'
314
+ || $param === 'visitor_multi' ) {
315
  return trim($param);
316
  }
317
  }
includes/shortcodes/classes/YasrRankings.php CHANGED
@@ -46,49 +46,12 @@ class YasrRankings extends YasrShortcode {
46
 
47
  $this->query_highest_rated_overall = YasrRankingData::rankingOverallGetResults($sql_atts);
48
 
49
- $this->returnTableOverall($this->urlencodeAtts($sql_atts));
50
  $this->shortcode_html .= '<!--End Yasr Top 10 highest Rated Shortcode-->';
51
 
52
  return $this->shortcode_html;
53
  }
54
 
55
- /**
56
- * Returns only initial and ending table tag
57
- * Table content is build with REACT
58
- *
59
- * @author Dario Curvino <@dudo>
60
- * @since 2.5.7
61
- *
62
- * @param $sql_params array|string - params that can be used in REST API
63
- *
64
- */
65
- protected function returnTableOverall($sql_params=false) {
66
- if ($this->query_highest_rated_overall) {
67
-
68
- $table_id = 'yasr_overall_ranking_'.str_shuffle(uniqid());
69
- $array_with_title['data_overall'] = self::rankingData($this->query_highest_rated_overall);
70
-
71
- $table_attributes = json_encode($sql_params);
72
-
73
- $this->shortcode_html .= "<table
74
- class='yasr-rankings yasr-stars-rankings'
75
- id=$table_id
76
- data-ranking-data='".json_encode($array_with_title)."'
77
- data-ranking-source='".json_encode('overall_rating')."'
78
- data-ranking-params='$table_attributes'
79
- data-ranking-size='".$this->starSize()."'
80
- >";
81
-
82
- $this->shortcode_html .= "</table>";
83
- }
84
- else {
85
- $this->shortcode_html .= '<div style="padding: 20px">';
86
- $this->shortcode_html .= __('No data found', 'yet-another-stars-rating');
87
- $this->shortcode_html .= '</div>';
88
- }
89
-
90
- }
91
-
92
  /**
93
  * Returns the shortcode for all rankings that get data from visitor votes
94
  *
@@ -113,12 +76,37 @@ class YasrRankings extends YasrShortcode {
113
 
114
  $this->query_result_highest_rated_visitor = YasrRankingData::rankingVVGetResults($sql_atts, 'highest');
115
 
116
- $this->returnTableVV($this->urlencodeAtts($sql_atts), $source);
117
  $this->shortcode_html .= '<!--End Yasr TMost Or Highest Rated Shortcode -->';
118
 
119
  return $this->shortcode_html;
120
  }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  /**
123
  * Return from shortcode yasr_visitor_multi_set_ranking
124
  *
@@ -150,19 +138,56 @@ class YasrRankings extends YasrShortcode {
150
  $sql_atts = array('setid' => $this->set_id);
151
  }
152
 
153
- $this->returnTableVV($this->urlencodeAtts($sql_atts), 'visitor_multi');
154
  $this->shortcode_html .= '<!--End Yasr Ranking by Visitor Multiset -->';
155
 
156
  return $this->shortcode_html;
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  /**
160
  * Create the queries for the rankings
161
  * Return the full html for the shortcode
162
  *
163
  * @param $urlencoded_params array|string - params that can be used in REST API
164
  */
165
- public function returnTableVV($urlencoded_params, $source) {
166
  if($this->query_result_most_rated_visitor && $this->query_result_highest_rated_visitor) {
167
 
168
  //This means that an hook has run
@@ -214,6 +239,7 @@ class YasrRankings extends YasrShortcode {
214
 
215
  $i=0;
216
  foreach ($query_result as $result) {
 
217
  $data_array[$i]['post_id'] = (int)$result->post_id;
218
  $data_array[$i]['rating'] = round($result->rating,1);
219
  if(isset($result->number_of_votes)) {
46
 
47
  $this->query_highest_rated_overall = YasrRankingData::rankingOverallGetResults($sql_atts);
48
 
49
+ $this->returnSingleTableRanking($this->urlencodeAtts($sql_atts));
50
  $this->shortcode_html .= '<!--End Yasr Top 10 highest Rated Shortcode-->';
51
 
52
  return $this->shortcode_html;
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  /**
56
  * Returns the shortcode for all rankings that get data from visitor votes
57
  *
76
 
77
  $this->query_result_highest_rated_visitor = YasrRankingData::rankingVVGetResults($sql_atts, 'highest');
78
 
79
+ $this->returnDoubleTableRanking($this->urlencodeAtts($sql_atts), $source);
80
  $this->shortcode_html .= '<!--End Yasr TMost Or Highest Rated Shortcode -->';
81
 
82
  return $this->shortcode_html;
83
  }
84
 
85
+ /**
86
+ * Return the shortcode yasr_multi_set_ranking
87
+ *
88
+ * @author Dario Curvino <@dudo>
89
+ * @since 2.7.2
90
+ *
91
+ * @param $atts
92
+ *
93
+ * @return string
94
+ */
95
+ public function returnMulti ($atts) {
96
+ $this->shortcode_html = '<!-- Yasr Ranking by Multiset -->';
97
+
98
+ //hook in this filter to use shortcode atts
99
+ //$this->shorcode_name is the default value
100
+ $sql_atts = apply_filters('yasr_multi_set_ranking_atts', $this->shortcode_name, $atts);
101
+
102
+ $this->query_highest_rated_overall = YasrRankingData::rankingMulti($this->set_id, $sql_atts);
103
+
104
+ $this->returnSingleTableRanking($this->urlencodeAtts($sql_atts), 'author_multi');
105
+ $this->shortcode_html .= '<!-- Yasr Ranking by Multiset -->';
106
+
107
+ return $this->shortcode_html;
108
+ }
109
+
110
  /**
111
  * Return from shortcode yasr_visitor_multi_set_ranking
112
  *
138
  $sql_atts = array('setid' => $this->set_id);
139
  }
140
 
141
+ $this->returnDoubleTableRanking($this->urlencodeAtts($sql_atts), 'visitor_multi');
142
  $this->shortcode_html .= '<!--End Yasr Ranking by Visitor Multiset -->';
143
 
144
  return $this->shortcode_html;
145
  }
146
 
147
+ /**
148
+ * Returns only initial and ending table tag
149
+ * Table content is build with REACT
150
+ *
151
+ * @author Dario Curvino <@dudo>
152
+ * @since 2.5.7
153
+ *
154
+ * @param $sql_params array|string - params that can be used in REST API
155
+ *
156
+ */
157
+ protected function returnSingleTableRanking($sql_params=false, $source='overall_rating') {
158
+ if ($this->query_highest_rated_overall) {
159
+
160
+ $table_id = 'yasr_overall_ranking_'.str_shuffle(uniqid());
161
+ $array_with_title = self::rankingData($this->query_highest_rated_overall);
162
+
163
+ $table_attributes = json_encode($sql_params);
164
+
165
+ $this->shortcode_html .= "<table
166
+ class='yasr-rankings yasr-stars-rankings'
167
+ id=$table_id
168
+ data-ranking-data='".json_encode($array_with_title)."'
169
+ data-ranking-source='".json_encode($source)."'
170
+ data-ranking-params='$table_attributes'
171
+ data-ranking-size='".$this->starSize()."'
172
+ >";
173
+
174
+ $this->shortcode_html .= "</table>";
175
+ }
176
+ else {
177
+ $this->shortcode_html .= '<div style="padding: 20px">';
178
+ $this->shortcode_html .= __('No data found', 'yet-another-stars-rating');
179
+ $this->shortcode_html .= '</div>';
180
+ }
181
+
182
+ }
183
+
184
  /**
185
  * Create the queries for the rankings
186
  * Return the full html for the shortcode
187
  *
188
  * @param $urlencoded_params array|string - params that can be used in REST API
189
  */
190
+ public function returnDoubleTableRanking($urlencoded_params, $source) {
191
  if($this->query_result_most_rated_visitor && $this->query_result_highest_rated_visitor) {
192
 
193
  //This means that an hook has run
239
 
240
  $i=0;
241
  foreach ($query_result as $result) {
242
+ $result = (object) $result;
243
  $data_array[$i]['post_id'] = (int)$result->post_id;
244
  $data_array[$i]['rating'] = round($result->rating,1);
245
  if(isset($result->number_of_votes)) {
includes/shortcodes/classes/YasrShortcode.php CHANGED
@@ -79,7 +79,7 @@ abstract class YasrShortcode
79
  protected function starSize()
80
  {
81
  $size = null;
82
- if ( $this->shortcode_name === 'yasr_ov_ranking' || $this->shortcode_name === 'yasr_most_or_highest_rated_posts' || $this->shortcode_name === 'yasr_pro_ur_ranking' || $this->shortcode_name === 'yasr_visitor_multi_set_ranking' ) {
83
  //default size for all rankings
84
  $size = 'medium';
85
  }
79
  protected function starSize()
80
  {
81
  $size = null;
82
+ if ( $this->shortcode_name === 'yasr_ov_ranking' || $this->shortcode_name === 'yasr_most_or_highest_rated_posts' || $this->shortcode_name === 'yasr_pro_ur_ranking' || $this->shortcode_name === 'yasr_multi_set_ranking' || $this->shortcode_name === 'yasr_visitor_multi_set_ranking' ) {
83
  //default size for all rankings
84
  $size = 'medium';
85
  }
includes/shortcodes/yasr-shortcode-functions.php CHANGED
@@ -211,6 +211,14 @@ function yasr_ranking_users_callback ($atts, $content, $shortcode_tag) {
211
  return $ranking_users_obj->returnTopUsers($atts);
212
  } //End users rankings
213
 
 
 
 
 
 
 
 
 
214
  add_shortcode ('yasr_visitor_multi_set_ranking', 'yasr_visitor_multi_set_ranking_callback');
215
 
216
  function yasr_visitor_multi_set_ranking_callback($atts, $content, $shortcode_tag) {
211
  return $ranking_users_obj->returnTopUsers($atts);
212
  } //End users rankings
213
 
214
+
215
+ add_shortcode ('yasr_multi_set_ranking', 'yasr_multi_set_ranking_callback');
216
+
217
+ function yasr_multi_set_ranking_callback($atts, $content, $shortcode_tag) {
218
+ $yasr_ranking = new YasrRankings($atts, $shortcode_tag);
219
+ return $yasr_ranking->returnMulti($atts);
220
+ } //End function
221
+
222
  add_shortcode ('yasr_visitor_multi_set_ranking', 'yasr_visitor_multi_set_ranking_callback');
223
 
224
  function yasr_visitor_multi_set_ranking_callback($atts, $content, $shortcode_tag) {
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.7
7
  Requires PHP: 5.4
8
- Stable tag: 2.7.2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
@@ -17,28 +17,28 @@ as it promotes familiarity and loyalty with your brand, and enhances visibility
17
  Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and testimonials to your
18
  website posts, pages and CPT, without affecting its speed.
19
 
20
- = How To use =
21
 
22
- = Reviewer Vote =
23
  With the classic editor, when you create or update a page or a post, a box (metabox) will be available in the upper right corner where you'll
24
  be able to insert the overall rating.
25
  With the new Guteneberg editor, just click on the "+" icon to add a block and search for Yasr Overall Rating.
26
  You can either place the overall rating automatically at the beginning or the end of a post (look in "Settings"
27
  -> "Yet Another Stars Rating: Settings"), or wherever you want in the page using the shortcode [yasr_overall_rating] (easily added through the visual editor).
28
 
29
- = Visitor Votes =
30
  You can give your users the ability to vote, pasting the shortcode [yasr_visitor_votes] where you want the stars to appear.
31
  If you're using the new Gutenberg editor, just click on the "+" icon to add a block and search for Yasr Visitor Votes
32
  Again, this can be placed automatically at the beginning or the end of each post; the option is in "Settings" -> "Yet Another Stars Rating: Settings".
33
 
34
- = Multi Set =
35
  Multisets give the opportunity to score different aspects for each review: for example, if you're reviewing a videogame, you can create the aspects "Graphics", "Gameplay", "Story", etc.
36
 
37
- = Migration tools =
38
  You can easily migrate from *WP-PostRatings*, *kk Star Ratings*, *Rate My Post* and *Multi Rating*
39
  A tab will appear in the settings if one of these plugin is detected.
40
 
41
- = Supported itemtypes =
42
  YASR supports the following schema.org itemtypes:
43
 
44
  BlogPosting ✝,
@@ -100,11 +100,22 @@ More info [here](https://wordpress.org/plugins/yet-another-stars-rating/faq/)
100
  * recipeCuisine
101
  * recipeIngredient
102
 
103
- = Video Tutorial =
104
- In this video I'll show you the "Auto Insert" feature and manual placement of yasr_visitor_votes and yasr_overall_rating shortcodes
 
105
  [youtube https://www.youtube.com/watch?v=M47xsJMQJ1E]
106
 
107
- = Related Link =
 
 
 
 
 
 
 
 
 
 
108
  * Documentation at [Yasr Official Site](https://yetanotherstarsrating.com/docs/)
109
  * [Demo page for Overall Rating and Vistor Rating](https://yetanotherstarsrating.com/yasr-basics-shortcode/)
110
  * [Demo page for Multi Sets](https://yetanotherstarsrating.com/yasr-multi-sets/)
@@ -181,6 +192,10 @@ If doesn't, you should work on your seo reputation.
181
 
182
  The full changelog can be found in the plugin's directory. Recent entries:
183
 
 
 
 
 
184
  = 2.7.2 =
185
  * NEW FEATURE: new shortcode: yasr_visitor_multi_set_ranking : this will show rankings from yasr_visitor_multiset
186
  * TWEAKED: minor fixes
@@ -221,70 +236,5 @@ The full changelog can be found in the plugin's directory. Recent entries:
221
  * TWEAKED: code cleanup
222
 
223
 
224
- = 2.6.2 =
225
- * TWEAK: yasr_top_ten_highest_rated is now depcrecated. yasr_ov_ranking will take its place
226
- * TWEAK: yasr_top_5_reviewers is now depcrecated. yasr_top_reviewers will take its place
227
- * TWEAK: yasr_top_ten_active_users is now depcrecated. yasr_most_active_users will take its place
228
- * FIX: yasr_visitor_votes didn't work on CPT if AJAX is enabled and CPT is registred without _base parameter
229
- * FIX: Couldn't add new element in MultiSet if only one is used
230
- * Updated freemius to version 2.4.2
231
-
232
-
233
- = 2.6.1 =
234
- * FIX: Visitor rating broken if custom text is enabled. (thanks to @raulpopi)
235
- * FIX: In some themes (Twenty Twenty, Twenty One and most likely many others) if a post contains the <!--more--> tag, and
236
- stars next to the title is active, the excpert layout get broken
237
-
238
- = 2.6.0 =
239
- * FIX: if load results with ajax is enabled, and for some reason an api call fails, span below the stars didn't shows up
240
- * TWEAK: containerAfterStars method is now public
241
-
242
- = 2.5.9 =
243
- * TWEAK: when a rating is saved, ajax answer returns an array instead of the html. This will no overwrite the actual text but just update it.
244
- * FIX: "0" Showing up at the end of the titles in some circumstances.
245
- * Minor changes
246
-
247
- = 2.5.8 =
248
- * FIX: wrong css style for rankings yasr_top_5_reviewers and yasr_top_ten_active_users
249
-
250
- = 2.5.7 =
251
- * TWEAK: Rankings have been rewritten: now are build in REACT, this will allow much more flexibility
252
-
253
- = 2.5.6 =
254
- * FIX: register_rest_route called incorrectly in Gutenberg
255
- * FIX: random js error into dashboard (thanks to @lwangaman)
256
- * TWEAK: On stars hover, cursor is now displayed an an hand
257
- * FIX: minor changes to support older versions
258
-
259
- = 2.5.5 =
260
- * FIX: rich snippet's attribute name returns the post_id instead of the title in some circumstances
261
-
262
- = 2.5.4 =
263
- * FIX: yasr_visitor_multiset data didn't save correctly if more than one were used in the same page.
264
-
265
-
266
- = 2.5.3 =
267
- * FIX: in Yet Another Stars Rating: Stats -> Overall Rating only posts with rating > 0 are shown
268
-
269
- = 2.5.2 =
270
- * NEW FEATURE: is now possible delete overall rating data in Yet Another Stars Rating -> Stats -> Overall Rating
271
- * FIXED: Schema title come with rating string if "Enable stars next to the title?" is enabled
272
- * TWEAKED: all rankings functions has been rewritten to work with REST API. Documentation will come soon.
273
- * TWEAKED: a lot of minor changes.
274
-
275
- = 2.5.1 =
276
- * TWEAKED: added new hooks: yasr_vv_shortcode, yasr_vv_ro_shortcode and yasr_overall_shortcode. These hooks can
277
- be used to customize the shortcodes.
278
-
279
-
280
- = 2.5.0 =
281
- * TWEAKED: minor changes. Nothing to be excited about
282
-
283
- = 2.4.9 =
284
- * FIXED: Removed unnecessary closing div for yasr_visitor_votes shortcode
285
-
286
- = 2.4.8 =
287
- * Removed YasrSettings file from svn repo
288
-
289
  = Additional Info =
290
  See credits.txt file
5
  Contributors: Dudo
6
  Tested up to: 5.7
7
  Requires PHP: 5.4
8
+ Stable tag: 2.7.3
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
17
  Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and testimonials to your
18
  website posts, pages and CPT, without affecting its speed.
19
 
20
+ == How To use ==
21
 
22
+ == Reviewer Vote ==
23
  With the classic editor, when you create or update a page or a post, a box (metabox) will be available in the upper right corner where you'll
24
  be able to insert the overall rating.
25
  With the new Guteneberg editor, just click on the "+" icon to add a block and search for Yasr Overall Rating.
26
  You can either place the overall rating automatically at the beginning or the end of a post (look in "Settings"
27
  -> "Yet Another Stars Rating: Settings"), or wherever you want in the page using the shortcode [yasr_overall_rating] (easily added through the visual editor).
28
 
29
+ == Visitor Votes ==
30
  You can give your users the ability to vote, pasting the shortcode [yasr_visitor_votes] where you want the stars to appear.
31
  If you're using the new Gutenberg editor, just click on the "+" icon to add a block and search for Yasr Visitor Votes
32
  Again, this can be placed automatically at the beginning or the end of each post; the option is in "Settings" -> "Yet Another Stars Rating: Settings".
33
 
34
+ == Multi Set ==
35
  Multisets give the opportunity to score different aspects for each review: for example, if you're reviewing a videogame, you can create the aspects "Graphics", "Gameplay", "Story", etc.
36
 
37
+ == Migration tools ==
38
  You can easily migrate from *WP-PostRatings*, *kk Star Ratings*, *Rate My Post* and *Multi Rating*
39
  A tab will appear in the settings if one of these plugin is detected.
40
 
41
+ == Supported itemtypes ==
42
  YASR supports the following schema.org itemtypes:
43
 
44
  BlogPosting ✝,
100
  * recipeCuisine
101
  * recipeIngredient
102
 
103
+ == Video Tutorial ==
104
+
105
+ = Old video, but still valid. =
106
  [youtube https://www.youtube.com/watch?v=M47xsJMQJ1E]
107
 
108
+ = New videos, talked in Italian but easily to understand (eng subs will comes) =
109
+ [Tutorial's playlist](https://www.youtube.com/playlist?list=PLFErQFOLUVMcx8Qb9--KKme3bQ_KGri71)
110
+
111
+
112
+ == Developers ==
113
+ While YASR - Yet Another Stars Rating does not require any coding, it is developer friendly!
114
+ It is the first (and for now only) rating plugin that uses REST API.
115
+ [Here](https://documenter.getpostman.com/view/12873985/TzJycbVz) you can find the documentation.
116
+ Further, it comes with a lot of hooks, you can find more info [here](https://yetanotherstarsrating.com/docs/developers/) .
117
+
118
+ == Related Link ==
119
  * Documentation at [Yasr Official Site](https://yetanotherstarsrating.com/docs/)
120
  * [Demo page for Overall Rating and Vistor Rating](https://yetanotherstarsrating.com/yasr-basics-shortcode/)
121
  * [Demo page for Multi Sets](https://yetanotherstarsrating.com/yasr-multi-sets/)
192
 
193
  The full changelog can be found in the plugin's directory. Recent entries:
194
 
195
+ = 2.7.3 =
196
+ * NEW FEATURE: new shortcode: yasr_multi_set_ranking : this will show rankings from yasr_multiset
197
+ * TWEAKED: code cleanup.
198
+
199
  = 2.7.2 =
200
  * NEW FEATURE: new shortcode: yasr_visitor_multi_set_ranking : this will show rankings from yasr_visitor_multiset
201
  * TWEAKED: minor fixes
236
  * TWEAKED: code cleanup
237
 
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  = Additional Info =
240
  See credits.txt file
yet-another-stars-rating.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
- * Version: 2.7.2
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
@@ -76,7 +76,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
- define( 'YASR_VERSION_NUM', '2.7.2' );
80
  //Plugin absolute path
81
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
82
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
@@ -164,12 +164,12 @@ if ( !function_exists( 'yasr_fs' ) ) {
164
 
165
  if ( yasr_fs()->is_free_plan() ) {
166
  // create link
167
- if ( $file == $plugin ) {
168
  $links[] = '<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=above_description&utm_campaign=yasr_plugin_list">' . __( 'Buy Yasr Pro', 'yet-another-stars-rating' ) . '</a>';
169
  }
170
  } else {
171
  // create link
172
- if ( $file == $plugin ) {
173
  $links[] = __( 'Thank you for using Yasr Pro', 'yet-another-stars-rating' );
174
  }
175
  }
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
+ * Version: 2.7.3
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
+ define( 'YASR_VERSION_NUM', '2.7.3' );
80
  //Plugin absolute path
81
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
82
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
164
 
165
  if ( yasr_fs()->is_free_plan() ) {
166
  // create link
167
+ if ( $file === $plugin ) {
168
  $links[] = '<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=above_description&utm_campaign=yasr_plugin_list">' . __( 'Buy Yasr Pro', 'yet-another-stars-rating' ) . '</a>';
169
  }
170
  } else {
171
  // create link
172
+ if ( $file === $plugin ) {
173
  $links[] = __( 'Thank you for using Yasr Pro', 'yet-another-stars-rating' );
174
  }
175
  }