Yasr – Yet Another Stars Rating - Version 3.0.5

Version Description

  • FIX: set_id parameter didn't work in shortcodes yasr_multi_set_ranking and yasr_visitor_multi_set_ranking
  • FIX: rankings didn't show up when post title contains quotation marks ( " )
  • TWEAKED: In the setting page, section "Custom texts" is now renamed in "Customize strings", and it works on two columns (more strings will come soon)
  • TWEAKED: under the hood changes.
Download this release

Release Info

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

Code changes from version 3.0.4 to 3.0.5

Files changed (41) hide show
  1. admin/classes/YasrOnInstall.php +1 -0
  2. admin/classes/Yasr_WP_List_Table.php +5 -1
  3. admin/editor/YasrEditorHooks.php +2 -1
  4. admin/editor/yasr-metabox-multiple-rating.php +6 -4
  5. admin/js/src/yasr-pricing-page.js +1 -1
  6. admin/js/src/yasr-settings-page.js +4 -4
  7. admin/js/yasr-pricing-page.js +1 -1
  8. admin/js/yasr-settings.js +1 -1
  9. admin/settings/classes/YasrSettings.php +122 -130
  10. admin/settings/multiset/yasr-settings-functions-multiset.php +2 -0
  11. admin/settings/yasr-settings-functions-misc.php +31 -8
  12. admin/settings/yasr-settings-page.php +1 -0
  13. admin/settings/yasr-stats-page.php +1 -0
  14. admin/yasr-admin-functions.php +3 -0
  15. includes/classes/YasrDatabaseRatings.php +1 -0
  16. includes/classes/YasrDefineOptions.php +161 -0
  17. includes/classes/YasrIncludesFilters.php +10 -58
  18. includes/classes/YasrLogDashboardWidget.php +3 -4
  19. includes/classes/YasrScriptsLoader.php +153 -5
  20. includes/classes/YasrSettingsValues.php +1 -0
  21. includes/js/catch-inifite-scroll.js +1 -1
  22. includes/js/shortcodes/overall-multiset.js +1 -1
  23. includes/js/shortcodes/rankings.js +1 -1
  24. includes/js/shortcodes/visitorVotes.js +1 -1
  25. includes/js/shortcodes/yasr-log-users-frontend.js +1 -1
  26. includes/js/src/catch-inifite-scroll.js +1 -1
  27. includes/js/src/global_functions/rater-js-src.js +1 -1
  28. includes/js/src/shortcodes/overall-multiset.js +8 -3
  29. includes/js/src/shortcodes/ranking.js +5 -5
  30. includes/js/src/shortcodes/visitorVotes.js +14 -10
  31. includes/js/src/shortcodes/yasr-log-users-frontend.js +2 -2
  32. includes/js/yasr-globals.js +1 -1
  33. includes/shortcodes/classes/YasrOverallRating.php +1 -2
  34. includes/shortcodes/classes/YasrRankings.php +9 -4
  35. includes/shortcodes/classes/YasrShortcodesAjax.php +34 -7
  36. includes/shortcodes/classes/YasrVisitorVotes.php +0 -1
  37. includes/shortcodes/yasr-shortcode-functions.php +9 -26
  38. includes/yasr-includes-functions.php +0 -117
  39. includes/yasr-includes-init.php +25 -95
  40. readme.txt +10 -2
  41. yet-another-stars-rating.php +2 -2
admin/classes/YasrOnInstall.php CHANGED
@@ -22,6 +22,7 @@ if (!defined('ABSPATH')) {
22
  } // Exit if accessed directly
23
 
24
  if (!current_user_can('manage_options')) {
 
25
  wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
26
  }
27
 
22
  } // Exit if accessed directly
23
 
24
  if (!current_user_can('manage_options')) {
25
+ /** @noinspection ForgottenDebugOutputInspection */
26
  wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
27
  }
28
 
admin/classes/Yasr_WP_List_Table.php CHANGED
@@ -1,4 +1,8 @@
1
- <?php
 
 
 
 
2
 
3
  if (!defined('ABSPATH')) {
4
  exit('You\'re not allowed to see this page');
1
+ <?php /** @noinspection ALL */
2
+ /** @noinspection CallableParameterUseCaseInTypeContextInspection */
3
+ /** @noinspection CallableParameterUseCaseInTypeContextInspection */
4
+ /** @noinspection VariableFunctionsUsageInspection */
5
+ /** @noinspection VariableFunctionsUsageInspection */
6
 
7
  if (!defined('ABSPATH')) {
8
  exit('You\'re not allowed to see this page');
admin/editor/YasrEditorHooks.php CHANGED
@@ -359,7 +359,7 @@ class YasrEditorHooks {
359
 
360
  if(is_array($constants_array) && !empty($constants_array)) {
361
  wp_localize_script(
362
- 'yasradmin',
363
  'yasrConstantGutenberg',
364
  $constants_array
365
  );
@@ -797,6 +797,7 @@ class YasrEditorHooks {
797
  */
798
  public function metaboxOutputMultisets() {
799
  if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
 
800
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
801
  }
802
 
359
 
360
  if(is_array($constants_array) && !empty($constants_array)) {
361
  wp_localize_script(
362
+ 'yasradmin', //Where to attacch the object
363
  'yasrConstantGutenberg',
364
  $constants_array
365
  );
797
  */
798
  public function metaboxOutputMultisets() {
799
  if (!current_user_can(YASR_USER_CAPABILITY_EDIT_POST)) {
800
+ /** @noinspection ForgottenDebugOutputInspection */
801
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
802
  }
803
 
admin/editor/yasr-metabox-multiple-rating.php CHANGED
@@ -23,7 +23,7 @@ if (!defined( 'ABSPATH')) {
23
  } // Exit if accessed directly
24
 
25
  $multi_set = YasrMultiSetData::returnMultiSetNames();
26
- $post_id = get_the_ID();
27
  wp_nonce_field('yasr_nonce_save_multi_values_action', 'yasr_nonce_save_multi_values');
28
  wp_nonce_field('yasr_nonce_multiset_review_enabled_action','yasr_nonce_multiset_review_enabled');
29
 
@@ -67,10 +67,10 @@ if ($n_multi_set > 1) {
67
  data-setid="<?php echo esc_attr($set_id) ?>"
68
  data-postid="<?php echo esc_attr($post_id) ?>">
69
 
 
 
70
  <input type="hidden" name="yasr_multiset_author_votes" id="yasr-multiset-author-votes" value="">
71
  <input type="hidden" name="yasr_multiset_id" id="yasr-multiset-id" value="<?php echo esc_attr($set_id) ?>">
72
- <input type="hidden" name="yasr_pro_review_setid" id="yasr-pro-review-setid"
73
- value="<?php esc_attr_e($post->yasr_pro_review_setid) ?>">
74
 
75
  <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin">
76
  </table>
@@ -95,7 +95,6 @@ if ($n_multi_set > 1) {
95
 
96
  <div id="yasr-visitor-multiset-container">
97
  <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin-visitor">
98
-
99
  </table>
100
 
101
  <div class="yasr-multi-set-admin-explain">
@@ -128,6 +127,9 @@ if ($n_multi_set > 1) {
128
 
129
  <div class="yasr-settings-row">
130
  <div class="yasr-settings-col-30">
 
 
 
131
  <div class="yasr-metabox-editor-title">
132
  <?php
133
  esc_html_e('Insert this Multi Set in the comment form?', 'yet-another-stars-rating');
23
  } // Exit if accessed directly
24
 
25
  $multi_set = YasrMultiSetData::returnMultiSetNames();
26
+ $post_id = $post->ID;
27
  wp_nonce_field('yasr_nonce_save_multi_values_action', 'yasr_nonce_save_multi_values');
28
  wp_nonce_field('yasr_nonce_multiset_review_enabled_action','yasr_nonce_multiset_review_enabled');
29
 
67
  data-setid="<?php echo esc_attr($set_id) ?>"
68
  data-postid="<?php echo esc_attr($post_id) ?>">
69
 
70
+ <?php do_action('yasr_add_content_multiset_tab_top', $post_id, $set_id); ?>
71
+
72
  <input type="hidden" name="yasr_multiset_author_votes" id="yasr-multiset-author-votes" value="">
73
  <input type="hidden" name="yasr_multiset_id" id="yasr-multiset-id" value="<?php echo esc_attr($set_id) ?>">
 
 
74
 
75
  <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin">
76
  </table>
95
 
96
  <div id="yasr-visitor-multiset-container">
97
  <table class="yasr_table_multi_set_admin" id="yasr-table-multi-set-admin-visitor">
 
98
  </table>
99
 
100
  <div class="yasr-multi-set-admin-explain">
127
 
128
  <div class="yasr-settings-row">
129
  <div class="yasr-settings-col-30">
130
+
131
+ <?php do_action('yasr_add_content_multiset_tab_pro', $post_id, $set_id); ?>
132
+
133
  <div class="yasr-metabox-editor-title">
134
  <?php
135
  esc_html_e('Insert this Multi Set in the comment form?', 'yet-another-stars-rating');
admin/js/src/yasr-pricing-page.js CHANGED
@@ -295,7 +295,7 @@ function YasrPricingRedirect (cycle, licenses, currency, pricingId) {
295
  }
296
  paramsBody = paramsBody.join("&");
297
 
298
- let linkRedirect = yasrCommonData.adminUrl+'admin.php?'+paramsBody;
299
 
300
  window.open(linkRedirect,"_self");
301
  }
295
  }
296
  paramsBody = paramsBody.join("&");
297
 
298
+ let linkRedirect = yasrWindowVar.adminUrl+'admin.php?'+paramsBody;
299
 
300
  window.open(linkRedirect,"_self");
301
  }
admin/js/src/yasr-settings-page.js CHANGED
@@ -147,7 +147,7 @@ if (activeTab === 'migration_tools') {
147
 
148
  //show loader on click
149
  document.getElementById('yasr-import-ratemypost-answer').innerHTML =
150
- '<img src="' + yasrCommonData.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
151
 
152
  var nonce = document.getElementById('yasr-import-rmp-nonce').value;
153
 
@@ -167,7 +167,7 @@ if (activeTab === 'migration_tools') {
167
 
168
  //show loader on click
169
  document.getElementById('yasr-import-wppr-answer').innerHTML =
170
- '<img src="' + yasrCommonData.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
171
 
172
  var nonce = document.getElementById('yasr-import-wppr-nonce').value;
173
 
@@ -187,7 +187,7 @@ if (activeTab === 'migration_tools') {
187
 
188
  //show loader on click
189
  document.getElementById('yasr-import-kksr-answer').innerHTML =
190
- '<img src="' + yasrCommonData.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
191
 
192
  var nonce = document.getElementById('yasr-import-kksr-nonce').value;
193
 
@@ -208,7 +208,7 @@ if (activeTab === 'migration_tools') {
208
 
209
  //show loader on click
210
  document.getElementById('yasr-import-mr-answer').innerHTML =
211
- '<img src="' + yasrCommonData.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
212
 
213
  var nonce = document.getElementById('yasr-import-mr-nonce').value;
214
 
147
 
148
  //show loader on click
149
  document.getElementById('yasr-import-ratemypost-answer').innerHTML =
150
+ '<img src="' + yasrWindowVar.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
151
 
152
  var nonce = document.getElementById('yasr-import-rmp-nonce').value;
153
 
167
 
168
  //show loader on click
169
  document.getElementById('yasr-import-wppr-answer').innerHTML =
170
+ '<img src="' + yasrWindowVar.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
171
 
172
  var nonce = document.getElementById('yasr-import-wppr-nonce').value;
173
 
187
 
188
  //show loader on click
189
  document.getElementById('yasr-import-kksr-answer').innerHTML =
190
+ '<img src="' + yasrWindowVar.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
191
 
192
  var nonce = document.getElementById('yasr-import-kksr-nonce').value;
193
 
208
 
209
  //show loader on click
210
  document.getElementById('yasr-import-mr-answer').innerHTML =
211
+ '<img src="' + yasrWindowVar.loaderUrl + '" alt="yasr-loader" width="16" height="16">';
212
 
213
  var nonce = document.getElementById('yasr-import-mr-nonce').value;
214
 
admin/js/yasr-pricing-page.js CHANGED
@@ -1 +1 @@
1
- (()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var c=0;c<t.length;c++){var a=t[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function a(t,c){if(c&&("object"===e(c)||"function"==typeof c))return c;if(void 0!==c)throw new TypeError("Derived constructors may only return object or undefined");return r(t)}function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function l(e){var t="$";return"eur"===e.name&&(t="€"),React.createElement("small",null,t," ")}function i(e){var t="/year";return"monthly"===e.name&&(t="/month"),"lifetime"===e.name&&(t=""),React.createElement("small",null,t)}function s(e){var t=" 1 website";return"plus"===e.license&&(t=" 5 websites"),"enterprise"===e.license&&(t=" 30 websites"),React.createElement("ul",{className:"yasr-pricing-table-features"},"annual"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"1 year")," of supports and updates ",React.createElement("br",null),"for",React.createElement("strong",null,t)),"monthly"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"1 month")," of supports and updates ",React.createElement("br",null),"for",React.createElement("strong",null,t)),"lifetime"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"Lifetime")," updates and support",React.createElement("br",null),"for",React.createElement("strong",null,t)),React.createElement("li",{className:"yasr-pricing-table-feature"},"User reviews"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Custom rankings"),React.createElement("li",{className:"yasr-pricing-table-feature"},"20 + ready to use themes"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Upload your own theme"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Add fake ratings"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Direct email support"),"lifetime"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},"We setup the plugin for free ",React.createElement("br",null),"(only lifetime plans)"))}function u(e){var t="",c=1,a="";return"single"===e.license?(a="eur"===e.currency?5399:1933,t="monthly"===e.cycle?"eur"===e.currency?"4.49":"4.99":"lifetime"===e.cycle?"eur"===e.currency?"129.99":"149.99":"eur"===e.currency?"41.99":"47.88"):"plus"===e.license?(c=5,a="eur"===e.currency?5400:1935,t="monthly"===e.cycle?"eur"===e.currency?"8.99":"9.99":"lifetime"===e.cycle?"eur"===e.currency?"249.99":"289.99":"eur"===e.currency?"83.88":"95.88"):"enterprise"===e.license&&(c=30,a="eur"===e.currency?5550:5549,t="monthly"===e.cycle?"eur"===e.currency?"12.99":"14.99":"lifetime"===e.cycle?"eur"===e.currency?"359.99":"439.99":"eur"===e.currency?"119.88":"143.88"),React.createElement("div",{className:"yasr-pring-table-price"},React.createElement(l,{name:e.currency}),React.createElement("span",null,t),React.createElement(i,{name:e.cycle}),React.createElement(o,{cycle:e.cycle,currency:e.currency,license:e.license}),React.createElement("p",{className:"PT-CTA"},React.createElement("a",{href:"#",className:"yasr-buy-button",onClick:function(t){!function(e,t,c,a){var r={plugin_id:256,billing_cycle:e,pricing_id:a,licenses:t,id:"yasr_checkout",page:"yasr_settings_page-pricing",checkout:"true",plan_id:"2778",plan_name:"yasrpro",disable_licenses_selector:!0,hide_billing_cycles:!0,currency:c},n=[];for(var l in r){var i=encodeURIComponent(l),s=encodeURIComponent(r[l]);n.push(i+"="+s)}n=n.join("&");var u=yasrCommonData.adminUrl+"admin.php?"+n;window.open(u,"_self")}(e.cycle,c,e.currency,a),t.preventDefault()}},"Buy YASR ")))}function o(e){if("annual"===e.cycle){var t;return t="plus"===e.license?"eur"===e.currency?"6.99":"7.99":"enterprise"===e.license?"eur"===e.currency?"9.99":"11.99":"eur"===e.currency?"3.49":"3.99",React.createElement("p",{className:"yasr-pricing-table-price-desc"},React.createElement(l,{name:e.currency}),t," /month")}return React.createElement(React.Fragment,null)}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(p,React.Component);var l,i,o,y,m=(o=p,y=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=n(o);if(y){var c=n(this).constructor;e=Reflect.construct(t,arguments,c)}else e=t.apply(this,arguments);return a(this,e)});function p(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,p),(t=m.call(this,e)).state={currencyName:"usd",cycle:"annual"},t.updateCurrency=t.updateCurrency.bind(r(t)),t.updateCycle=t.updateCycle.bind(r(t)),t}return l=p,(i=[{key:"updateCurrency",value:function(e){var t=e.target;!0===("checkbox"===t.type?t.checked:t.value)?this.setState({currencyName:"eur"}):this.setState({currencyName:"usd"})}},{key:"updateCycle",value:function(e){this.setState({cycle:e.target.value})}},{key:"render",value:function(){return React.createElement(React.Fragment,null,React.createElement("div",{id:"yasr-radio-billing-cycle"},React.createElement("input",{type:"radio",id:"yasr-billing-cycle-monthly",name:"billing-cycle",value:"monthly",onChange:this.updateCycle,checked:"monthly"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-monthly"},"Monthly"),React.createElement("input",{type:"radio",id:"yasr-billing-cycle-annual",name:"billing-cycle",value:"annual",onChange:this.updateCycle,checked:"annual"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-annual"},"Annual"),React.createElement("input",{type:"radio",id:"yasr-billing-cycle-lifetime",name:"billing-cycle",value:"lifetime",onChange:this.updateCycle,checked:"lifetime"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-lifetime"},"Lifetime")),React.createElement("div",{id:"yasr-pricing-table"},React.createElement("div",{className:"yasr-pricing-table-item"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Plus"),React.createElement("p",{className:"yasr-pricing-table-subtitle"},"5 websites")),React.createElement(s,{cycle:this.state.cycle,license:"plus"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(u,{cycle:this.state.cycle,currency:this.state.currencyName,license:"plus"}))),React.createElement("div",{className:"yasr-pricing-table-item is-highlighted"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Single"),React.createElement("p",{className:"yasr-pricing-table-subtitle"}," 1 website")),React.createElement(s,{cycle:this.state.cycle,license:"single"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(u,{cycle:this.state.cycle,currency:this.state.currencyName,license:"single"}))),React.createElement("div",{className:"yasr-pricing-table-item"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Enterprise"),React.createElement("p",{className:"yasr-pricing-table-subtitle"}," 30 websites")),React.createElement(s,{cycle:this.state.cycle,license:"enterprise"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(u,{cycle:this.state.cycle,currency:this.state.currencyName,license:"enterprise"})))),React.createElement("div",{id:"switch-container"},React.createElement("span",{className:"yasr-pricing-text-switcher"}," Display Prices In US $ "),React.createElement("label",{className:"yasr-pricing-switch"},React.createElement("input",{type:"checkbox",onChange:this.updateCurrency}),React.createElement("span",{className:"yasr-pricing-slider"})),React.createElement("span",{className:"yasr-pricing-text-switcher"}," €")))}}])&&t(l.prototype,i),Object.defineProperty(l,"prototype",{writable:!1}),p}();ReactDOM.render(React.createElement(y,null),document.getElementById("yasr-table-container"));var m=document.getElementById("yasr-link-policy"),p=document.getElementById("yasr-link-policy-faq"),f=document.getElementById("yasr-refund-policy"),d=document.getElementById("yasr-close-modal-policy");m.addEventListener("click",(function(){f.style.display="block",document.body.style.backgroundColor="rgba(0,0,0,0.7)"})),p.addEventListener("click",(function(){f.style.display="block",document.body.style.backgroundColor="rgba(0,0,0,0.7)"})),d.onclick=function(){f.style.display="none",document.body.style.backgroundColor="#f1f1f1"}})();
1
+ (()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var c=0;c<t.length;c++){var a=t[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function a(t,c){if(c&&("object"===e(c)||"function"==typeof c))return c;if(void 0!==c)throw new TypeError("Derived constructors may only return object or undefined");return r(t)}function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function l(e){var t="$";return"eur"===e.name&&(t="€"),React.createElement("small",null,t," ")}function i(e){var t="/year";return"monthly"===e.name&&(t="/month"),"lifetime"===e.name&&(t=""),React.createElement("small",null,t)}function s(e){var t=" 1 website";return"plus"===e.license&&(t=" 5 websites"),"enterprise"===e.license&&(t=" 30 websites"),React.createElement("ul",{className:"yasr-pricing-table-features"},"annual"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"1 year")," of supports and updates ",React.createElement("br",null),"for",React.createElement("strong",null,t)),"monthly"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"1 month")," of supports and updates ",React.createElement("br",null),"for",React.createElement("strong",null,t)),"lifetime"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},React.createElement("strong",null,"Lifetime")," updates and support",React.createElement("br",null),"for",React.createElement("strong",null,t)),React.createElement("li",{className:"yasr-pricing-table-feature"},"User reviews"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Custom rankings"),React.createElement("li",{className:"yasr-pricing-table-feature"},"20 + ready to use themes"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Upload your own theme"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Add fake ratings"),React.createElement("li",{className:"yasr-pricing-table-feature"},"Direct email support"),"lifetime"===e.cycle&&React.createElement("li",{className:"yasr-pricing-table-feature"},"We setup the plugin for free ",React.createElement("br",null),"(only lifetime plans)"))}function u(e){var t="",c=1,a="";return"single"===e.license?(a="eur"===e.currency?5399:1933,t="monthly"===e.cycle?"eur"===e.currency?"4.49":"4.99":"lifetime"===e.cycle?"eur"===e.currency?"129.99":"149.99":"eur"===e.currency?"41.99":"47.88"):"plus"===e.license?(c=5,a="eur"===e.currency?5400:1935,t="monthly"===e.cycle?"eur"===e.currency?"8.99":"9.99":"lifetime"===e.cycle?"eur"===e.currency?"249.99":"289.99":"eur"===e.currency?"83.88":"95.88"):"enterprise"===e.license&&(c=30,a="eur"===e.currency?5550:5549,t="monthly"===e.cycle?"eur"===e.currency?"12.99":"14.99":"lifetime"===e.cycle?"eur"===e.currency?"359.99":"439.99":"eur"===e.currency?"119.88":"143.88"),React.createElement("div",{className:"yasr-pring-table-price"},React.createElement(l,{name:e.currency}),React.createElement("span",null,t),React.createElement(i,{name:e.cycle}),React.createElement(o,{cycle:e.cycle,currency:e.currency,license:e.license}),React.createElement("p",{className:"PT-CTA"},React.createElement("a",{href:"#",className:"yasr-buy-button",onClick:function(t){!function(e,t,c,a){var r={plugin_id:256,billing_cycle:e,pricing_id:a,licenses:t,id:"yasr_checkout",page:"yasr_settings_page-pricing",checkout:"true",plan_id:"2778",plan_name:"yasrpro",disable_licenses_selector:!0,hide_billing_cycles:!0,currency:c},n=[];for(var l in r){var i=encodeURIComponent(l),s=encodeURIComponent(r[l]);n.push(i+"="+s)}n=n.join("&");var u=yasrWindowVar.adminUrl+"admin.php?"+n;window.open(u,"_self")}(e.cycle,c,e.currency,a),t.preventDefault()}},"Buy YASR ")))}function o(e){if("annual"===e.cycle){var t;return t="plus"===e.license?"eur"===e.currency?"6.99":"7.99":"enterprise"===e.license?"eur"===e.currency?"9.99":"11.99":"eur"===e.currency?"3.49":"3.99",React.createElement("p",{className:"yasr-pricing-table-price-desc"},React.createElement(l,{name:e.currency}),t," /month")}return React.createElement(React.Fragment,null)}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(p,React.Component);var l,i,o,y,m=(o=p,y=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=n(o);if(y){var c=n(this).constructor;e=Reflect.construct(t,arguments,c)}else e=t.apply(this,arguments);return a(this,e)});function p(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,p),(t=m.call(this,e)).state={currencyName:"usd",cycle:"annual"},t.updateCurrency=t.updateCurrency.bind(r(t)),t.updateCycle=t.updateCycle.bind(r(t)),t}return l=p,(i=[{key:"updateCurrency",value:function(e){var t=e.target;!0===("checkbox"===t.type?t.checked:t.value)?this.setState({currencyName:"eur"}):this.setState({currencyName:"usd"})}},{key:"updateCycle",value:function(e){this.setState({cycle:e.target.value})}},{key:"render",value:function(){return React.createElement(React.Fragment,null,React.createElement("div",{id:"yasr-radio-billing-cycle"},React.createElement("input",{type:"radio",id:"yasr-billing-cycle-monthly",name:"billing-cycle",value:"monthly",onChange:this.updateCycle,checked:"monthly"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-monthly"},"Monthly"),React.createElement("input",{type:"radio",id:"yasr-billing-cycle-annual",name:"billing-cycle",value:"annual",onChange:this.updateCycle,checked:"annual"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-annual"},"Annual"),React.createElement("input",{type:"radio",id:"yasr-billing-cycle-lifetime",name:"billing-cycle",value:"lifetime",onChange:this.updateCycle,checked:"lifetime"===this.state.cycle}),React.createElement("label",{htmlFor:"yasr-billing-cycle-lifetime"},"Lifetime")),React.createElement("div",{id:"yasr-pricing-table"},React.createElement("div",{className:"yasr-pricing-table-item"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Plus"),React.createElement("p",{className:"yasr-pricing-table-subtitle"},"5 websites")),React.createElement(s,{cycle:this.state.cycle,license:"plus"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(u,{cycle:this.state.cycle,currency:this.state.currencyName,license:"plus"}))),React.createElement("div",{className:"yasr-pricing-table-item is-highlighted"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Single"),React.createElement("p",{className:"yasr-pricing-table-subtitle"}," 1 website")),React.createElement(s,{cycle:this.state.cycle,license:"single"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(u,{cycle:this.state.cycle,currency:this.state.currencyName,license:"single"}))),React.createElement("div",{className:"yasr-pricing-table-item"},React.createElement("header",{className:"yasr-pricing-table-heading"},React.createElement("h2",{className:"yasr-pricing-table-title"},"Enterprise"),React.createElement("p",{className:"yasr-pricing-table-subtitle"}," 30 websites")),React.createElement(s,{cycle:this.state.cycle,license:"enterprise"}),React.createElement("div",{className:"yasr-pricing-table-footer"},React.createElement(u,{cycle:this.state.cycle,currency:this.state.currencyName,license:"enterprise"})))),React.createElement("div",{id:"switch-container"},React.createElement("span",{className:"yasr-pricing-text-switcher"}," Display Prices In US $ "),React.createElement("label",{className:"yasr-pricing-switch"},React.createElement("input",{type:"checkbox",onChange:this.updateCurrency}),React.createElement("span",{className:"yasr-pricing-slider"})),React.createElement("span",{className:"yasr-pricing-text-switcher"}," €")))}}])&&t(l.prototype,i),Object.defineProperty(l,"prototype",{writable:!1}),p}();ReactDOM.render(React.createElement(y,null),document.getElementById("yasr-table-container"));var m=document.getElementById("yasr-link-policy"),p=document.getElementById("yasr-link-policy-faq"),f=document.getElementById("yasr-refund-policy"),d=document.getElementById("yasr-close-modal-policy");m.addEventListener("click",(function(){f.style.display="block",document.body.style.backgroundColor="rgba(0,0,0,0.7)"})),p.addEventListener("click",(function(){f.style.display="block",document.body.style.backgroundColor="rgba(0,0,0,0.7)"})),d.onclick=function(){f.style.display="none",document.body.style.backgroundColor="#f1f1f1"}})();
admin/js/yasr-settings.js CHANGED
@@ -1 +1 @@
1
- (()=>{var e;if(document.getElementsByClassName("nav-tab-active").length>0&&(e=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===e){var t=document.getElementById("yasr_auto_insert_switch").checked,a=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===t&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===a&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-rating-saved").value="Rating saved!",document.getElementById("yasr-settings-custom-text-rating-updated").value="Rating updated!",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===e&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===e){var r=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===r){var n=jQuery("#yasr-edit-form-number-elements").attr("value");n++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(n>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 #'+n+' <input type="text" name="edit-multi-set-element-'+n+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),n++}))}else r>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"migration_tools"===e&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})),wp.hooks.doAction("yasr_migration_page_bottom")),"rankings"===e&&wp.hooks.doAction("yasr_ranking_page_top")})(),(()=>{"use strict";let e;var t,a=new Uint8Array(16);function r(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(a)}const n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&n.test(e)};for(var o=[],i=0;i<256;++i)o.push((i+256).toString(16).substr(1));const l=function(e,t,a){var n=(e=e||{}).random||(e.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){a=a||0;for(var i=0;i<16;++i)t[a+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase();if(!s(a))throw TypeError("Stringified UUID is invalid");return a}(n)};function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function c(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function y(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}var p=wp.i18n.__,g=wp.element.render;function h(e){var t="yasr-ranking-element-"+l(),a=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:t,ref:function(){return yasrSetRaterValue(a,t,!1,.1,!0,e.rating)}})}function f(e){if(void 0!==e.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",e.post.number_of_votes,"  ",p("Average:","yet-another-stars-rating")," ",e.post.rating,"]");var t=e.text;return React.createElement("span",{className:"yasr-highest-rated-text"},t," ",e.post.rating)}function v(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===e&&(e=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),e.innerHTML=t;const a=e.textContent;return e.innerHTML="",a}(t.post.title)))}function _(e){var t="after",a=p("Rating:","yet-another-stars-rating"),r=new URLSearchParams(e.rankingParams);return null!==r.get("text_position")&&(t=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===t?React.createElement("td",{className:e.colClass},React.createElement(f,{post:e.post,tableId:e.tableId,text:a}),React.createElement(h,{rating:e.post.rating,tableId:e.tableId})):React.createElement("td",{className:e.colClass},React.createElement(h,{rating:e.post.rating,tableId:e.tableId}),React.createElement(f,{post:e.post,tableId:e.tableId,text:a}))}function b(e){var t="",a="";return"author_ranking"===e.source?(t="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===e.source&&(t="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:e.trClass},React.createElement(v,{colClass:t,post:e.post}),React.createElement(_,{colClass:a,post:e.post,tableId:e.tableId,rankingParams:e.rankingParams}))}function E(e){return React.createElement("tbody",{id:e.tBodyId,style:{display:e.show}},e.data.map((function(t,a){var r="yasr-rankings-td-colored";return"author_ranking"===e.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===e.source&&(r="yasr-rankings-td-colored")),React.createElement(b,{key:t.post_id,source:e.source,tableId:e.tableId,rankingParams:e.rankingParams,post:t,trClass:r})})))}var k=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(o,React.Component);var t,a,r,n,s=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=m(r);if(n){var a=m(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return y(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e)).state={error:null,isLoaded:!1,data:[],tableId:e.tableId,source:e.source,rankingParams:e.params,nonce:e.nonce},t}return t=o,a=[{key:"componentDidMount",value:function(){var e=this,t=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:t});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(e){return fetch(e).then((function(e){return!0===e.ok?e.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(e){"KO"===e?a=t:"overall_rating"===e.source||"author_multi"===e.source?a="overall_rating"===e.source?e.data_overall:e.data_mv:a[e.show]=e.data_vv})).catch((function(e){a=t,console.info(e)}))}))).then((function(t){e.setState({isLoaded:!0,data:a})})).catch((function(t){console.info(t),e.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var e,t=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==t&&!1!==t){var s=new URLSearchParams(t);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==t){var l=new URLSearchParams(t);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}e=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return e}},{key:"rankingTableHead",value:function(e,t){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==e){var s=React.createElement("span",null,React.createElement("span",{id:r},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===t&&(s=React.createElement("span",null,React.createElement("span",{id:n},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(e){e.preventDefault();var t=e.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(t),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),t===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),t===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var e=this.state,t=e.data,a=e.source,r=e.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:t,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=t.most,s=t.highest,o="table-row-group",i="none",l="most",d=o,c=i,u=new URLSearchParams(r);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(d=i,c=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:d,source:a}),React.createElement(E,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}))}},{key:"render",value:function(){var e=this.state,t=e.error,a=e.isLoaded;return t?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(t),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}],a&&c(t.prototype,a),Object.defineProperty(t,"prototype",{writable:!1}),o}();function w(){var e=document.getElementsByClassName("yasr-stars-rankings");if(e.length>0)for(var t=0;t<e.length;t++){var a=e.item(t).id,r=JSON.parse(e.item(t).dataset.rankingSource),n=JSON.parse(e.item(t).dataset.rankingParams),s=JSON.parse(e.item(t).dataset.rankingNonce),o=document.getElementById(a);g(React.createElement(k,{source:r,tableId:a,params:n,nonce:s}),o)}}w(),tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var I,B=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(I=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===I){var R,j=function(e){var t=D.value,a=document.getElementById("yasr-builder-shortcode").textContent,r=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];r=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",r),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+t+"&full_shortcode="+a).then((function(e){return!0===e.ok?e.json():(console.info(B("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(e){console.info(e)})).then((function(e){if("KO"!==e){var t=document.createElement("div");t.innerHTML=e,M.childNodes.length>0?M.replaceChild(t,M.childNodes[0]):M.appendChild(t)}})).then((function(e){r.forEach((function(e){t===e&&w()}))}))},x=function(e,t,a,r,n,s,o,i,l){e.style.display="",t.style.display="",s.style.display="",l.style.display="",a.style.display="none",r.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},C=function(e,t,a,r,n,s,o,i,l){a.style.display="",r.style.display="",t.style.display="",s.style.display="",l.style.display="",e.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},Q=function(e,t,a,r,n,s,o,i,l){n.style.display="",l.style.display="none",e.style.display="none",a.style.display="none",r.style.display="none",t.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},L=function(e,t,a,r,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(F.className="",F.classList.add("yasr-settings-row-24"),a.style.display="",r.style.display="",e.style.display="none"):(a.style.display="none",r.style.display="none",e.style.display=""),s.style.display="",t.style.display="",d.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")},T=".yasr-builder-elements-parents",S=".yasr-builder-elements-childs";jQuery(T).prop("disabled",!0),jQuery(S).prop("disabled",!0),jQuery(T).find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",T,S);var P=[],O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};R=O.name,document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]");var N=document.getElementById("yasr-builder-button-preview"),H=document.getElementById("yasr-builder-copy-shortcode"),M=document.getElementById("yasr-builder-preview"),D=document.getElementById("yasr-ranking-source"),A=document.getElementById("yasr-ranking-multiset-select"),U=document.getElementById("yasr-builder-datepicker-start"),q=document.getElementById("yasr-builder-datepicker-end"),F=document.getElementById("yasr-builder-params-container"),z=document.getElementById("builder-vv-default-view"),V=document.getElementById("builder-vv-required-votes"),J=document.getElementById("builder-stars-size"),K=document.getElementById("builder-overall-text"),Y=document.getElementById("builder-username-options"),G=document.getElementById("builder-category"),$=document.getElementById("builder-cpt"),W=document.getElementById("yasr-ranking-multiset"),X=document.getElementById("yasr-builder-datepicker"),Z=D.value,ee=!1;U.value="",q.value="","yasr_ov_ranking"===Z?x(K,J,z,V,Y,G,$,W,X):"yasr_most_active_users"===Z||"yasr_top_reviewers"===Z?Q(K,J,z,V,Y,G,$,W,X):"yasr_multi_set_ranking"===Z?L(K,J,z,V,Y,G,$,W,!1,X):"yasr_visitor_multi_set_ranking"===Z?L(K,J,z,V,Y,G,$,W,!0,X):C(K,J,z,V,Y,G,$,W,X),document.addEventListener("change",(function(e){if("yasr-ranking-source"===e.target.id)F.className="",F.classList.add("yasr-settings-row-33"),M.innerHTML="",U.value="",q.value="",O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===e.target.value?x(K,J,z,V,Y,G,$,W,X):"yasr_most_active_users"===e.target.value||"yasr_top_reviewers"===e.target.value?Q(K,J,z,V,Y,G,$,W,X):"yasr_multi_set_ranking"===e.target.value?(L(K,J,z,V,Y,G,$,W,!1,X),O.setid=" setid="+A[0].value):"yasr_visitor_multi_set_ranking"===e.target.value?(L(K,J,z,V,Y,G,$,W,!0,X),O.setid=" setid="+A[0].value):C(K,J,z,V,Y,G,$,W,X),O.name=e.target.value,R=O.name+O.setid;else{"yasr-ranking-multiset-select"===e.target.id&&(O.setid=" setid="+e.target.value),P=wp.hooks.applyFilters("yasrBuilderFilterShortcode",O);for(var t=2;O.length;t++)P.hasOwnProperty(O[t])&&(O[t]=P[t]);R=O.name+O.setid+O.rows+O.view+O.minvotesmost+O.minvoteshg+O.size+O.txtPosition+O.txt+O.display+O.start_date+O.end_date+O.category+O.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]"),!0===ee&&"yasr-ranking-source"!==e.target.id&&"yasr-builder-category-radio"!==e.target.name&&j()})),H.onclick=function(e){var t,a;t=document.getElementById(e.target.id).getAttribute("data-shortcode"),(a=document.createElement("textarea")).value=t,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},N.onclick=function(e){j(),ee=!0}}})();
1
+ (()=>{var e;if(document.getElementsByClassName("nav-tab-active").length>0&&(e=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===e){var t=document.getElementById("yasr_auto_insert_switch").checked,a=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===t&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===a&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-rating-saved").value="Rating saved!",document.getElementById("yasr-settings-custom-text-rating-updated").value="Rating updated!",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===e&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===e){var r=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===r){var n=jQuery("#yasr-edit-form-number-elements").attr("value");n++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(n>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 #'+n+' <input type="text" name="edit-multi-set-element-'+n+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),n++}))}else r>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var e={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(e)})),!1})),jQuery(document).ajaxComplete((function(){var e=jQuery("#yasr-edit-form-number-elements").attr("value");e++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(e>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+e+' <input type="text" name="edit-multi-set-element-'+e+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),e++}))})))}"migration_tools"===e&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrWindowVar.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrWindowVar.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrWindowVar.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrWindowVar.loaderUrl+'" alt="yasr-loader" width="16" height="16">';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})),wp.hooks.doAction("yasr_migration_page_bottom")),"rankings"===e&&wp.hooks.doAction("yasr_ranking_page_top")})(),(()=>{"use strict";let e;var t,a=new Uint8Array(16);function r(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(a)}const n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&n.test(e)};for(var o=[],i=0;i<256;++i)o.push((i+256).toString(16).substr(1));const l=function(e,t,a){var n=(e=e||{}).random||(e.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){a=a||0;for(var i=0;i<16;++i)t[a+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase();if(!s(a))throw TypeError("Stringified UUID is invalid");return a}(n)};function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function c(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function y(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}var p=wp.i18n.__,g=wp.element.render;function h(e){var t="yasr-ranking-element-"+l(),a=document.getElementById(e.tableId).dataset.rankingSize;return React.createElement("div",{id:t,ref:function(){return yasrSetRaterValue(a,t,!1,.1,!0,e.rating)}})}function f(e){if(void 0!==e.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",e.post.number_of_votes,"  ",p("Average:","yet-another-stars-rating")," ",e.post.rating,"]");var t=e.text;return React.createElement("span",{className:"yasr-highest-rated-text"},t," ",e.post.rating)}function v(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===e&&(e=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),e.innerHTML=t;const a=e.textContent;return e.innerHTML="",a}(t.post.title)))}function _(e){var t="after",a=p("Rating:","yet-another-stars-rating"),r=new URLSearchParams(e.rankingParams);return null!==r.get("text_position")&&(t=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===t?React.createElement("td",{className:e.colClass},React.createElement(f,{post:e.post,tableId:e.tableId,text:a}),React.createElement(h,{rating:e.post.rating,tableId:e.tableId})):React.createElement("td",{className:e.colClass},React.createElement(h,{rating:e.post.rating,tableId:e.tableId}),React.createElement(f,{post:e.post,tableId:e.tableId,text:a}))}function b(e){var t="",a="";return"author_ranking"===e.source?(t="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===e.source&&(t="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:e.trClass},React.createElement(v,{colClass:t,post:e.post}),React.createElement(_,{colClass:a,post:e.post,tableId:e.tableId,rankingParams:e.rankingParams}))}function E(e){return React.createElement("tbody",{id:e.tBodyId,style:{display:e.show}},e.data.map((function(t,a){var r="yasr-rankings-td-colored";return"author_ranking"===e.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===e.source&&(r="yasr-rankings-td-colored")),React.createElement(b,{key:t.post_id,source:e.source,tableId:e.tableId,rankingParams:e.rankingParams,post:t,trClass:r})})))}var k=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(o,React.Component);var t,a,r,n,s=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=m(r);if(n){var a=m(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return y(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=s.call(this,e)).state={error:null,isLoaded:!1,data:[],tableId:e.tableId,source:e.source,rankingParams:e.params,nonce:e.nonce},t}return t=o,a=[{key:"componentDidMount",value:function(){var e=this,t=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrWindowVar.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:t});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(e){return fetch(e).then((function(e){return!0===e.ok?e.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(e){"KO"===e?a=t:"overall_rating"===e.source||"author_multi"===e.source?a="overall_rating"===e.source?e.data_overall:e.data_mv:a[e.show]=e.data_vv})).catch((function(e){a=t,console.info(e)}))}))).then((function(t){e.setState({isLoaded:!0,data:a})})).catch((function(t){console.info(t),e.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var e,t=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==t&&!1!==t){var s=new URLSearchParams(t);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)e=[yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==t){var l=new URLSearchParams(t);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}e=[yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return e}},{key:"rankingTableHead",value:function(e,t){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==e){var s=React.createElement("span",null,React.createElement("span",{id:r},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===t&&(s=React.createElement("span",null,React.createElement("span",{id:n},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(e){e.preventDefault();var t=e.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(t),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),t===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),t===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var e=this.state,t=e.data,a=e.source,r=e.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:t,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=t.most,s=t.highest,o="table-row-group",i="none",l="most",d=o,c=i,u=new URLSearchParams(r);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(d=i,c=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:d,source:a}),React.createElement(E,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}))}},{key:"render",value:function(){var e=this.state,t=e.error,a=e.isLoaded;return t?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(t),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}],a&&c(t.prototype,a),Object.defineProperty(t,"prototype",{writable:!1}),o}();function w(){var e=document.getElementsByClassName("yasr-stars-rankings");if(e.length>0)for(var t=0;t<e.length;t++){var a=e.item(t).id,r=JSON.parse(e.item(t).dataset.rankingSource),n=JSON.parse(e.item(t).dataset.rankingParams),s=JSON.parse(e.item(t).dataset.rankingNonce),o=document.getElementById(a);g(React.createElement(k,{source:r,tableId:a,params:n,nonce:s}),o)}}w(),tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"});var I,B=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(I=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===I){var R,j=function(e){var t=A.value,a=document.getElementById("yasr-builder-shortcode").textContent,r=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];r=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",r),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+t+"&full_shortcode="+a).then((function(e){return!0===e.ok?e.json():(console.info(B("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(e){console.info(e)})).then((function(e){if("KO"!==e){var t=document.createElement("div");t.innerHTML=e,M.childNodes.length>0?M.replaceChild(t,M.childNodes[0]):M.appendChild(t)}})).then((function(e){r.forEach((function(e){t===e&&w()}))}))},x=function(e,t,a,r,n,s,o,i,l){e.style.display="",t.style.display="",s.style.display="",l.style.display="",a.style.display="none",r.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},Q=function(e,t,a,r,n,s,o,i,l){a.style.display="",r.style.display="",t.style.display="",s.style.display="",l.style.display="",e.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},C=function(e,t,a,r,n,s,o,i,l){n.style.display="",l.style.display="none",e.style.display="none",a.style.display="none",r.style.display="none",t.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},L=function(e,t,a,r,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8],d=arguments.length>9?arguments[9]:void 0;!0===l?(q.className="",q.classList.add("yasr-settings-row-24"),a.style.display="",r.style.display="",e.style.display="none"):(a.style.display="none",r.style.display="none",e.style.display=""),s.style.display="",t.style.display="",d.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="")},T=".yasr-builder-elements-parents",S=".yasr-builder-elements-childs";jQuery(T).prop("disabled",!0),jQuery(S).prop("disabled",!0),jQuery(T).find("input").each((function(){jQuery(this).prop("disabled",!0)})),wp.hooks.doAction("yasrBuilderBegin",T,S);var P=[],O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""};R=O.name,document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]");var N=document.getElementById("yasr-builder-button-preview"),H=document.getElementById("yasr-builder-copy-shortcode"),M=document.getElementById("yasr-builder-preview"),A=document.getElementById("yasr-ranking-source"),V=document.getElementById("yasr-ranking-multiset-select"),U=document.getElementById("yasr-builder-datepicker-start"),D=document.getElementById("yasr-builder-datepicker-end"),q=document.getElementById("yasr-builder-params-container"),F=document.getElementById("builder-vv-default-view"),W=document.getElementById("builder-vv-required-votes"),z=document.getElementById("builder-stars-size"),J=document.getElementById("builder-overall-text"),K=document.getElementById("builder-username-options"),Y=document.getElementById("builder-category"),G=document.getElementById("builder-cpt"),$=document.getElementById("yasr-ranking-multiset"),X=document.getElementById("yasr-builder-datepicker"),Z=A.value,ee=!1;U.value="",D.value="","yasr_ov_ranking"===Z?x(J,z,F,W,K,Y,G,$,X):"yasr_most_active_users"===Z||"yasr_top_reviewers"===Z?C(J,z,F,W,K,Y,G,$,X):"yasr_multi_set_ranking"===Z?L(J,z,F,W,K,Y,G,$,!1,X):"yasr_visitor_multi_set_ranking"===Z?L(J,z,F,W,K,Y,G,$,!0,X):Q(J,z,F,W,K,Y,G,$,X),document.addEventListener("change",(function(e){if("yasr-ranking-source"===e.target.id)q.className="",q.classList.add("yasr-settings-row-33"),M.innerHTML="",U.value="",D.value="",O={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",start_date:"",end_date:"",category:"",cpt:""},"yasr_ov_ranking"===e.target.value?x(J,z,F,W,K,Y,G,$,X):"yasr_most_active_users"===e.target.value||"yasr_top_reviewers"===e.target.value?C(J,z,F,W,K,Y,G,$,X):"yasr_multi_set_ranking"===e.target.value?(L(J,z,F,W,K,Y,G,$,!1,X),O.setid=" setid="+V[0].value):"yasr_visitor_multi_set_ranking"===e.target.value?(L(J,z,F,W,K,Y,G,$,!0,X),O.setid=" setid="+V[0].value):Q(J,z,F,W,K,Y,G,$,X),O.name=e.target.value,R=O.name+O.setid;else{"yasr-ranking-multiset-select"===e.target.id&&(O.setid=" setid="+e.target.value),P=wp.hooks.applyFilters("yasrBuilderFilterShortcode",O);for(var t=2;O.length;t++)P.hasOwnProperty(O[t])&&(O[t]=P[t]);R=O.name+O.setid+O.rows+O.view+O.minvotesmost+O.minvoteshg+O.size+O.txtPosition+O.txt+O.display+O.start_date+O.end_date+O.category+O.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+R+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+R+"]"),!0===ee&&"yasr-ranking-source"!==e.target.id&&"yasr-builder-category-radio"!==e.target.name&&j()})),H.onclick=function(e){var t,a;t=document.getElementById(e.target.id).getAttribute("data-shortcode"),(a=document.createElement("textarea")).value=t,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)},N.onclick=function(e){j(),ee=!0}}})();
admin/settings/classes/YasrSettings.php CHANGED
@@ -58,8 +58,8 @@ class YasrSettings {
58
  array($this, 'sanitize')
59
  );
60
 
61
- $settings = new YasrSettingsValues();
62
- $options = $settings->getGeneralSettings();
63
 
64
  add_settings_section(
65
  'yasr_general_options_section_id',
@@ -114,19 +114,18 @@ class YasrSettings {
114
  );
115
 
116
  add_settings_field(
117
- 'yasr_custom_text',
118
- yasr_description_cstm_txt(),
119
- array($this, 'customText'),
120
  'yasr_general_settings_tab',
121
  'yasr_general_options_section_id',
122
  $options
123
  );
124
 
125
-
126
  add_settings_field(
127
- 'yasr_choose_snippet_id',
128
- yasr_description_strucutured_data(),
129
- array($this, 'snippets' ),
130
  'yasr_general_settings_tab',
131
  'yasr_general_options_section_id',
132
  $options
@@ -443,6 +442,9 @@ class YasrSettings {
443
  alt="yasr-statsexplained">
444
  </div>
445
  </div>
 
 
 
446
  <hr />
447
  <?php
448
 
@@ -481,106 +483,6 @@ class YasrSettings {
481
 
482
  } //End function
483
 
484
- /**
485
- * Display options for custom texts
486
- *
487
- * @author Dario Curvino <@dudo>
488
- * @param $option
489
- */
490
- public function customText($option) {
491
- ?>
492
- <div>
493
- <?php
494
- $custom_text = array(
495
- 'txt_before_overall' => array (
496
- 'name' => 'text_before_overall',
497
- 'description' => __('Custom text to display before Overall Rating', 'yet-another-stars-rating'),
498
- 'id' => 'yasr-settings-custom-text-before-overall',
499
- 'class' => 'yasr-general-options-text-before'
500
- ),
501
- 'txt_before_vv' => array (
502
- 'name' => 'text_before_visitor_rating',
503
- 'description' => __('Custom text to display BEFORE Visitor Rating', 'yet-another-stars-rating'),
504
- 'id' => 'yasr-settings-custom-text-before-visitor',
505
- 'class' => 'yasr-general-options-text-before'
506
- ),
507
- 'txt_after_vv' => array (
508
- 'name' => 'text_after_visitor_rating',
509
- 'description' => __('Custom text to display AFTER Visitor Rating', 'yet-another-stars-rating'),
510
- 'id' => 'yasr-settings-custom-text-after-visitor',
511
- 'class' => 'yasr-general-options-text-before'
512
- ),
513
- 'txt_login_required' => array (
514
- 'name' => 'custom_text_must_sign_in',
515
- 'description' => __('Custom text to display when login is required to vote', 'yet-another-stars-rating'),
516
- 'id' => 'yasr-settings-custom-text-must-sign-in',
517
- 'class' => 'yasr-general-options-text-before'
518
- ),
519
- 'txt_vv_rating_saved' => array (
520
- 'name' => 'custom_text_rating_saved',
521
- 'description' => __('Custom text to display when rating is saved', 'yet-another-stars-rating'),
522
- 'id' => 'yasr-settings-custom-text-rating-saved',
523
- 'class' => 'yasr-general-options-text-before'
524
- ),
525
- 'txt_vv_rating_updated' => array (
526
- 'name' => 'custom_text_rating_updated',
527
- 'description' => __('Custom text to display when rating is updated (only for logged in users)',
528
- 'yet-another-stars-rating'),
529
- 'id' => 'yasr-settings-custom-text-rating-updated',
530
- 'class' => 'yasr-general-options-text-before'
531
- ),
532
- 'txt_vv_rated' => array (
533
- 'name' => 'custom_text_user_voted',
534
- 'description' => __('Custom text to display when an user has already rated', 'yet-another-stars-rating'),
535
- 'id' => 'yasr-settings-custom-text-already-rated',
536
- 'class' => 'yasr-general-options-text-before'
537
- ),
538
- );
539
- ?>
540
- <div class="yasr-settings-row-45">
541
- <div id="yasr-general-options-custom-text">
542
- <?php
543
- self::echoSettingFields($custom_text, $option);
544
- ?>
545
- <input type="button"
546
- id="yasr-settings-custom-texts"
547
- class="button"
548
- value="<?php esc_attr_e('Restore defaults', 'yet-another-stars-rating') ?>">
549
- </div>
550
-
551
- <div id="yasr-doc-custom-text-div">
552
- <div class="yasr-help-box-settings" style="display: block">
553
- <?php
554
- $string_custom_overall = sprintf(
555
- __('In the first and last fields you can use %s pattern to show the rating (as text).',
556
- 'yet-another-stars-rating'), '<strong>%rating%</strong>');
557
-
558
- $string_custom_visitor = sprintf(__('In the second and third fields you can use %s pattern to show the
559
- total count, and %s pattern to show the average.', 'yet-another-stars-rating'),
560
- '<strong>%total_count%</strong>', '<strong>%average%</strong>');
561
-
562
- esc_html_e('Leave a field empty to disable it.', 'yet-another-stars-rating');
563
- echo '<br /><br/>';
564
- echo wp_kses_post($string_custom_overall);
565
- echo '<br /><br/>';
566
- echo wp_kses_post($string_custom_visitor);
567
- echo '<br /><br/>';
568
-
569
- esc_html_e('You can use these html tags:', 'yet-another-stars-rating');
570
- echo ' <strong>' . esc_html('<strong>, <p>') . '.</strong>';
571
- ?>
572
- </div>
573
- </div>
574
- </div>
575
- <br />
576
- <?php
577
- submit_button(YASR_SAVE_All_SETTINGS_TEXT);
578
- ?>
579
- </div>
580
- <hr />
581
- <?php
582
- }
583
-
584
  /**
585
  * Display options for rich snippets
586
  *
@@ -697,6 +599,102 @@ class YasrSettings {
697
 
698
  } //End function yasr_choose_snippet_callback
699
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
700
  /**
701
  * Display options for advanced settings
702
  *
@@ -786,22 +784,12 @@ class YasrSettings {
786
  //Array to return
787
  $output = array();
788
 
789
- $tidy_installed = false;
790
-
791
- if (extension_loaded('tidy')) {
792
- $tidy_release_date = strtotime(tidy_get_release());
793
- $tidy_working_release_date = strtotime('2017/11/25');
794
-
795
- if ($tidy_release_date >= $tidy_working_release_date) {
796
- $tidy_installed = true;
797
- }
798
- }
799
 
800
  // Loop through each of the incoming options
801
  foreach ($option as $key => $value) {
802
  // Check to see if the current option has a value. If so, process it.
803
  if (isset($option[$key])) {
804
-
805
  //Tags are not allowed for any fields
806
  $allowed_tags = '';
807
 
@@ -917,6 +905,7 @@ class YasrSettings {
917
  */
918
  public static function echoSettingFields($elementsType_array, $option, $option_prefix='yasr_general_options') {
919
  $string_input = false;
 
920
 
921
  foreach($elementsType_array as $property) {
922
 
@@ -934,24 +923,27 @@ class YasrSettings {
934
  }
935
  } //to use text, there is no need to set the type element
936
  else {
937
- $placeholder = isset($property['placeholder']) ? $property['placeholder'] : '';
938
- $string_input = YasrPhpFieldsHelper::text(
 
 
 
 
939
  $property['class'], '', $element_name, $property['id'], $placeholder, esc_attr($option[$property['name']])
940
  );
941
  }
942
 
943
- echo htmlspecialchars_decode($string_input);
944
-
945
  if(isset($property['description']) && $property['description'] !== '') {
946
- echo '<div class="yasr-element-row-container-description">';
947
- echo esc_html($property['description']);
948
- echo '</div>';
 
 
949
  }
950
 
 
 
951
  }
952
  }
953
 
954
-
955
-
956
-
957
  }
58
  array($this, 'sanitize')
59
  );
60
 
61
+ $settings = new YasrSettingsValues();
62
+ $options = $settings->getGeneralSettings();
63
 
64
  add_settings_section(
65
  'yasr_general_options_section_id',
114
  );
115
 
116
  add_settings_field(
117
+ 'yasr_choose_snippet_id',
118
+ yasr_description_strucutured_data(),
119
+ array($this, 'snippets'),
120
  'yasr_general_settings_tab',
121
  'yasr_general_options_section_id',
122
  $options
123
  );
124
 
 
125
  add_settings_field(
126
+ 'yasr_custom_text',
127
+ wp_kses_post(yasr_description_cstm_txt()),
128
+ array($this, 'customText'),
129
  'yasr_general_settings_tab',
130
  'yasr_general_options_section_id',
131
  $options
442
  alt="yasr-statsexplained">
443
  </div>
444
  </div>
445
+ <?php
446
+ submit_button(YASR_SAVE_All_SETTINGS_TEXT);
447
+ ?>
448
  <hr />
449
  <?php
450
 
483
 
484
  } //End function
485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  /**
487
  * Display options for rich snippets
488
  *
599
 
600
  } //End function yasr_choose_snippet_callback
601
 
602
+ /**
603
+ * Display options for custom texts
604
+ *
605
+ * @author Dario Curvino <@dudo>
606
+ * @param $option
607
+ */
608
+ public function customText($option) {
609
+ ?>
610
+ <div>
611
+ <?php
612
+ $custom_text = array(
613
+ 'txt_before_overall' => array (
614
+ 'name' => 'text_before_overall',
615
+ 'description' => '&sup1; '.esc_html__('Custom text to display before Overall Rating', 'yet-another-stars-rating'),
616
+ 'id' => 'yasr-settings-custom-text-before-overall',
617
+ 'class' => 'yasr-general-options-text-before'
618
+ ),
619
+ 'txt_before_vv' => array (
620
+ 'name' => 'text_before_visitor_rating',
621
+ 'description' => '&sup2; '.esc_html__('Custom text to display BEFORE Visitor Rating', 'yet-another-stars-rating'),
622
+ 'id' => 'yasr-settings-custom-text-before-visitor',
623
+ 'class' => 'yasr-general-options-text-before'
624
+ ),
625
+ 'txt_after_vv' => array (
626
+ 'name' => 'text_after_visitor_rating',
627
+ 'description' => '&sup2; '.esc_html__('Custom text to display AFTER Visitor Rating', 'yet-another-stars-rating'),
628
+ 'id' => 'yasr-settings-custom-text-after-visitor',
629
+ 'class' => 'yasr-general-options-text-before'
630
+ ),
631
+ 'txt_login_required' => array (
632
+ 'name' => 'custom_text_must_sign_in',
633
+ 'description' => esc_html__('Custom text to display when login is required to vote', 'yet-another-stars-rating'),
634
+ 'id' => 'yasr-settings-custom-text-must-sign-in',
635
+ 'class' => 'yasr-general-options-text-before'
636
+ ),
637
+ 'txt_vv_rating_saved' => array (
638
+ 'name' => 'custom_text_rating_saved',
639
+ 'description' => esc_html__('Custom text to display when rating is saved', 'yet-another-stars-rating'),
640
+ 'id' => 'yasr-settings-custom-text-rating-saved',
641
+ 'class' => 'yasr-general-options-text-before'
642
+ ),
643
+ 'txt_vv_rating_updated' => array (
644
+ 'name' => 'custom_text_rating_updated',
645
+ 'description' => esc_html__('Custom text to display when rating is updated (only for logged in users)',
646
+ 'yet-another-stars-rating'),
647
+ 'id' => 'yasr-settings-custom-text-rating-updated',
648
+ 'class' => 'yasr-general-options-text-before'
649
+ ),
650
+ 'txt_vv_rated' => array (
651
+ 'name' => 'custom_text_user_voted',
652
+ 'description' => '&sup1; '.esc_html__('Custom text to display when an user has already rated', 'yet-another-stars-rating'),
653
+ 'id' => 'yasr-settings-custom-text-already-rated',
654
+ 'class' => 'yasr-general-options-text-before'
655
+ ),
656
+ );
657
+ ?>
658
+ <div class="yasr-settings-row-45" id="yasr-general-options-custom-text">
659
+ <?php
660
+ self::echoSettingFields($custom_text, $option);
661
+ ?>
662
+ </div>
663
+
664
+ <div class="yasr-help-box-settings" style="display: block">
665
+ <?php
666
+ $string_custom_overall = sprintf(
667
+ __('%s In these fields you can use %s pattern to show the rating (as text).',
668
+ 'yet-another-stars-rating'),
669
+ '<strong>&sup1;</strong>','<strong>%rating%</strong>');
670
+
671
+ $string_custom_visitor = sprintf(__('%s In these fields you can use %s pattern to show the
672
+ total count, and %s pattern to show the average.', 'yet-another-stars-rating'),
673
+ '<strong>&sup2;</strong>','<strong>%total_count%</strong>', '<strong>%average%</strong>');
674
+
675
+ $description = esc_html__('Leave a field empty to disable it.', 'yet-another-stars-rating');
676
+ $description .= '<p>'.$string_custom_overall.'</p>';
677
+ $description .= '<p>'.$string_custom_visitor.'</p>';
678
+ $description .= '<p>'.esc_html__('Allowed html tags:', 'yet-another-stars-rating');
679
+ $description .= '<br /><strong>' . esc_html('<strong>, <p>') . '</strong>'.'.</p>';
680
+
681
+ echo wp_kses_post($description);
682
+ ?>
683
+ </div>
684
+ <div style="padding-left: 10px; padding-bottom: 15px;">
685
+ <p>
686
+ <input type="button"
687
+ id="yasr-settings-custom-texts"
688
+ class="button"
689
+ value="<?php esc_attr_e('Restore default strings', 'yet-another-stars-rating') ?>"
690
+ >
691
+ </p>
692
+ </div>
693
+ </div>
694
+ <hr />
695
+ <?php
696
+ }
697
+
698
  /**
699
  * Display options for advanced settings
700
  *
784
  //Array to return
785
  $output = array();
786
 
787
+ $tidy_installed = yasr_is_tidy_installed();
 
 
 
 
 
 
 
 
 
788
 
789
  // Loop through each of the incoming options
790
  foreach ($option as $key => $value) {
791
  // Check to see if the current option has a value. If so, process it.
792
  if (isset($option[$key])) {
 
793
  //Tags are not allowed for any fields
794
  $allowed_tags = '';
795
 
905
  */
906
  public static function echoSettingFields($elementsType_array, $option, $option_prefix='yasr_general_options') {
907
  $string_input = false;
908
+ $type = false;
909
 
910
  foreach($elementsType_array as $property) {
911
 
923
  }
924
  } //to use text, there is no need to set the type element
925
  else {
926
+ $type = 'text';
927
+ $placeholder = isset($property['placeholder']) ? $property['placeholder'] : '';
928
+
929
+ //if description exists, add another <div> before
930
+ $string_input = isset($property['description']) && ($property['description'] !== '') ? '<div>' : '';
931
+ $string_input .= YasrPhpFieldsHelper::text(
932
  $property['class'], '', $element_name, $property['id'], $placeholder, esc_attr($option[$property['name']])
933
  );
934
  }
935
 
 
 
936
  if(isset($property['description']) && $property['description'] !== '') {
937
+ $string_input .= '<div class="yasr-element-row-container-description">';
938
+ $string_input .= esc_html($property['description']);
939
+ //if this is coming from "text field, close 2 divs"
940
+ $string_input .= ($type === 'text') ? '</div>' : '';
941
+ $string_input .= '</div>';
942
  }
943
 
944
+ echo htmlspecialchars_decode($string_input);
945
+
946
  }
947
  }
948
 
 
 
 
949
  }
admin/settings/multiset/yasr-settings-functions-multiset.php CHANGED
@@ -400,6 +400,7 @@ function yasr_process_new_multi_set_form() {
400
  global $wpdb;
401
 
402
  if (!current_user_can('manage_options')) {
 
403
  wp_die('You are not allowed to be on this page.');
404
  }
405
 
@@ -575,6 +576,7 @@ function yasr_process_edit_multi_set_form() {
575
  $array_errors = array();
576
 
577
  if (!current_user_can('manage_options')) {
 
578
  wp_die('You are not allowed to be on this page.');
579
  }
580
 
400
  global $wpdb;
401
 
402
  if (!current_user_can('manage_options')) {
403
+ /** @noinspection ForgottenDebugOutputInspection */
404
  wp_die('You are not allowed to be on this page.');
405
  }
406
 
576
  $array_errors = array();
577
 
578
  if (!current_user_can('manage_options')) {
579
+ /** @noinspection ForgottenDebugOutputInspection */
580
  wp_die('You are not allowed to be on this page.');
581
  }
582
 
admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -175,10 +175,10 @@ function yasr_description_allow_vote()
175
  */
176
  function yasr_description_cstm_txt()
177
  {
178
- $name = esc_html__( 'Custom texts', 'yet-another-stars-rating' );
179
  $div_desc = '<div class="yasr-settings-description">';
180
- $description = esc_html__( 'Auto insert custom texts to show before or after the stars', 'yet-another-stars-rating' );
181
- $end_div = '.</div>';
182
  return $name . $div_desc . $description . $end_div;
183
  }
184
 
@@ -445,11 +445,13 @@ function yasr_custom_admin_footer( $text )
445
  if ( $yasr_page === 'yasr_settings_page' || $yasr_page === 'yasr_stats_page' ) {
446
  $custom_text = ' | <i>';
447
  $custom_text .= sprintf(
448
- __( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
449
- Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>', 'yet-another-stars-rating' ),
450
- 'https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=footer&utm_campaign=yasr_settings',
451
- 'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
452
- 'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
 
 
453
  );
454
  $custom_text .= '</i>';
455
  return $text . $custom_text;
@@ -460,3 +462,24 @@ function yasr_custom_admin_footer( $text )
460
 
461
  return $text;
462
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  */
176
  function yasr_description_cstm_txt()
177
  {
178
+ $name = esc_html__( 'Customize strings', 'yet-another-stars-rating' );
179
  $div_desc = '<div class="yasr-settings-description">';
180
+ $description = '<p>' . esc_html__( 'Customize YASR strings.', 'yet-another-stars-rating' ) . '</p>';
181
+ $end_div = '</div>';
182
  return $name . $div_desc . $description . $end_div;
183
  }
184
 
445
  if ( $yasr_page === 'yasr_settings_page' || $yasr_page === 'yasr_stats_page' ) {
446
  $custom_text = ' | <i>';
447
  $custom_text .= sprintf(
448
+ esc_html__( 'Thank you for using %s. Please %s rate it%s 5 stars on %s', 'yet-another-stars-rating' ),
449
+ '<a href="https://yetanotherstarsrating.com/?utm_source=wp-plugin&utm_medium=footer&utm_campaign=yasr_settings"
450
+ target="_blank">Yet Another Stars Rating</a>',
451
+ '<a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5" target="_blank">',
452
+ '</a>',
453
+ '<a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5" target="_blank">
454
+ WordPress.org</a>'
455
  );
456
  $custom_text .= '</i>';
457
  return $text . $custom_text;
462
 
463
  return $text;
464
  }
465
+
466
+ /**
467
+ * Return true if tidy is installed and version is later than 25 Nov 2017, false otherwise
468
+ *
469
+ * @author Dario Curvino <@dudo>
470
+ * @since 3.0.5
471
+ * @return bool
472
+ */
473
+ function yasr_is_tidy_installed()
474
+ {
475
+
476
+ if ( extension_loaded( 'tidy' ) ) {
477
+ $tidy_release_date = strtotime( tidy_get_release() );
478
+ $tidy_working_release_date = strtotime( '2017/11/25' );
479
+ if ( $tidy_release_date >= $tidy_working_release_date ) {
480
+ return true;
481
+ }
482
+ }
483
+
484
+ return false;
485
+ }
admin/settings/yasr-settings-page.php CHANGED
@@ -23,6 +23,7 @@ if (!defined('ABSPATH')) {
23
  } // Exit if accessed directly
24
 
25
  if (!current_user_can('manage_options')) {
 
26
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
27
  }
28
 
23
  } // Exit if accessed directly
24
 
25
  if (!current_user_can('manage_options')) {
26
+ /** @noinspection ForgottenDebugOutputInspection */
27
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
28
  }
29
 
admin/settings/yasr-stats-page.php CHANGED
@@ -23,6 +23,7 @@ if (!defined('ABSPATH')) {
23
  } // Exit if accessed directly
24
 
25
  if (!current_user_can('manage_options')) {
 
26
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
27
  }
28
 
23
  } // Exit if accessed directly
24
 
25
  if (!current_user_can('manage_options')) {
26
+ /** @noinspection ForgottenDebugOutputInspection */
27
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
28
  }
29
 
admin/yasr-admin-functions.php CHANGED
@@ -175,6 +175,7 @@ function yasr_add_pages() {
175
  // Settings Page Content
176
  function yasr_settings_page_callback() {
177
  if (!current_user_can('manage_options')) {
 
178
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
179
  }
180
 
@@ -184,6 +185,7 @@ function yasr_settings_page_callback() {
184
 
185
  function yasr_stats_page_callback() {
186
  if (!current_user_can('manage_options')) {
 
187
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
188
  }
189
 
@@ -192,6 +194,7 @@ function yasr_stats_page_callback() {
192
 
193
  function yasr_pricing_page_callback() {
194
  if (!current_user_can('manage_options')) {
 
195
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
196
  }
197
 
175
  // Settings Page Content
176
  function yasr_settings_page_callback() {
177
  if (!current_user_can('manage_options')) {
178
+ /** @noinspection ForgottenDebugOutputInspection */
179
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
180
  }
181
 
185
 
186
  function yasr_stats_page_callback() {
187
  if (!current_user_can('manage_options')) {
188
+ /** @noinspection ForgottenDebugOutputInspection */
189
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
190
  }
191
 
194
 
195
  function yasr_pricing_page_callback() {
196
  if (!current_user_can('manage_options')) {
197
+ /** @noinspection ForgottenDebugOutputInspection */
198
  wp_die(__('You do not have sufficient permissions to access this page.', 'yet-another-stars-rating'));
199
  }
200
 
includes/classes/YasrDatabaseRatings.php CHANGED
@@ -82,6 +82,7 @@ class YasrDatabaseRatings {
82
  * array(
83
  * 'number_of_votes' = (int)$user_votes->number_of_votes;
84
  * 'sum_votes' = (int)$user_votes->sum_votes;
 
85
  * )
86
  */
87
  public static function getVisitorVotes ($post_id = false) {
82
  * array(
83
  * 'number_of_votes' = (int)$user_votes->number_of_votes;
84
  * 'sum_votes' = (int)$user_votes->sum_votes;
85
+ * 'average' = (int)average result
86
  * )
87
  */
88
  public static function getVisitorVotes ($post_id = false) {
includes/classes/YasrDefineOptions.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>
19
+ */
20
+
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
+ } // Exit if accessed directly
24
+
25
+ /**
26
+ * @author Dario Curvino <@dudo>
27
+ * @since 3.0.5
28
+ * Class YasrDefineOptions
29
+ */
30
+ class YasrDefineOptions {
31
+
32
+ /**
33
+ * Defines for general settings tab
34
+ *
35
+ * @author Dario Curvino <@dudo>
36
+ * @since 3.0.5
37
+ *
38
+ * @param $yasr_general_settings
39
+ */
40
+ public function generalSettings($yasr_general_settings) {
41
+ if(isset($yasr_general_settings['auto_insert_enabled'])) {
42
+ define('YASR_AUTO_INSERT_ENABLED', (int)$yasr_general_settings['auto_insert_enabled']);
43
+ } else {
44
+ define('YASR_AUTO_INSERT_ENABLED', 0);
45
+ }
46
+
47
+ if (YASR_AUTO_INSERT_ENABLED === 1) {
48
+ define('YASR_AUTO_INSERT_WHAT', $yasr_general_settings['auto_insert_what']);
49
+ define('YASR_AUTO_INSERT_WHERE', $yasr_general_settings['auto_insert_where']);
50
+ define('YASR_AUTO_INSERT_ALIGN', $yasr_general_settings['auto_insert_align']);
51
+ define('YASR_AUTO_INSERT_SIZE', $yasr_general_settings['auto_insert_size']);
52
+ define('YASR_AUTO_INSERT_EXCLUDE_PAGES', $yasr_general_settings['auto_insert_exclude_pages']);
53
+ define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', $yasr_general_settings['auto_insert_custom_post_only']);
54
+ } else {
55
+ define('YASR_AUTO_INSERT_WHAT', null);
56
+ define('YASR_AUTO_INSERT_WHERE', null);
57
+ define('YASR_AUTO_INSERT_ALIGN', null);
58
+ define('YASR_AUTO_INSERT_SIZE', null);
59
+ define('YASR_AUTO_INSERT_EXCLUDE_PAGES', null);
60
+ define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', null);
61
+ }
62
+
63
+ define('YASR_STARS_TITLE', $yasr_general_settings['stars_title']);
64
+
65
+ if (YASR_STARS_TITLE === 'yes') {
66
+ define('YASR_STARS_TITLE_WHAT', $yasr_general_settings['stars_title_what']);
67
+ define('YASR_STARS_TITLE_EXCLUDE_PAGES', $yasr_general_settings['stars_title_exclude_pages']);
68
+ define('YASR_STARS_TITLE_WHERE', $yasr_general_settings['stars_title_where']);
69
+ } else {
70
+ define('YASR_STARS_TITLE_WHAT', null);
71
+ define('YASR_STARS_TITLE_EXCLUDE_PAGES', null);
72
+ define('YASR_STARS_TITLE_WHERE', null);
73
+ }
74
+
75
+ define('YASR_SHOW_OVERALL_IN_LOOP', $yasr_general_settings['show_overall_in_loop']);
76
+ define('YASR_SHOW_VISITOR_VOTES_IN_LOOP', $yasr_general_settings['show_visitor_votes_in_loop']);
77
+ define('YASR_VISITORS_STATS', $yasr_general_settings['visitors_stats']);
78
+ define('YASR_ALLOWED_USER', $yasr_general_settings['allowed_user']);
79
+
80
+ //custom texts
81
+ define('YASR_TEXT_BEFORE_OVERALL', $yasr_general_settings['text_before_overall']);
82
+ define('YASR_TEXT_BEFORE_VR', $yasr_general_settings['text_before_visitor_rating']);
83
+ define('YASR_TEXT_AFTER_VR', $yasr_general_settings['text_after_visitor_rating']);
84
+ define('YASR_TEXT_RATING_SAVED', $yasr_general_settings['custom_text_rating_saved']);
85
+ define('YASR_TEXT_RATING_UPDATED', $yasr_general_settings['custom_text_rating_updated']);
86
+ define('YASR_TEXT_USER_VOTED', $yasr_general_settings['custom_text_user_voted']);
87
+ define('YASR_TEXT_MUST_SIGN_IN', $yasr_general_settings['custom_text_must_sign_in']);
88
+ //end custom texts
89
+
90
+ define('YASR_ENABLE_IP', $yasr_general_settings['enable_ip']);
91
+ define('YASR_ITEMTYPE', $yasr_general_settings['snippet_itemtype']);
92
+ define('YASR_PUBLISHER_TYPE', $yasr_general_settings['publisher']);
93
+ define('YASR_PUBLISHER_NAME', $yasr_general_settings['publisher_name']);
94
+
95
+ if (isset($yasr_general_settings['publisher_logo'])
96
+ && (filter_var($yasr_general_settings['publisher_logo'], FILTER_VALIDATE_URL) !== false)) {
97
+ define('YASR_PUBLISHER_LOGO', $yasr_general_settings['publisher_logo']);
98
+ } else {
99
+ define('YASR_PUBLISHER_LOGO', get_site_icon_url());
100
+ }
101
+
102
+ define('YASR_ENABLE_AJAX', $yasr_general_settings['enable_ajax']);
103
+ }
104
+
105
+ /**
106
+ * Defines for "Aspect & Stlyes" tab
107
+ *
108
+ * @author Dario Curvino <@dudo>
109
+ * @since 3.0.5
110
+ *
111
+ * @param $style_options
112
+ */
113
+ public function styleSettings($style_options) {
114
+ //Get stored style options
115
+ //To better support php version < 7, I can't use an array into define
116
+ //Also, I can't use const here, because it only works with primitive values
117
+ //https://stackoverflow.com/questions/2447791/php-define-vs-const
118
+ define('YASR_STYLE_OPTIONS', json_encode($style_options));
119
+
120
+ define('YASR_STARS_SET', $style_options['stars_set_free']);
121
+ define('YASR_SCHEME_COLOR', $style_options['scheme_color_multiset']);
122
+ define('YASR_CUSTOM_CSS_RULES', $style_options['textarea']);
123
+ }
124
+
125
+ /**
126
+ * Defines for MultiSet options
127
+ *
128
+ * @author Dario Curvino <@dudo>
129
+ * @since 3.0.5
130
+ *
131
+ * @param $multi_set_options
132
+ */
133
+ public function multisetSettings($multi_set_options) {
134
+ define('YASR_MULTI_SHOW_AVERAGE', $multi_set_options['show_average']);
135
+ }
136
+
137
+ /**
138
+ * Do these defines on plugins_loaded
139
+ *
140
+ * @author Dario Curvino <@dudo>
141
+ * @since 3.0.5
142
+ */
143
+ public function onPluginsLoaded() {
144
+ add_action('plugins_loaded', static function () {
145
+ define('YASR_FIRST_SETID', YasrMultiSetData::returnFirstSetId());
146
+ define('YASR_CATCH_INFINITE_SCROLL_INSTALLED', yasr_is_catch_infinite_sroll_installed());
147
+ });
148
+ }
149
+
150
+ /**
151
+ * All the other defines
152
+ *
153
+ * @author Dario Curvino <@dudo>
154
+ * @since 3.0.5
155
+ */
156
+ public function misc() {
157
+ //Text for button in settings pages
158
+ $save_settings_text = esc_html__('Save All Settings', 'yet-another-stars-rating');
159
+ define('YASR_SAVE_All_SETTINGS_TEXT', $save_settings_text);
160
+ }
161
+ }
includes/classes/YasrIncludesFilters.php CHANGED
@@ -13,21 +13,14 @@ if (!defined('ABSPATH')) {
13
  */
14
  class YasrIncludesFilters {
15
 
16
- private $yasr_stored_options = array();
17
-
18
  /**
19
  * This filters will hook for show custom texts
20
  *
21
  * @author Dario Curvino <@dudo>
22
  * @since 2.6.6
23
  *
24
- * @param $yasr_stored_options
25
  */
26
- public function filterCustomTexts($yasr_stored_options) {
27
- if(is_array($yasr_stored_options)) {
28
- $this->yasr_stored_options = $yasr_stored_options;
29
- }
30
-
31
  add_filter('yasr_cstm_text_before_overall', array($this, 'filterTextOverall'), 10);
32
  add_filter('yasr_cstm_text_before_vv', array($this, 'filterTextVVBefore'), 10, 3);
33
  add_filter('yasr_cstm_text_after_vv', array($this, 'filterTextVVAfter'), 10, 3);
@@ -75,13 +68,7 @@ class YasrIncludesFilters {
75
  * @return string|string[]
76
  */
77
  public function filterTextOverall ($overall_rating) {
78
- //no need to escape, it is done later when string is printed
79
- if(array_key_exists('text_before_overall', $this->yasr_stored_options)) {
80
- $custom_text = $this->yasr_stored_options['text_before_overall'];
81
- } else {
82
- $custom_text = '';
83
- }
84
- return str_replace('%rating%', $overall_rating, $custom_text);
85
  }
86
 
87
  /**
@@ -98,12 +85,7 @@ class YasrIncludesFilters {
98
  */
99
  public function filterTextVVBefore ($number_of_votes, $average_rating, $unique_id) {
100
  //no need to escape, it is done later when string is printed
101
- if(array_key_exists('text_before_visitor_rating', $this->yasr_stored_options)) {
102
- $custom_text = $this->yasr_stored_options['text_before_visitor_rating'];
103
- } else {
104
- $custom_text = '';
105
- }
106
- return $this->strReplaceInput($custom_text, $number_of_votes, $average_rating, $unique_id);
107
  }
108
 
109
  /**
@@ -119,32 +101,20 @@ class YasrIncludesFilters {
119
  * @return string|string[]
120
  */
121
  public function filterTextVVAfter ($number_of_votes, $average_rating, $unique_id) {
122
- //no need to escape, it is done later when string is printed
123
- if(array_key_exists('text_after_visitor_rating', $this->yasr_stored_options)) {
124
- $custom_text = '<span id="yasr-vv-text-container-'.$unique_id.'" class="yasr-vv-text-container">';
125
- $custom_text .= $this->yasr_stored_options['text_after_visitor_rating'];
126
- $custom_text .= '</span>';
127
- } else {
128
- $custom_text = '';
129
- }
130
  return $this->strReplaceInput($custom_text, $number_of_votes, $average_rating, $unique_id);
131
  }
132
 
133
  /**
134
  * @author Dario Curvino <@dudo>
135
  * @since 2.9.5
136
- * @param $rating_saved
137
  *
138
  * @return mixed
139
  */
140
  public function filterTextRatingSaved() {
141
- if(array_key_exists('custom_text_rating_saved', $this->yasr_stored_options)) {
142
- //no need to escape, it is done later when string is printed
143
- $custom_text = $this->yasr_stored_options['custom_text_rating_saved'];
144
- } else {
145
- $custom_text = '';
146
- }
147
- return $custom_text;
148
  }
149
 
150
  /**
@@ -154,13 +124,7 @@ class YasrIncludesFilters {
154
  * @return mixed
155
  */
156
  public function filterTextRatingUpdated() {
157
- if(array_key_exists('custom_text_rating_updated', $this->yasr_stored_options)) {
158
- //no need to escape, it is done later when string is printed
159
- $custom_text = $this->yasr_stored_options['custom_text_rating_updated'];
160
- } else {
161
- $custom_text = '';
162
- }
163
- return $custom_text;
164
  }
165
 
166
  /**
@@ -171,13 +135,7 @@ class YasrIncludesFilters {
171
  * @return array|string|string[]
172
  */
173
  public function filterTextAlreadyVoted ($rating) {
174
- //no need to escape, it is done later when string is printed
175
- if(array_key_exists('custom_text_user_voted', $this->yasr_stored_options)) {
176
- $custom_text = $this->yasr_stored_options['custom_text_user_voted'];
177
- } else {
178
- $custom_text = '';
179
- }
180
- return str_replace('%rating%', $rating, $custom_text);
181
  }
182
 
183
  /**
@@ -187,13 +145,7 @@ class YasrIncludesFilters {
187
  * @return mixed|string|void
188
  */
189
  public function filterTextMustSignIn () {
190
- //no need to escape, it is done later when string is printed
191
- if(array_key_exists('custom_text_must_sign_in', $this->yasr_stored_options)) {
192
- $custom_text = $this->yasr_stored_options['custom_text_must_sign_in'];
193
- } else {
194
- $custom_text = '';
195
- }
196
- return $custom_text;
197
  }
198
 
199
  /**
13
  */
14
  class YasrIncludesFilters {
15
 
 
 
16
  /**
17
  * This filters will hook for show custom texts
18
  *
19
  * @author Dario Curvino <@dudo>
20
  * @since 2.6.6
21
  *
 
22
  */
23
+ public function filterCustomTexts() {
 
 
 
 
24
  add_filter('yasr_cstm_text_before_overall', array($this, 'filterTextOverall'), 10);
25
  add_filter('yasr_cstm_text_before_vv', array($this, 'filterTextVVBefore'), 10, 3);
26
  add_filter('yasr_cstm_text_after_vv', array($this, 'filterTextVVAfter'), 10, 3);
68
  * @return string|string[]
69
  */
70
  public function filterTextOverall ($overall_rating) {
71
+ return str_replace('%rating%', $overall_rating, YASR_TEXT_BEFORE_OVERALL);
 
 
 
 
 
 
72
  }
73
 
74
  /**
85
  */
86
  public function filterTextVVBefore ($number_of_votes, $average_rating, $unique_id) {
87
  //no need to escape, it is done later when string is printed
88
+ return $this->strReplaceInput(YASR_TEXT_BEFORE_VR, $number_of_votes, $average_rating, $unique_id);
 
 
 
 
 
89
  }
90
 
91
  /**
101
  * @return string|string[]
102
  */
103
  public function filterTextVVAfter ($number_of_votes, $average_rating, $unique_id) {
104
+ $custom_text = '<span id="yasr-vv-text-container-'.$unique_id.'" class="yasr-vv-text-container">';
105
+ $custom_text .= YASR_TEXT_AFTER_VR;
106
+ $custom_text .= '</span>';
 
 
 
 
 
107
  return $this->strReplaceInput($custom_text, $number_of_votes, $average_rating, $unique_id);
108
  }
109
 
110
  /**
111
  * @author Dario Curvino <@dudo>
112
  * @since 2.9.5
 
113
  *
114
  * @return mixed
115
  */
116
  public function filterTextRatingSaved() {
117
+ return YASR_TEXT_RATING_SAVED;
 
 
 
 
 
 
118
  }
119
 
120
  /**
124
  * @return mixed
125
  */
126
  public function filterTextRatingUpdated() {
127
+ return YASR_TEXT_RATING_UPDATED;
 
 
 
 
 
 
128
  }
129
 
130
  /**
135
  * @return array|string|string[]
136
  */
137
  public function filterTextAlreadyVoted ($rating) {
138
+ return str_replace('%rating%', $rating, YASR_TEXT_USER_VOTED);
 
 
 
 
 
 
139
  }
140
 
141
  /**
145
  * @return mixed|string|void
146
  */
147
  public function filterTextMustSignIn () {
148
+ return YASR_TEXT_MUST_SIGN_IN;
 
 
 
 
 
 
149
  }
150
 
151
  /**
includes/classes/YasrLogDashboardWidget.php CHANGED
@@ -34,7 +34,6 @@ class YasrLogDashboardWidget {
34
  private $num_of_pages;
35
  private $n_rows;
36
  private $log_query;
37
- private $is_ajax = false;
38
  private $button_class;
39
  private $span_loader_id;
40
  private $user_widget = false;
@@ -47,10 +46,10 @@ class YasrLogDashboardWidget {
47
  $this->page_num = (int)$_POST['pagenum'];
48
  $this->num_of_pages = (int)$_POST['totalpages'];
49
  $this->offset = (int)($this->page_num - 1) * $this->limit;
50
- $this->is_ajax = true;
51
  } else {
52
  $this->page_num = 1;
53
  }
 
54
  }
55
 
56
  /**
@@ -156,7 +155,7 @@ class YasrLogDashboardWidget {
156
  public function userWidgetShortcode () {
157
  YasrScriptsLoader::loadLogUsersFrontend();
158
 
159
- if($this->is_ajax === false) {
160
  return $this->userWidget(true);
161
  }
162
  echo $this->userWidget(true);
@@ -334,7 +333,7 @@ class YasrLogDashboardWidget {
334
  * If is_ajax === true, call die()
335
  */
336
  private function die_if_is_ajax() {
337
- if ($this->is_ajax === true) {
338
  die();
339
  }
340
  }
34
  private $num_of_pages;
35
  private $n_rows;
36
  private $log_query;
 
37
  private $button_class;
38
  private $span_loader_id;
39
  private $user_widget = false;
46
  $this->page_num = (int)$_POST['pagenum'];
47
  $this->num_of_pages = (int)$_POST['totalpages'];
48
  $this->offset = (int)($this->page_num - 1) * $this->limit;
 
49
  } else {
50
  $this->page_num = 1;
51
  }
52
+
53
  }
54
 
55
  /**
155
  public function userWidgetShortcode () {
156
  YasrScriptsLoader::loadLogUsersFrontend();
157
 
158
+ if(wp_doing_ajax() === false) {
159
  return $this->userWidget(true);
160
  }
161
  echo $this->userWidget(true);
333
  * If is_ajax === true, call die()
334
  */
335
  private function die_if_is_ajax() {
336
+ if (wp_doing_ajax()) {
337
  die();
338
  }
339
  }
includes/classes/YasrScriptsLoader.php CHANGED
@@ -7,6 +7,101 @@
7
  */
8
  class YasrScriptsLoader {
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  /**
11
  * This function enqueue the js scripts required on both admin and frontend
12
  *
@@ -19,13 +114,13 @@ class YasrScriptsLoader {
19
  wp_enqueue_script(
20
  'yasr-global-functions',
21
  YASR_JS_DIR_INCLUDES . 'yasr-globals.js',
22
- 'yasr-global-data',
23
  YASR_VERSION_NUM,
24
  true
25
  );
26
 
27
  if (defined('YASR_CATCH_INFINITE_SCROLL_INSTALLED') && YASR_CATCH_INFINITE_SCROLL_INSTALLED === true) {
28
- $array_dep = array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-global-data', 'wp-element');
29
 
30
  //laod tippy only if the shortcode has loaded it
31
  $tippy_loaded = wp_script_is('tippy');
@@ -45,6 +140,59 @@ class YasrScriptsLoader {
45
 
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  /**
49
  * Enqueue visitorVotes.js file
50
  *
@@ -52,7 +200,7 @@ class YasrScriptsLoader {
52
  * @since 2.8.5
53
  */
54
  public static function loadVVJs() {
55
- $array_dep = array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-global-data');
56
  $tippy_loaded = wp_script_is('tippy');
57
 
58
  if ($tippy_loaded) {
@@ -78,7 +226,7 @@ class YasrScriptsLoader {
78
  wp_enqueue_script(
79
  'yasr-ov-multi',
80
  YASR_JS_DIR_INCLUDES . 'shortcodes/overall-multiset.js',
81
- array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-global-data'),
82
  YASR_VERSION_NUM,
83
  true
84
  );
@@ -94,7 +242,7 @@ class YasrScriptsLoader {
94
  wp_enqueue_script(
95
  'yasr-rankings',
96
  YASR_JS_DIR_INCLUDES . 'shortcodes/rankings.js',
97
- array('jquery', 'yasr-global-functions', 'wp-i18n', 'wp-element', 'yasr-global-data'),
98
  YASR_VERSION_NUM,
99
  true
100
  );
7
  */
8
  class YasrScriptsLoader {
9
 
10
+ /**
11
+ * @author Dario Curvino <@dudo>
12
+ * @since 3.0.5
13
+ */
14
+ public function loadRequiredScripts() {
15
+ //Adds window.var needed in both admin and public
16
+ add_action('wp_enqueue_scripts', array($this, 'loadWindowVar'), 11);
17
+ add_action('admin_enqueue_scripts', array($this, 'loadWindowVar'), 11);
18
+
19
+ //Adds css needed in both admin and public
20
+ add_action('wp_enqueue_scripts', array($this, 'loadTableCss'), 11);
21
+ add_action('admin_enqueue_scripts', array($this, 'loadTableCss'), 11);
22
+
23
+ add_action('yasr_add_front_script_css', array($this, 'loadRtlSupport'));
24
+ add_action('yasr_add_admin_scripts_end', array($this, 'loadRtlSupport'));
25
+
26
+ /*** Css rules for stars set, from version 1.2.7
27
+ * Here I use add_action instead of directly use wp_add_inline_style so I can
28
+ * use remove_action if needed (e.g. Yasr Stylish)
29
+ ***/
30
+ add_action('yasr_add_front_script_css', array($this, 'loadCssStarsSet'));
31
+ add_action('yasr_add_admin_scripts_end', array($this, 'loadCssStarsSet'));
32
+ }
33
+
34
+ /**
35
+ * Helper function that load window.var required by YASR
36
+ *
37
+ * @author Dario Curvino <@dudo>
38
+ * @since 3.0.5
39
+ */
40
+ public function loadWindowVar() {
41
+ //This is required to use wp_localize_script without dependency
42
+ //https://wordpress.stackexchange.com/a/311279/48442
43
+ wp_register_script('yasr-window-var', '', array(), '', true);
44
+ wp_enqueue_script('yasr-window-var');
45
+
46
+ $yasr_visitor_votes_loader =
47
+ '<div id="loader-visitor-rating" style="display: inline-block">&nbsp; '.
48
+ '<img src="' . esc_url(YASR_IMG_DIR . 'loader.gif').'"
49
+ title="yasr-loader" alt="yasr-loader" height="16" width="16">'.
50
+ '</div>';
51
+
52
+
53
+ $yasr_window_var = array(
54
+ 'siteUrl' => site_url(),
55
+ 'adminUrl' => admin_url(), //keep this for pricing page
56
+ 'ajaxurl' => admin_url('admin-ajax.php'),
57
+ 'visitorStatsEnabled' => YASR_VISITORS_STATS,
58
+ 'ajaxEnabled' => YASR_ENABLE_AJAX,
59
+ 'loaderHtml' => $yasr_visitor_votes_loader,
60
+ 'loaderUrl' => esc_url(YASR_IMG_DIR . 'loader.gif'),
61
+ 'isUserLoggedIn' => json_encode(is_user_logged_in()),
62
+ 'isRtl' => json_encode(is_rtl())
63
+ );
64
+
65
+ //check if wp_localize_script has already run before
66
+ //since version 2.9.8 wp_localize_script is used again instead of wp_add_inline_script.
67
+ //For some reasons, wp_add_inline_script simply didn't run in some cases
68
+ // (e.g. https://wordpress.org/support/topic/yellow-star-not-appear/)
69
+ if(!defined('YASR_GLOBAL_DATA_EXISTS')) {
70
+ wp_localize_script(
71
+ 'yasr-window-var',
72
+ 'yasrWindowVar',
73
+ $yasr_window_var
74
+ );
75
+
76
+ //use a constant to be sure that yasrWindowVar is not loaded twice
77
+ define ('YASR_GLOBAL_DATA_EXISTS', true);
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Load Multiset and ranking css
83
+ *
84
+ * @author Dario Curvino <@dudo>
85
+ * @since 3.0.5
86
+ */
87
+ public function loadTableCss () {
88
+ $yasr_multiset_theme_handle = 'yasrcsslightscheme';
89
+ $yasr_multiset_theme = 'yasr-table-light.css';
90
+
91
+ //default css is the light one
92
+ if (YASR_SCHEME_COLOR === 'dark') {
93
+ $yasr_multiset_theme_handle = 'yasrcssdarkscheme';
94
+ $yasr_multiset_theme = 'yasr-table-dark.css';
95
+ }
96
+
97
+ wp_enqueue_style(
98
+ $yasr_multiset_theme_handle,
99
+ YASR_CSS_DIR_INCLUDES . $yasr_multiset_theme,
100
+ '',
101
+ YASR_VERSION_NUM
102
+ );
103
+ }
104
+
105
  /**
106
  * This function enqueue the js scripts required on both admin and frontend
107
  *
114
  wp_enqueue_script(
115
  'yasr-global-functions',
116
  YASR_JS_DIR_INCLUDES . 'yasr-globals.js',
117
+ 'yasr-window-var',
118
  YASR_VERSION_NUM,
119
  true
120
  );
121
 
122
  if (defined('YASR_CATCH_INFINITE_SCROLL_INSTALLED') && YASR_CATCH_INFINITE_SCROLL_INSTALLED === true) {
123
+ $array_dep = array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-window-var', 'wp-element');
124
 
125
  //laod tippy only if the shortcode has loaded it
126
  $tippy_loaded = wp_script_is('tippy');
140
 
141
  }
142
 
143
+
144
+ /**
145
+ * Rtl support
146
+ *
147
+ * @author Dario Curvino <@dudo>
148
+ */
149
+ public function loadRtlSupport() {
150
+ if (is_rtl()) {
151
+ $yasr_rtl_css = '.yasr-star-rating .yasr-star-value {
152
+ -moz-transform: scaleX(-1);
153
+ -o-transform: scaleX(-1);
154
+ -webkit-transform: scaleX(-1);
155
+ transform: scaleX(-1);
156
+ filter: FlipH;
157
+ -ms-filter: "FlipH";
158
+ right: 0;
159
+ left: auto;
160
+ }';
161
+
162
+ wp_add_inline_style('yasrcss', $yasr_rtl_css);
163
+ }
164
+ }
165
+
166
+ /**
167
+ * Load inline css for star set
168
+ *
169
+ * @author Dario Curvino <@dudo>
170
+ */
171
+ public function loadCssStarsSet() {
172
+ //if star selected is "rater", select the images
173
+ if (YASR_STARS_SET === 'rater') {
174
+ $star_grey = YASR_IMG_DIR . 'star_0.svg';
175
+ $star_yellow = YASR_IMG_DIR . 'star_1.svg';
176
+ } elseif (YASR_STARS_SET === 'rater-oxy') {
177
+ $star_grey = YASR_IMG_DIR . 'star_oxy_0.svg';
178
+ $star_yellow = YASR_IMG_DIR . 'star_oxy_1.svg';
179
+ } //by default, use the one provided by Yasr
180
+ else {
181
+ $star_grey = YASR_IMG_DIR . 'star_2.svg';
182
+ $star_yellow = YASR_IMG_DIR . 'star_3.svg';
183
+ }
184
+
185
+ $yasr_st_css = "
186
+ .yasr-star-rating {
187
+ background-image: url('".esc_url($star_grey)."');
188
+ }
189
+ .yasr-star-rating .yasr-star-value {
190
+ background: url('".esc_url($star_yellow)."') ;
191
+ }";
192
+
193
+ wp_add_inline_style('yasrcss', $yasr_st_css);
194
+ }
195
+
196
  /**
197
  * Enqueue visitorVotes.js file
198
  *
200
  * @since 2.8.5
201
  */
202
  public static function loadVVJs() {
203
+ $array_dep = array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-window-var');
204
  $tippy_loaded = wp_script_is('tippy');
205
 
206
  if ($tippy_loaded) {
226
  wp_enqueue_script(
227
  'yasr-ov-multi',
228
  YASR_JS_DIR_INCLUDES . 'shortcodes/overall-multiset.js',
229
+ array('jquery', 'yasr-global-functions', 'wp-i18n', 'yasr-window-var'),
230
  YASR_VERSION_NUM,
231
  true
232
  );
242
  wp_enqueue_script(
243
  'yasr-rankings',
244
  YASR_JS_DIR_INCLUDES . 'shortcodes/rankings.js',
245
+ array('jquery', 'yasr-global-functions', 'wp-i18n', 'wp-element', 'yasr-window-var'),
246
  YASR_VERSION_NUM,
247
  true
248
  );
includes/classes/YasrSettingsValues.php CHANGED
@@ -11,6 +11,7 @@ class YasrSettingsValues {
11
 
12
  /**
13
  * Returns YASR General Settings
 
14
  *
15
  * @author Dario Curvino <@dudo>
16
  * @since 3.0.4
11
 
12
  /**
13
  * Returns YASR General Settings
14
+ * If general settings are not found (i.e. option deleted from database) return YASR default values
15
  *
16
  * @author Dario Curvino <@dudo>
17
  * @since 3.0.4
includes/js/catch-inifite-scroll.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var t={593:(t,e,a)=>{let r;var n;a.d(e,{N:()=>C});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)}const i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,l=function(t){return"string"==typeof t&&i.test(t)};for(var c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));const d=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};function m(t){return m="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},m(t)}function y(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function g(t,e){return g=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},g(t,e)}function f(t,e){if(e&&("object"===m(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function v(t){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},v(t)}var p=wp.i18n.__,h=wp.element.render;function b(t){var e="yasr-ranking-element-"+d(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return yasrSetRaterValue(a,e,!1,.1,!0,t.rating)}})}function _(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",p("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 E(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;const e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function R(t){var e="after",a=p("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(_,{post:t.post,tableId:t.tableId,text:a}),React.createElement(b,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(b,{rating:t.post.rating,tableId:t.tableId}),React.createElement(_,{post:t.post,tableId:t.tableId,text:a}))}function k(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(E,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function w(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(k,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var I=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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&g(t,e)}(o,React.Component);var e,a,r,n,s=(r=o,n=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}}(),function(){var t,e=v(r);if(n){var a=v(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return f(this,t)});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=s.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=o,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(t)}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(e),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(w,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="table-row-group",i="none",l="most",c=o,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(w,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(w,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&y(e.prototype,a),Object.defineProperty(e,"prototype",{writable:!1}),o}();function C(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);h(React.createElement(I,{source:r,tableId:a,params:n,nonce:s}),o)}}C()}},e={};function a(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,a),s.exports}a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{for(var t=wp.i18n.__,e=["yasr-rater-stars","yasr-multiset-visitors-rater"],r=0;r<e.length;r++)n(e[r]);function n(e){var a=document.getElementsByClassName(e);a.length>0&&("yasr-rater-stars"===e&&function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id,n=a.getAttribute("data-rater-starsize");yasrSetRaterValue(n,r,a)}}(a),"yasr-multiset-visitors-rater"===e&&function(e){for(var a="",r=[],n=document.getElementById("yasr-pro-multiset-review-rating"),s=0;s<e.length;s++)!function(t){if(!1===e.item(t).classList.contains("yasr-star-rating")){var s=e.item(t),o=s.id,i=s.getAttribute("data-rater-readonly"),l=s.getAttribute("data-rater-starsize");l||(l=16),i=yasrTrueFalseStringConvertion(i);yasrSetRaterValue(l,o,s,1,i,!1,(function(t,e){var o=s.getAttribute("data-rater-postid"),i=s.getAttribute("data-rater-setid"),l=s.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var c=parseInt(t);this.setRating(c),a={postid:o,setid:i,field:l,rating:c},r.push(a),n&&(n.value=JSON.stringify(r)),e()}))}}(s);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var e=this.getAttribute("data-postid"),a=this.getAttribute("data-setid"),n=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+e+"-"+a).hide(),jQuery("#yasr-loader-multiset-visitor-"+e+"-"+a).show();var s={action:"yasr_visitor_multiset_field_vote",nonce:n,post_id:e,rating:r,set_id:a};jQuery.post(yasrCommonData.ajaxurl,s).done((function(t){var r;r=(t=JSON.parse(t)).text,jQuery("#yasr-loader-multiset-visitor-"+e+"-"+a).text(r)})).fail((function(e,a,r,n){console.error(t("YASR ajax call failed. Can't save data","yet-another-stars-rating")),console.log(e)}))}))}(a))}var s=wp.i18n.__;function o(t){if(t.length>0&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rater-postid"),n=a.id,s=n.replace("yasr-visitor-votes-rater-",""),o=document.getElementById("yasr_visitor_votes_"+s),u=parseInt(a.getAttribute("data-rater-starsize")),d=a.getAttribute("data-rater-nonce"),m=a.getAttribute("data-issingular"),y="yasr-vv-votes-number-container-"+s,g="yasr-vv-average-container-"+s,f="yasr-vv-bottom-container-"+s,v="yasr-vv-loader-"+s,p=document.getElementById(y),h=document.getElementById(g),b=document.getElementById(f),_=document.getElementById(v),E=a.getAttribute("data-rating"),R=a.getAttribute("data-readonly-attribute"),k=a.getAttribute("data-rater-readonly");if(null===R&&(R=!1),R=yasrTrueFalseStringConvertion(R),k=yasrTrueFalseStringConvertion(k),!0===R&&(k=!0),"yes"===yasrCommonData.ajaxEnabled){c(_);var w={action:"yasr_load_vv",post_id:r};jQuery.get(yasrCommonData.ajaxurl,w).done((function(t){var e,a=yasrValidJson(t);if(!1===a){return c(_,!1),void l(o,"Not a valid Json Element")}if(e=!0===R||a.yasr_visitor_votes.stars_attributes.read_only,E=(E=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),E=parseFloat(E),i(u,E,r,e,n,0,d,m,p,h,_,b),!0!==R&&(l(p,a.yasr_visitor_votes.number_of_votes),l(h,E),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom)){var s=a.yasr_visitor_votes.stars_attributes.span_bottom;l(b,s)}})).fail((function(t,e,a,s){console.info("YASR ajax call failed. Showing ratings from html"),i(u,E,r,k,n,0,d,m,p,h,_,b),!0!==R&&(b.style.display="")}))}else i(u,E,r,k,n,0,d,m,p,h,_,b)}}(e)}(t),"yes"===yasrCommonData.visitorStatsEnabled)){var e=document.getElementsByClassName("yasr-dashicons-visitor-stats");e&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};"function"==typeof tippy&&tippy(s,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){if(!1!==(e=yasrValidJson(e)))return"error"===e.status?(console.error(e.text),void t.setContent(e.text)):void t.setContent(u(e));t.setContent("Error!")})).fail((function(e,a,r,n){console.log(e),t.setContent("YASR ajax call failed.")}))},onHidden:function(){r=s}})}(n)}(e)}}function i(t,e,a,r,n,s,o,i,u,d,m,y){e=parseFloat(e),r=yasrTrueFalseStringConvertion(r);var g=document.getElementById(n);c(m,!1),yasrSetRaterValue(t,n,g,1,r,e,(function(t,e){c(m,!0);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,r).done((function(t){if(!1===(t=yasrValidJson(t)))return c(m,!1),void l(y,"<span>Not a valid Json Element, rating can't be saved.</span>");var a,r="yasr-vote-".concat(t.status);"success"===t.status&&(l(u,t.number_of_votes),l(d,t.average_rating)),a='<span class="yasr-small-block-bold" id="'.concat(r,'"> ').concat(t.text," </span>"),l(y,a),c(m,!1),e()})).fail((function(t,e,a,r){console.error("YASR ajax call failed. Can't save data"),console.log(t)}))}))}function l(t,e){null!==t&&(t.innerHTML=e,t.style.display="")}function c(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a="";!0===e&&(a=yasrCommonData.loaderHtml),l(t,a)}function u(t){var e=t.medium_rating;delete t.medium_rating;for(var a=0,r=1;r<=5;r++)(1===r||t[r].n_of_votes>a)&&(a=t[r].n_of_votes);var n=Math.log(a)*Math.LOG10E+1|0,o="5%";n<=3&&(o="5%"),n>3&&n<=5&&(o="10%"),n>5&&(o="15%");var i='<div class="yasr-visitors-stats-tooltip">';i+='<span id="yasr-medium-rating-tooltip">'+e+" "+s("out of 5 stars","yet-another-stars-rating")+"</span>",i+='<div class="yasr-progress-bars-container">';for(var l=s("stars","yet-another-stars-rating"),c=0,u=0,d=5;d>0;d--)1===d&&(l=s("star","yet-another-stars-rating")),void 0!==t[d]&&(c=t[d].progressbar,u=t[d].n_of_votes),i+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(d," ").concat(l,"</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:").concat(c,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(o,' ">').concat(u,"</div>\n </div>");return i+"</div></div>"}o(document.getElementsByClassName("yasr-rater-stars-vv"));var d=a(593);jQuery(document).ajaxComplete((function(t,e,a){var r=yasrCommonData.siteUrl+"/page/";a.url.includes(r)&&(function(){for(var t=["yasr-rater-stars","yasr-multiset-visitors-rater"],e=0;e<t.length;e++)n(t[e])}(),o(document.getElementsByClassName("yasr-rater-stars-vv")),(0,d.N)())}))})()})();
1
+ (()=>{"use strict";var t={593:(t,e,a)=>{let r;var n;a.d(e,{N:()=>x});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)}const i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,l=function(t){return"string"==typeof t&&i.test(t)};for(var c=[],d=0;d<256;++d)c.push((d+256).toString(16).substr(1));const u=function(t,e,a){var r=(t=t||{}).random||(t.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){a=a||0;for(var n=0;n<16;++n)e[a+n]=r[n];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase();if(!l(a))throw TypeError("Stringified UUID is invalid");return a}(r)};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},y(t)}function m(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function g(t,e){return g=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},g(t,e)}function f(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function v(t){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},v(t)}var p=wp.i18n.__,h=wp.element.render;function b(t){var e="yasr-ranking-element-"+u(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return yasrSetRaterValue(a,e,!1,.1,!0,t.rating)}})}function _(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",p("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",p("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 E(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===r&&(r=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),r.innerHTML=t;const e=r.textContent;return r.innerHTML="",e}(t.post.title)))}function R(t){var e="after",a=p("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(_,{post:t.post,tableId:t.tableId,text:a}),React.createElement(b,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(b,{rating:t.post.rating,tableId:t.tableId}),React.createElement(_,{post:t.post,tableId:t.tableId,text:a}))}function w(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(E,{colClass:e,post:t.post}),React.createElement(R,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function k(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var I=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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&g(t,e)}(o,React.Component);var e,a,r,n,s=(r=o,n=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}}(),function(){var t,e=v(r);if(n){var a=v(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return f(this,t)});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=s.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=o,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrWindowVar.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(t)}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(e),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("start_date")&&"0"!==s.get("start_date")&&(n+="&start_date="+s.get("start_date")),null!==s.get("end_date")&&"0"!==s.get("end_date")&&(n+="&end_date="+s.get("end_date")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+o+r,yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:r},p("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},p("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},p("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},p("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,p("Post","yet-another-stars-rating")),React.createElement("th",null,p("Order By","yet-another-stars-rating"),":  ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,s="most-rated-posts-"+a,o="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(k,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,s=e.highest,o="table-row-group",i="none",l="most",c=o,d=i,u=new URLSearchParams(r);return null!==u.get("view")&&(l=u.get("view")),"highest"===l&&(c=i,d=o),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(k,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(k,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:d,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,p("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&m(e.prototype,a),Object.defineProperty(e,"prototype",{writable:!1}),o}();function x(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=JSON.parse(t.item(e).dataset.rankingNonce),o=document.getElementById(a);h(React.createElement(I,{source:r,tableId:a,params:n,nonce:s}),o)}}x()}},e={};function a(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,a),s.exports}a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{for(var t=wp.i18n.__,e=["yasr-rater-stars","yasr-multiset-visitors-rater"],r=0;r<e.length;r++)n(e[r]);function n(e){var a=document.getElementsByClassName(e);a.length>0&&("yasr-rater-stars"===e&&function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.id,n=a.getAttribute("data-rater-starsize");yasrSetRaterValue(n,r,a)}}(a),"yasr-multiset-visitors-rater"===e&&function(e){for(var a="",r=[],n=document.getElementById("yasr-pro-multiset-review-rating"),s=0;s<e.length;s++)!function(t){if(!1===e.item(t).classList.contains("yasr-star-rating")){var s=e.item(t),o=s.id,i=s.getAttribute("data-rater-readonly"),l=s.getAttribute("data-rater-starsize");l||(l=16),i=yasrTrueFalseStringConvertion(i);yasrSetRaterValue(l,o,s,1,i,!1,(function(t,e){var o=s.getAttribute("data-rater-postid"),i=s.getAttribute("data-rater-setid"),l=s.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var c=parseInt(t);this.setRating(c),a={postid:o,setid:i,field:l,rating:c},r.push(a),n&&(n.value=JSON.stringify(r)),e()}))}}(s);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var e=this.getAttribute("data-postid"),a=this.getAttribute("data-setid"),n=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+e+"-"+a).hide(),jQuery("#yasr-loader-multiset-visitor-"+e+"-"+a).show();var s=JSON.parse(yasrWindowVar.isUserLoggedIn),o={action:"yasr_visitor_multiset_field_vote",post_id:e,rating:r,set_id:a};!0===s&&Object.assign(o,{nonce:n}),jQuery.post(yasrWindowVar.ajaxurl,o).done((function(t){var r;r=(t=JSON.parse(t)).text,jQuery("#yasr-loader-multiset-visitor-"+e+"-"+a).text(r)})).fail((function(e,a,r,n){console.error(t("YASR ajax call failed. Can't save data","yet-another-stars-rating")),console.log(e)}))}))}(a))}var s=wp.i18n.__;function o(t){if(t.length>0&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var a=t.item(e),r=a.getAttribute("data-rater-postid"),n=a.id,s=n.replace("yasr-visitor-votes-rater-",""),o=document.getElementById("yasr_visitor_votes_"+s),d=parseInt(a.getAttribute("data-rater-starsize")),u=a.getAttribute("data-rater-nonce"),y=a.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+s,g="yasr-vv-average-container-"+s,f="yasr-vv-bottom-container-"+s,v="yasr-vv-loader-"+s,p=document.getElementById(m),h=document.getElementById(g),b=document.getElementById(f),_=document.getElementById(v),E=a.getAttribute("data-rating"),R=a.getAttribute("data-readonly-attribute"),w=a.getAttribute("data-rater-readonly");if(null===R&&(R=!1),R=yasrTrueFalseStringConvertion(R),w=yasrTrueFalseStringConvertion(w),!0===R&&(w=!0),"yes"===yasrWindowVar.ajaxEnabled){c(_);var k={action:"yasr_load_vv",post_id:r};jQuery.get(yasrWindowVar.ajaxurl,k).done((function(t){var e,a=yasrValidJson(t);if(!1===a){return c(_,!1),void l(o,"Not a valid Json Element")}if(e=!0===R||a.yasr_visitor_votes.stars_attributes.read_only,E=(E=a.yasr_visitor_votes.number_of_votes>0?a.yasr_visitor_votes.sum_votes/a.yasr_visitor_votes.number_of_votes:0).toFixed(1),E=parseFloat(E),i(d,E,r,e,n,0,u,y,p,h,_,b),!0!==R&&(l(p,a.yasr_visitor_votes.number_of_votes),l(h,E),!1!==a.yasr_visitor_votes.stars_attributes.span_bottom)){var s=a.yasr_visitor_votes.stars_attributes.span_bottom;l(b,s)}})).fail((function(t,e,a,s){console.info("YASR ajax call failed. Showing ratings from html"),i(d,E,r,w,n,0,u,y,p,h,_,b),!0!==R&&(b.style.display="")}))}else i(d,E,r,w,n,0,u,y,p,h,_,b)}}(e)}(t),"yes"===yasrWindowVar.visitorStatsEnabled)){var e=document.getElementsByClassName("yasr-dashicons-visitor-stats");e&&function(t){for(var e,a,r=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color")),a&&(document.getElementById(t.item(n).id).style.fill=a);var i={action:"yasr_stats_visitors_votes",post_id:o};"function"==typeof tippy&&tippy(s,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){s!==r&&jQuery.post(yasrWindowVar.ajaxurl,i,(function(e){if(!1!==(e=yasrValidJson(e)))return"error"===e.status?(console.error(e.text),void t.setContent(e.text)):void t.setContent(d(e));t.setContent("Error!")})).fail((function(e,a,r,n){console.log(e),t.setContent("YASR ajax call failed.")}))},onHidden:function(){r=s}})}(n)}(e)}}function i(t,e,a,r,n,s,o,i,d,u,y,m){e=parseFloat(e),r=yasrTrueFalseStringConvertion(r);var g=document.getElementById(n),f=JSON.parse(yasrWindowVar.isUserLoggedIn);c(y,!1),yasrSetRaterValue(t,n,g,1,r,e,(function(t,e){c(y,!0);var r={action:"yasr_send_visitor_rating",rating:t,post_id:a,is_singular:i};!0===f&&Object.assign(r,{nonce_visitor:o}),this.setRating(t),this.disable(),jQuery.post(yasrWindowVar.ajaxurl,r).done((function(t){if(!1===(t=yasrValidJson(t)))return c(y,!1),void l(m,"<span>Not a valid Json Element, rating can't be saved.</span>");var a,r="yasr-vote-".concat(t.status);"success"===t.status&&(l(d,t.number_of_votes),l(u,t.average_rating)),a='<span class="yasr-small-block-bold" id="'.concat(r,'"> ').concat(t.text," </span>"),l(m,a),c(y,!1),e()})).fail((function(t,e,a,r){console.error("YASR ajax call failed. Can't save data"),console.log(t)}))}))}function l(t,e){null!==t&&(t.innerHTML=e,t.style.display="")}function c(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a="";!0===e&&(a=yasrWindowVar.loaderHtml),l(t,a)}function d(t){var e=t.medium_rating;delete t.medium_rating;for(var a=0,r=1;r<=5;r++)(1===r||t[r].n_of_votes>a)&&(a=t[r].n_of_votes);var n=Math.log(a)*Math.LOG10E+1|0,o="5%";n<=3&&(o="5%"),n>3&&n<=5&&(o="10%"),n>5&&(o="15%");var i='<div class="yasr-visitors-stats-tooltip">';i+='<span id="yasr-medium-rating-tooltip">'+e+" "+s("out of 5 stars","yet-another-stars-rating")+"</span>",i+='<div class="yasr-progress-bars-container">';for(var l=s("stars","yet-another-stars-rating"),c=0,d=0,u=5;u>0;u--)1===u&&(l=s("star","yet-another-stars-rating")),void 0!==t[u]&&(c=t[u].progressbar,d=t[u].n_of_votes),i+="<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>".concat(u," ").concat(l,"</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:").concat(c,"'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style=\"flex-basis:").concat(o,' ">').concat(d,"</div>\n </div>");return i+"</div></div>"}o(document.getElementsByClassName("yasr-rater-stars-vv"));var u=a(593);jQuery(document).ajaxComplete((function(t,e,a){var r=yasrWindowVar.siteUrl+"/page/";a.url.includes(r)&&(function(){for(var t=["yasr-rater-stars","yasr-multiset-visitors-rater"],e=0;e<t.length;e++)n(t[e])}(),o(document.getElementsByClassName("yasr-rater-stars-vv")),(0,u.N)())}))})()})();
includes/js/shortcodes/overall-multiset.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";const{__:t}=wp.i18n,e=["yasr-rater-stars","yasr-multiset-visitors-rater"];for(let t=0;t<e.length;t++)r(e[t]);function r(e){const r=document.getElementsByClassName(e);r.length>0&&("yasr-rater-stars"===e&&function(t){for(let e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){const r=t.item(e),s=r.id,a=r.getAttribute("data-rater-starsize");yasrSetRaterValue(a,s,r)}}(r),"yasr-multiset-visitors-rater"===e&&function(e){var r="",s=[];const a=document.getElementById("yasr-pro-multiset-review-rating");for(let t=0;t<e.length;t++)!function(t){if(!1!==e.item(t).classList.contains("yasr-star-rating"))return;let i=e.item(t),n=i.id,o=i.getAttribute("data-rater-readonly"),l=i.getAttribute("data-rater-starsize");l||(l=16),o=yasrTrueFalseStringConvertion(o);yasrSetRaterValue(l,n,i,1,o,!1,(function(t,e){const n=i.getAttribute("data-rater-postid"),o=i.getAttribute("data-rater-setid"),l=i.getAttribute("data-rater-set-field-id");t=t.toFixed(1);const u=parseInt(t);this.setRating(u),r={postid:n,setid:o,field:l,rating:u},s.push(r),a&&(a.value=JSON.stringify(s)),e()}))}(t);jQuery(".yasr-send-visitor-multiset").on("click",(function(){const e=this.getAttribute("data-postid"),r=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+e+"-"+r).hide(),jQuery("#yasr-loader-multiset-visitor-"+e+"-"+r).show();const i={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:e,rating:s,set_id:r};jQuery.post(yasrCommonData.ajaxurl,i).done((function(t){let s;s=(t=JSON.parse(t)).text,jQuery("#yasr-loader-multiset-visitor-"+e+"-"+r).text(s)})).fail((function(e,r,s,a){console.error(t("YASR ajax call failed. Can't save data","yet-another-stars-rating")),console.log(e)}))}))}(r))}})();
1
+ (()=>{"use strict";const{__:t}=wp.i18n,e=["yasr-rater-stars","yasr-multiset-visitors-rater"];for(let t=0;t<e.length;t++)r(e[t]);function r(e){const r=document.getElementsByClassName(e);r.length>0&&("yasr-rater-stars"===e&&function(t){for(let e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){const r=t.item(e),s=r.id,a=r.getAttribute("data-rater-starsize");yasrSetRaterValue(a,s,r)}}(r),"yasr-multiset-visitors-rater"===e&&function(e){var r="",s=[];const a=document.getElementById("yasr-pro-multiset-review-rating");for(let t=0;t<e.length;t++)!function(t){if(!1!==e.item(t).classList.contains("yasr-star-rating"))return;let i=e.item(t),n=i.id,o=i.getAttribute("data-rater-readonly"),l=i.getAttribute("data-rater-starsize");l||(l=16),o=yasrTrueFalseStringConvertion(o);yasrSetRaterValue(l,n,i,1,o,!1,(function(t,e){const n=i.getAttribute("data-rater-postid"),o=i.getAttribute("data-rater-setid"),l=i.getAttribute("data-rater-set-field-id");t=t.toFixed(1);const u=parseInt(t);this.setRating(u),r={postid:n,setid:o,field:l,rating:u},s.push(r),a&&(a.value=JSON.stringify(s)),e()}))}(t);jQuery(".yasr-send-visitor-multiset").on("click",(function(){const e=this.getAttribute("data-postid"),r=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+e+"-"+r).hide(),jQuery("#yasr-loader-multiset-visitor-"+e+"-"+r).show();const i=JSON.parse(yasrWindowVar.isUserLoggedIn),n={action:"yasr_visitor_multiset_field_vote",post_id:e,rating:s,set_id:r};!0===i&&Object.assign(n,{nonce:a}),jQuery.post(yasrWindowVar.ajaxurl,n).done((function(t){let s;s=(t=JSON.parse(t)).text,jQuery("#yasr-loader-multiset-visitor-"+e+"-"+r).text(s)})).fail((function(e,r,s,a){console.error(t("YASR ajax call failed. Can't save data","yet-another-stars-rating")),console.log(e)}))}))}(r))}})();
includes/js/shortcodes/rankings.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";let t;var e,a=new Uint8Array(16);function r(){if(!e&&!(e="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 e(a)}const n=/^(?:[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,o=function(t){return"string"==typeof t&&n.test(t)};for(var s=[],i=0;i<256;++i)s.push((i+256).toString(16).substr(1));const l=function(t,e,a){var n=(t=t||{}).random||(t.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){a=a||0;for(var i=0;i<16;++i)e[a+i]=n[i];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase();if(!o(a))throw TypeError("Stringified UUID is invalid");return a}(n)};function c(t){return c="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},c(t)}function u(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e){return d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},d(t,e)}function m(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}var f=wp.i18n.__,p=wp.element.render;function h(t){var e="yasr-ranking-element-"+l(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return yasrSetRaterValue(a,e,!1,.1,!0,t.rating)}})}function y(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",f("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",f("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 b(e){return React.createElement("td",{className:e.colClass},React.createElement("a",{href:e.post.link},function(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===t&&(t=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),t.innerHTML=e;const a=t.textContent;return t.innerHTML="",a}(e.post.title)))}function v(t){var e="after",a=f("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(y,{post:t.post,tableId:t.tableId,text:a}),React.createElement(h,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(h,{rating:t.post.rating,tableId:t.tableId}),React.createElement(y,{post:t.post,tableId:t.tableId,text:a}))}function R(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(b,{colClass:e,post:t.post}),React.createElement(v,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function E(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(R,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var _=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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(s,React.Component);var e,a,r,n,o=(r=s,n=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}}(),function(){var t,e=g(r);if(n){var a=g(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return m(this,t)});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=o.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrCommonData.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(t)}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(e),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("start_date")&&"0"!==o.get("start_date")&&(n+="&start_date="+o.get("start_date")),null!==o.get("end_date")&&"0"!==o.get("end_date")&&(n+="&end_date="+o.get("end_date")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+s+r,yasrCommonData.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:r},f("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},f("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},f("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},f("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,f("Post","yet-another-stars-rating")),React.createElement("th",null,f("Order By","yet-another-stars-rating"),":  ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,o="most-rated-posts-"+a,s="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,o=e.highest,s="table-row-group",i="none",l="most",c=s,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=s),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(E,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,f("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&u(e.prototype,a),Object.defineProperty(e,"prototype",{writable:!1}),s}();!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=JSON.parse(t.item(e).dataset.rankingNonce),s=document.getElementById(a);p(React.createElement(_,{source:r,tableId:a,params:n,nonce:o}),s)}}()})();
1
+ (()=>{"use strict";let t;var e,a=new Uint8Array(16);function r(){if(!e&&!(e="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 e(a)}const n=/^(?:[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,o=function(t){return"string"==typeof t&&n.test(t)};for(var s=[],i=0;i<256;++i)s.push((i+256).toString(16).substr(1));const l=function(t,e,a){var n=(t=t||{}).random||(t.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){a=a||0;for(var i=0;i<16;++i)e[a+i]=n[i];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase();if(!o(a))throw TypeError("Stringified UUID is invalid");return a}(n)};function c(t){return c="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},c(t)}function u(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e){return d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},d(t,e)}function m(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}var f=wp.i18n.__,p=wp.element.render;function h(t){var e="yasr-ranking-element-"+l(),a=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return yasrSetRaterValue(a,e,!1,.1,!0,t.rating)}})}function y(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",f("Total:","yet-another-stars-rating")," ",t.post.number_of_votes,"  ",f("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 b(e){return React.createElement("td",{className:e.colClass},React.createElement("a",{href:e.post.link},function(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===t&&(t=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),t.innerHTML=e;const a=t.textContent;return t.innerHTML="",a}(e.post.title)))}function v(t){var e="after",a=f("Rating:","yet-another-stars-rating"),r=new URLSearchParams(t.rankingParams);return null!==r.get("text_position")&&(e=r.get("text_position")),null!==r.get("custom_txt")&&(a=r.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(y,{post:t.post,tableId:t.tableId,text:a}),React.createElement(h,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(h,{rating:t.post.rating,tableId:t.tableId}),React.createElement(y,{post:t.post,tableId:t.tableId,text:a}))}function R(t){var e="",a="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",a="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",a="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(b,{colClass:e,post:t.post}),React.createElement(v,{colClass:a,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function E(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,a){var r="yasr-rankings-td-colored";return"author_ranking"===t.source&&(r="yasr-rankings-td-white"),a%2==0&&(r="yasr-rankings-td-white","author_ranking"===t.source&&(r="yasr-rankings-td-colored")),React.createElement(R,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:r})})))}var _=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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(s,React.Component);var e,a,r,n,o=(r=s,n=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}}(),function(){var t,e=g(r);if(n){var a=g(this).constructor;t=Reflect.construct(e,arguments,a)}else t=e.apply(this,arguments);return m(this,t)});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=o.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params,nonce:t.nonce},e}return e=s,(a=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),a={};if("yes"!==yasrWindowVar.ajaxEnabled)console.info("Ajax Disabled, getting data from source"),this.setState({isLoaded:!0,data:e});else if(this.state.source){var r=this.returnRestUrl();Promise.all(r.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info("Ajax Call Failed. Getting data from source"),"KO")})).then((function(t){"KO"===t?a=e:"overall_rating"===t.source||"author_multi"===t.source?a="overall_rating"===t.source?t.data_overall:t.data_mv:a[t.show]=t.data_vv})).catch((function(t){a=e,console.info(t)}))}))).then((function(e){t.setState({isLoaded:!0,data:a})})).catch((function(e){console.info(e),t.setState({isLoaded:!0,data:a})}))}else this.setState({error:"Invalid Data Source"})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",a=this.state.source,r="&nonce_rankings="+this.state.nonce,n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("start_date")&&"0"!==o.get("start_date")&&(n+="&start_date="+o.get("start_date")),null!==o.get("end_date")&&"0"!==o.get("end_date")&&(n+="&end_date="+o.get("end_date")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==a&&"author_multi"!==a||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===a||"author_multi"===a)t=[yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&source="+a+n+r];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&show=most&source="+a+n+s+r,yasrWindowVar.ajaxurl+"?action=yasr_load_rankings&show=highest&source="+a+n+i+r]}return t}},{key:"rankingTableHead",value:function(t,e){var a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:r},f("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},f("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},f("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:r,onClick:this.switchTBody.bind(this)},f("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,f("Post","yet-another-stars-rating")),React.createElement("th",null,f("Order By","yet-another-stars-rating"),":  ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,a=this.state.tableId,r="link-most-rated-posts-"+a,n="link-highest-rated-posts-"+a,o="most-rated-posts-"+a,s="highest-rated-posts-"+a,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===r&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(r),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,a=t.source,r=t.rankingParams;if("overall_rating"===a||"author_multi"===a)return React.createElement(E,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:r,show:"table-row-group",source:a});var n=e.most,o=e.highest,s="table-row-group",i="none",l="most",c=s,u=i,d=new URLSearchParams(r);return null!==d.get("view")&&(l=d.get("view")),"highest"===l&&(c=i,u=s),React.createElement(React.Fragment,null,this.rankingTableHead(a,l),React.createElement(E,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:r,show:c,source:a}),React.createElement(E,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:r,show:u,source:a}))}},{key:"render",value:function(){var t=this.state,e=t.error,a=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===a?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,f("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&u(e.prototype,a),Object.defineProperty(e,"prototype",{writable:!1}),s}();!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var a=t.item(e).id,r=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=JSON.parse(t.item(e).dataset.rankingNonce),s=document.getElementById(a);p(React.createElement(_,{source:r,tableId:a,params:n,nonce:o}),s)}}()})();
includes/js/shortcodes/visitorVotes.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";const{__:t}=wp.i18n;function e(t,e,r,o,n,i,l,d,u,y,v,c){e=parseFloat(e),o=yasrTrueFalseStringConvertion(o);const m=document.getElementById(n);s(v,!1),yasrSetRaterValue(t,n,m,1,o,e,(function(t,e){s(v,!0);const o={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:l,is_singular:d};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,o).done((function(t){if(!1===(t=yasrValidJson(t)))return s(v,!1),void a(c,"<span>Not a valid Json Element, rating can't be saved.</span>");let r,o=`yasr-vote-${t.status}`;"success"===t.status&&(a(u,t.number_of_votes),a(y,t.average_rating)),r=`<span class="yasr-small-block-bold" id="${o}"> ${t.text} </span>`,a(c,r),s(v,!1),e()})).fail((function(t,e,a,s){console.error("YASR ajax call failed. Can't save data"),console.log(t)}))}))}function a(t,e){null!==t&&(t.innerHTML=e,t.style.display="")}function s(t,e=!0){let s="";!0===e&&(s=yasrCommonData.loaderHtml),a(t,s)}function r(e){const a=e.medium_rating;delete e.medium_rating;let s=0;for(let t=1;t<=5;t++)(1===t||e[t].n_of_votes>s)&&(s=e[t].n_of_votes);let r=Math.log(s)*Math.LOG10E+1|0,o="5%";r<=3&&(o="5%"),r>3&&r<=5&&(o="10%"),r>5&&(o="15%");let n='<div class="yasr-visitors-stats-tooltip">';n+='<span id="yasr-medium-rating-tooltip">'+a+" "+t("out of 5 stars","yet-another-stars-rating")+"</span>",n+='<div class="yasr-progress-bars-container">';let i=t("stars","yet-another-stars-rating"),l=0,d=0;for(let a=5;a>0;a--)1===a&&(i=t("star","yet-another-stars-rating")),void 0!==e[a]&&(l=e[a].progressbar,d=e[a].n_of_votes),n+=`<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>${a} ${i}</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:${l}'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style="flex-basis:${o} ">${d}</div>\n </div>`;return n+="</div></div>",n}!function(t){if(t.length>0&&(function(t){for(let r=0;r<t.length;r++)!function(r){if(!1!==t.item(r).classList.contains("yasr-star-rating"))return;const o=t.item(r),n=o.getAttribute("data-rater-postid"),i=o.id,l=i.replace("yasr-visitor-votes-rater-",""),d=document.getElementById("yasr_visitor_votes_"+l),u=parseInt(o.getAttribute("data-rater-starsize")),y=o.getAttribute("data-rater-nonce"),v=o.getAttribute("data-issingular"),c="yasr-vv-votes-number-container-"+l,m="yasr-vv-average-container-"+l,g="yasr-vv-bottom-container-"+l,_="yasr-vv-loader-"+l,f=document.getElementById(c),p=document.getElementById(m),b=document.getElementById(g),h=document.getElementById(_);let C=o.getAttribute("data-rating"),E=o.getAttribute("data-readonly-attribute"),x=o.getAttribute("data-rater-readonly");if(null===E&&(E=!1),E=yasrTrueFalseStringConvertion(E),x=yasrTrueFalseStringConvertion(x),!0===E&&(x=!0),"yes"===yasrCommonData.ajaxEnabled){s(h);let t={action:"yasr_load_vv",post_id:n};jQuery.get(yasrCommonData.ajaxurl,t).done((function(t){let r,o=yasrValidJson(t);if(!1===o){let t="Not a valid Json Element";return s(h,!1),void a(d,t)}if(r=!0===E||o.yasr_visitor_votes.stars_attributes.read_only,C=o.yasr_visitor_votes.number_of_votes>0?o.yasr_visitor_votes.sum_votes/o.yasr_visitor_votes.number_of_votes:0,C=C.toFixed(1),C=parseFloat(C),e(u,C,n,r,i,0,y,v,f,p,h,b),!0!==E&&(a(f,o.yasr_visitor_votes.number_of_votes),a(p,C),!1!==o.yasr_visitor_votes.stars_attributes.span_bottom)){let t=o.yasr_visitor_votes.stars_attributes.span_bottom;a(b,t)}})).fail((function(t,a,s,r){console.info("YASR ajax call failed. Showing ratings from html"),e(u,C,n,x,i,0,y,v,f,p,h,b),!0!==E&&(b.style.display="")}))}else e(u,C,n,x,i,0,y,v,f,p,h,b)}(r)}(t),"yes"===yasrCommonData.visitorStatsEnabled)){let t=document.getElementsByClassName("yasr-dashicons-visitor-stats");t&&function(t){let e,a,s=!1;for(let o=0;o<t.length;o++)!function(o){let n="#"+t.item(o).id,i=t.item(o).getAttribute("data-postid");0===o&&(e=document.getElementsByClassName("yasr-vv-text-container"),null!==e&&(a=window.getComputedStyle(e[0],null).getPropertyValue("color"))),a&&(document.getElementById(t.item(o).id).style.fill=a);let l={action:"yasr_stats_visitors_votes",post_id:i};"function"==typeof tippy&&tippy(n,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){n!==s&&jQuery.post(yasrCommonData.ajaxurl,l,(function(e){if(!1!==(e=yasrValidJson(e)))return"error"===e.status?(console.error(e.text),void t.setContent(e.text)):void t.setContent(r(e));t.setContent("Error!")})).fail((function(e,a,s,r){console.log(e),t.setContent("YASR ajax call failed.")}))},onHidden:function(){s=n}})}(o)}(t)}}(document.getElementsByClassName("yasr-rater-stars-vv"))})();
1
+ (()=>{"use strict";const{__:t}=wp.i18n;function e(t,e,r,n,o,i,l,d,y,u,v,c){e=parseFloat(e),n=yasrTrueFalseStringConvertion(n);const g=document.getElementById(o),_=JSON.parse(yasrWindowVar.isUserLoggedIn);a(v,!1),yasrSetRaterValue(t,o,g,1,n,e,(function(t,e){a(v,!0);let n={action:"yasr_send_visitor_rating",rating:t,post_id:r,is_singular:d};!0===_&&Object.assign(n,{nonce_visitor:l}),this.setRating(t),this.disable(),jQuery.post(yasrWindowVar.ajaxurl,n).done((function(t){if(!1===(t=yasrValidJson(t)))return a(v,!1),void s(c,"<span>Not a valid Json Element, rating can't be saved.</span>");let r,n=`yasr-vote-${t.status}`;"success"===t.status&&(s(y,t.number_of_votes),s(u,t.average_rating)),r=`<span class="yasr-small-block-bold" id="${n}"> ${t.text} </span>`,s(c,r),a(v,!1),e()})).fail((function(t,e,s,a){console.error("YASR ajax call failed. Can't save data"),console.log(t)}))}))}function s(t,e){null!==t&&(t.innerHTML=e,t.style.display="")}function a(t,e=!0){let a="";!0===e&&(a=yasrWindowVar.loaderHtml),s(t,a)}function r(e){const s=e.medium_rating;delete e.medium_rating;let a=0;for(let t=1;t<=5;t++)(1===t||e[t].n_of_votes>a)&&(a=e[t].n_of_votes);let r=Math.log(a)*Math.LOG10E+1|0,n="5%";r<=3&&(n="5%"),r>3&&r<=5&&(n="10%"),r>5&&(n="15%");let o='<div class="yasr-visitors-stats-tooltip">';o+='<span id="yasr-medium-rating-tooltip">'+s+" "+t("out of 5 stars","yet-another-stars-rating")+"</span>",o+='<div class="yasr-progress-bars-container">';let i=t("stars","yet-another-stars-rating"),l=0,d=0;for(let s=5;s>0;s--)1===s&&(i=t("star","yet-another-stars-rating")),void 0!==e[s]&&(l=e[s].progressbar,d=e[s].n_of_votes),o+=`<div class='yasr-progress-bar-row-container yasr-w3-container'>\n <div class='yasr-progress-bar-name'>${s} ${i}</div> \n <div class='yasr-single-progress-bar-container'> \n <div class='yasr-w3-border'> \n <div class='yasr-w3-amber' style='height:17px;width:${l}'></div> \n </div>\n </div> \n <div class='yasr-progress-bar-votes-count' style="flex-basis:${n} ">${d}</div>\n </div>`;return o+="</div></div>",o}!function(t){if(t.length>0&&(function(t){for(let r=0;r<t.length;r++)!function(r){if(!1!==t.item(r).classList.contains("yasr-star-rating"))return;const n=t.item(r),o=n.getAttribute("data-rater-postid"),i=n.id,l=i.replace("yasr-visitor-votes-rater-",""),d=document.getElementById("yasr_visitor_votes_"+l),y=parseInt(n.getAttribute("data-rater-starsize")),u=n.getAttribute("data-rater-nonce"),v=n.getAttribute("data-issingular"),c="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,_="yasr-vv-bottom-container-"+l,m="yasr-vv-loader-"+l,f=document.getElementById(c),p=document.getElementById(g),b=document.getElementById(_),w=document.getElementById(m);let h=n.getAttribute("data-rating"),E=n.getAttribute("data-readonly-attribute"),x=n.getAttribute("data-rater-readonly");if(null===E&&(E=!1),E=yasrTrueFalseStringConvertion(E),x=yasrTrueFalseStringConvertion(x),!0===E&&(x=!0),"yes"===yasrWindowVar.ajaxEnabled){a(w);let t={action:"yasr_load_vv",post_id:o};jQuery.get(yasrWindowVar.ajaxurl,t).done((function(t){let r,n=yasrValidJson(t);if(!1===n){let t="Not a valid Json Element";return a(w,!1),void s(d,t)}if(r=!0===E||n.yasr_visitor_votes.stars_attributes.read_only,h=n.yasr_visitor_votes.number_of_votes>0?n.yasr_visitor_votes.sum_votes/n.yasr_visitor_votes.number_of_votes:0,h=h.toFixed(1),h=parseFloat(h),e(y,h,o,r,i,0,u,v,f,p,w,b),!0!==E&&(s(f,n.yasr_visitor_votes.number_of_votes),s(p,h),!1!==n.yasr_visitor_votes.stars_attributes.span_bottom)){let t=n.yasr_visitor_votes.stars_attributes.span_bottom;s(b,t)}})).fail((function(t,s,a,r){console.info("YASR ajax call failed. Showing ratings from html"),e(y,h,o,x,i,0,u,v,f,p,w,b),!0!==E&&(b.style.display="")}))}else e(y,h,o,x,i,0,u,v,f,p,w,b)}(r)}(t),"yes"===yasrWindowVar.visitorStatsEnabled)){let t=document.getElementsByClassName("yasr-dashicons-visitor-stats");t&&function(t){let e,s,a=!1;for(let n=0;n<t.length;n++)!function(n){let o="#"+t.item(n).id,i=t.item(n).getAttribute("data-postid");0===n&&(e=document.getElementsByClassName("yasr-vv-text-container"),null!==e&&(s=window.getComputedStyle(e[0],null).getPropertyValue("color"))),s&&(document.getElementById(t.item(n).id).style.fill=s);let l={action:"yasr_stats_visitors_votes",post_id:i};"function"==typeof tippy&&tippy(o,{allowHTML:!0,content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:!0,arrowType:"round",onShow:function(t){o!==a&&jQuery.post(yasrWindowVar.ajaxurl,l,(function(e){if(!1!==(e=yasrValidJson(e)))return"error"===e.status?(console.error(e.text),void t.setContent(e.text)):void t.setContent(r(e));t.setContent("Error!")})).fail((function(e,s,a,r){console.log(e),t.setContent("YASR ajax call failed.")}))},onHidden:function(){a=o}})}(n)}(t)}}(document.getElementsByClassName("yasr-rater-stars-vv"))})();
includes/js/shortcodes/yasr-log-users-frontend.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrCommonData.ajaxurl,a,(function(a){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(a)}))})),jQuery(document).ajaxComplete((function(a,e,r){void 0!==r.data&&-1!==r.data.search("action=yasr_change_user_log_page_front")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrCommonData.ajaxurl,a,(function(a){jQuery("#yasr-user-log-container").html(a)}))}))}))}));
1
+ jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrWindowVar.ajaxurl,a,(function(a){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(a)}))})),jQuery(document).ajaxComplete((function(a,r,e){void 0!==e.data&&-1!==e.data.search("action=yasr_change_user_log_page_front")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var a={action:"yasr_change_user_log_page_front",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(yasrWindowVar.ajaxurl,a,(function(a){jQuery("#yasr-user-log-container").html(a)}))}))}))}));
includes/js/src/catch-inifite-scroll.js CHANGED
@@ -8,7 +8,7 @@ import {yasrSearchVVInDom} from "./shortcodes/visitorVotes";
8
  import {yasrDrawRankings} from "./shortcodes/ranking";
9
 
10
  jQuery( document ).ajaxComplete(function( event, xhr, settings ) {
11
- let acceptedUrl = yasrCommonData.siteUrl + '/page/';
12
  if(settings.url.includes(acceptedUrl)) {
13
  yasrCisOvMulti();
14
  yasrCisVV();
8
  import {yasrDrawRankings} from "./shortcodes/ranking";
9
 
10
  jQuery( document ).ajaxComplete(function( event, xhr, settings ) {
11
+ let acceptedUrl = yasrWindowVar.siteUrl + '/page/';
12
  if(settings.url.includes(acceptedUrl)) {
13
  yasrCisOvMulti();
14
  yasrCisVV();
includes/js/src/global_functions/rater-js-src.js CHANGED
@@ -28,7 +28,7 @@ window.raterJs = function(options) {
28
  let step = options.step || 1;
29
  let onHover = options.onHover;
30
  let onLeave = options.onLeave;
31
- let isRtl = yasrTrueFalseStringConvertion(yasrCommonData.isRtl);
32
  let rating;
33
  let myRating;
34
  let elem = options.element;
28
  let step = options.step || 1;
29
  let onHover = options.onHover;
30
  let onLeave = options.onLeave;
31
+ let isRtl = yasrTrueFalseStringConvertion(yasrWindowVar.isRtl);
32
  let rating;
33
  let myRating;
34
  let elem = options.element;
includes/js/src/shortcodes/overall-multiset.js CHANGED
@@ -2,7 +2,7 @@ const { __ } = wp.i18n; // Import __() from wp.i181n
2
  const arrayClasses = ['yasr-rater-stars', 'yasr-multiset-visitors-rater'];
3
 
4
  /*** Constant used by yasr
5
- yasrCommonData (ajaxurl, isrtl)
6
  ***/
7
 
8
  for (let i=0; i<arrayClasses.length; i++) {
@@ -117,16 +117,21 @@ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
117
  jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
118
  jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
119
 
 
 
120
  const data = {
121
  action: 'yasr_visitor_multiset_field_vote',
122
- nonce: nonce,
123
  post_id: multiSetPostId,
124
  rating: ratingArray,
125
  set_id: multiSetId
126
  };
127
 
 
 
 
 
128
  //Send value to the Server
129
- jQuery.post(yasrCommonData.ajaxurl, data).done(
130
  function(response) {
131
  let responseText;
132
  response = JSON.parse(response);
2
  const arrayClasses = ['yasr-rater-stars', 'yasr-multiset-visitors-rater'];
3
 
4
  /*** Constant used by yasr
5
+ yasrWindowVar (ajaxurl, isrtl)
6
  ***/
7
 
8
  for (let i=0; i<arrayClasses.length; i++) {
117
  jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
118
  jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
119
 
120
+ const isUserLoggedIn = JSON.parse(yasrWindowVar.isUserLoggedIn);
121
+
122
  const data = {
123
  action: 'yasr_visitor_multiset_field_vote',
 
124
  post_id: multiSetPostId,
125
  rating: ratingArray,
126
  set_id: multiSetId
127
  };
128
 
129
+ if(isUserLoggedIn === true) {
130
+ Object.assign(data, {nonce: nonce});
131
+ }
132
+
133
  //Send value to the Server
134
+ jQuery.post(yasrWindowVar.ajaxurl, data).done(
135
  function(response) {
136
  let responseText;
137
  response = JSON.parse(response);
includes/js/src/shortcodes/ranking.js CHANGED
@@ -110,7 +110,7 @@ function YasrRankingTableRightColumn (props) {
110
 
111
  return (
112
  <td className={props.colClass}>
113
- <YasrCallRaterJs rating={props.post.rating} tableId={props.tableId}/>
114
  <YasrTextAfterStars post={props.post} tableId={props.tableId} text={cstText}/>
115
  </td>
116
  )
@@ -224,7 +224,7 @@ class YasrRanking extends React.Component {
224
  let data = {};
225
 
226
  //If ajax is disabled, use global value
227
- if(yasrCommonData.ajaxEnabled !== 'yes') {
228
  console.info('Ajax Disabled, getting data from source');
229
  this.setState({
230
  isLoaded: true,
@@ -353,7 +353,7 @@ class YasrRanking extends React.Component {
353
  }
354
 
355
  if(dataSource === 'author_ranking' || dataSource === 'author_multi') {
356
- urlYasrRanking = [yasrCommonData.ajaxurl + '?action=yasr_load_rankings&source=' + dataSource + cleanedQuery + nonce];
357
  }
358
  else {
359
  let requiredMost = '';
@@ -371,8 +371,8 @@ class YasrRanking extends React.Component {
371
  }
372
 
373
  urlYasrRanking = [
374
- yasrCommonData.ajaxurl + '?action=yasr_load_rankings&show=most&source=' + dataSource + cleanedQuery + requiredMost + nonce,
375
- yasrCommonData.ajaxurl + '?action=yasr_load_rankings&show=highest&source=' + dataSource + cleanedQuery + requiredHighest + nonce
376
  ];
377
 
378
  }
110
 
111
  return (
112
  <td className={props.colClass}>
113
+ <YasrCallRaterJs rating={props.post.rating} tableId={props.tableId}/>
114
  <YasrTextAfterStars post={props.post} tableId={props.tableId} text={cstText}/>
115
  </td>
116
  )
224
  let data = {};
225
 
226
  //If ajax is disabled, use global value
227
+ if(yasrWindowVar.ajaxEnabled !== 'yes') {
228
  console.info('Ajax Disabled, getting data from source');
229
  this.setState({
230
  isLoaded: true,
353
  }
354
 
355
  if(dataSource === 'author_ranking' || dataSource === 'author_multi') {
356
+ urlYasrRanking = [yasrWindowVar.ajaxurl + '?action=yasr_load_rankings&source=' + dataSource + cleanedQuery + nonce];
357
  }
358
  else {
359
  let requiredMost = '';
371
  }
372
 
373
  urlYasrRanking = [
374
+ yasrWindowVar.ajaxurl + '?action=yasr_load_rankings&show=most&source=' + dataSource + cleanedQuery + requiredMost + nonce,
375
+ yasrWindowVar.ajaxurl + '?action=yasr_load_rankings&show=highest&source=' + dataSource + cleanedQuery + requiredHighest + nonce
376
  ];
377
 
378
  }
includes/js/src/shortcodes/visitorVotes.js CHANGED
@@ -7,7 +7,7 @@ yasrSearchVVInDom(yasrRaterInDom);
7
  export function yasrSearchVVInDom(yasrRaterInDom) {
8
  if (yasrRaterInDom.length > 0) {
9
  yasrVisitorVotesFront(yasrRaterInDom);
10
- if (yasrCommonData.visitorStatsEnabled === 'yes') {
11
  let yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
12
  if (yasrStatsInDom) {
13
  yasrVvStats (yasrStatsInDom);
@@ -62,7 +62,7 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
62
  readonly = true;
63
  }
64
 
65
- if(yasrCommonData.ajaxEnabled === 'yes') {
66
  yasrLoader(loaderContainer);
67
 
68
  let data = {
@@ -70,7 +70,7 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
70
  post_id: postId,
71
  };
72
 
73
- jQuery.get(yasrCommonData.ajaxurl, data).done(
74
  function (response) {
75
  let data = yasrValidJson(response);
76
 
@@ -159,9 +159,10 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
159
  rating = parseFloat(rating);
160
 
161
  //raterjs accepts only boolean for readOnly element
162
- readonly = yasrTrueFalseStringConvertion(readonly);
163
 
164
- const elem = document.getElementById(htmlId);
 
165
 
166
  yasrLoader(loaderContainer, false);
167
 
@@ -170,19 +171,22 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
170
  yasrLoader(loaderContainer, true);
171
 
172
  //Creating an object with data to send
173
- const data = {
174
  action: 'yasr_send_visitor_rating',
175
  rating: rating,
176
  post_id: postId,
177
- nonce_visitor: nonce,
178
  is_singular: isSingular
179
  };
180
 
 
 
 
 
181
  this.setRating(rating);
182
  this.disable();
183
 
184
  //Send value to the Server
185
- jQuery.post(yasrCommonData.ajaxurl, data).done(
186
  function (response) {
187
  response = yasrValidJson(response);
188
 
@@ -239,7 +243,7 @@ function yasrLoader(loaderContainer, show=true) {
239
  let loader = '';
240
 
241
  if(show === true) {
242
- loader = yasrCommonData.loaderHtml;
243
  }
244
 
245
  yasrInnerHtml(loaderContainer, loader);
@@ -297,7 +301,7 @@ function yasrVvStats (yasrStatsInDom) {
297
  onShow: function onShow(tip) {
298
  if (htmlId !== htmlIdChecked) {
299
  //must be post or wont work
300
- jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
301
  response = yasrValidJson(response);
302
 
303
  if(response === false) {
7
  export function yasrSearchVVInDom(yasrRaterInDom) {
8
  if (yasrRaterInDom.length > 0) {
9
  yasrVisitorVotesFront(yasrRaterInDom);
10
+ if (yasrWindowVar.visitorStatsEnabled === 'yes') {
11
  let yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
12
  if (yasrStatsInDom) {
13
  yasrVvStats (yasrStatsInDom);
62
  readonly = true;
63
  }
64
 
65
+ if(yasrWindowVar.ajaxEnabled === 'yes') {
66
  yasrLoader(loaderContainer);
67
 
68
  let data = {
70
  post_id: postId,
71
  };
72
 
73
+ jQuery.get(yasrWindowVar.ajaxurl, data).done(
74
  function (response) {
75
  let data = yasrValidJson(response);
76
 
159
  rating = parseFloat(rating);
160
 
161
  //raterjs accepts only boolean for readOnly element
162
+ readonly = yasrTrueFalseStringConvertion(readonly);
163
 
164
+ const elem = document.getElementById(htmlId);
165
+ const isUserLoggedIn = JSON.parse(yasrWindowVar.isUserLoggedIn);
166
 
167
  yasrLoader(loaderContainer, false);
168
 
171
  yasrLoader(loaderContainer, true);
172
 
173
  //Creating an object with data to send
174
+ let data = {
175
  action: 'yasr_send_visitor_rating',
176
  rating: rating,
177
  post_id: postId,
 
178
  is_singular: isSingular
179
  };
180
 
181
+ if(isUserLoggedIn === true) {
182
+ Object.assign(data, {nonce_visitor: nonce});
183
+ }
184
+
185
  this.setRating(rating);
186
  this.disable();
187
 
188
  //Send value to the Server
189
+ jQuery.post(yasrWindowVar.ajaxurl, data).done(
190
  function (response) {
191
  response = yasrValidJson(response);
192
 
243
  let loader = '';
244
 
245
  if(show === true) {
246
+ loader = yasrWindowVar.loaderHtml;
247
  }
248
 
249
  yasrInnerHtml(loaderContainer, loader);
301
  onShow: function onShow(tip) {
302
  if (htmlId !== htmlIdChecked) {
303
  //must be post or wont work
304
+ jQuery.post(yasrWindowVar.ajaxurl, data, function (response) {
305
  response = yasrValidJson(response);
306
 
307
  if(response === false) {
includes/js/src/shortcodes/yasr-log-users-frontend.js CHANGED
@@ -9,7 +9,7 @@ jQuery(document).ready(function () {
9
  totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
10
 
11
  };
12
- jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
13
  jQuery('#yasr-loader-log-metabox').hide();
14
  jQuery('#yasr-user-log-container').html(response);
15
  });
@@ -35,7 +35,7 @@ jQuery(document).ready(function () {
35
  totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
36
  };
37
 
38
- jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
39
  jQuery('#yasr-user-log-container').html(response); //This will hide the loader gif too
40
  });
41
  });
9
  totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
10
 
11
  };
12
+ jQuery.post(yasrWindowVar.ajaxurl, data, function (response) {
13
  jQuery('#yasr-loader-log-metabox').hide();
14
  jQuery('#yasr-user-log-container').html(response);
15
  });
35
  totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')
36
  };
37
 
38
+ jQuery.post(yasrWindowVar.ajaxurl, data, function (response) {
39
  jQuery('#yasr-user-log-container').html(response); //This will hide the loader gif too
40
  });
41
  });
includes/js/yasr-globals.js CHANGED
@@ -1 +1 @@
1
- window.yasrTrueFalseStringConvertion=function(e){return null!=e&&""!==e||(e=!1),"true"!==e&&"1"!==e||(e=!0),"false"!==e&&"0"!==e||(e=!1),e},window.yasrValidJson=function(e){try{const t=JSON.parse(e);if(t&&"object"==typeof t)return t}catch(e){console.error("Not a valid Json Element"),console.log(e)}return!1},window.raterJs=function(e){let t=!0;if(void 0===e.element||null===e.element)return void console.info("missing rating element");if(null!==e.element&&e.element.classList.contains("yasr-star-rating"))return;if(void 0!==e.showToolTip&&(t=!!e.showToolTip),void 0!==e.step&&(e.step<=0||e.step>1))throw new Error("step must be a number between 0 and 1");let r,i,a=e.starSize||16,n=e.step||1,o=e.onHover,s=e.onLeave,l=yasrTrueFalseStringConvertion(yasrCommonData.isRtl),u=e.element;u.classList.add("yasr-star-rating");let d=document.createElement("div");d.classList.add("yasr-star-value"),d.style.backgroundSize=a+"px",u.appendChild(d),u.style.width=5*a+"px",u.style.height=a+"px",u.style.backgroundSize=a+"px";let c,f,v,m=e.rateCallback,y=!!e.readOnly,g=!1,p=e.isBusyText;if(c=void 0!==e.disableText?e.disableText:"{rating}/{maxRating}",y||(u.style.cursor="pointer"),v=void 0!==e.ratingText?e.ratingText:"{rating}/{maxRating}",e.rating)T(e.rating);else{var b=u.dataset.rating;b&&T(+b)}function w(e){if(!0===y||!0===g)return;let i;if(!0===l){let t=this.getBoundingClientRect(),r=e.pageX-t.left,a=u.offsetWidth;i=(a-r)/(a/100)}else i=e.offsetX/u.offsetWidth*100;if(i<101){if(1===n)f=Math.ceil(i/100*5);else{let e=i/100*5;for(let t=0;;t+=n)if(t>=e){f=t;break}}if(f>5&&(f=5),u.querySelector(".yasr-star-value").style.width=f/5*100+"%",t){let e=v.replace("{rating}",f);e=e.replace("{maxRating}",5),u.setAttribute("data-title",e)}"function"==typeof o&&o(f,r)}}function h(e){void 0!==r?(u.querySelector(".yasr-star-value").style.width=r/5*100+"%",u.setAttribute("data-rating",r)):(u.querySelector(".yasr-star-value").style.width="0%",u.removeAttribute("data-rating")),"function"==typeof s&&s(f,r)}function x(e){!0!==y&&!0!==g&&(void 0===m&&!1===typeof m||(g=!0,i=f,void 0===p?u.removeAttribute("data-title"):u.setAttribute("data-title",p),m.call(this,i,(function(){!1===y&&u.removeAttribute("data-title"),g=!1}))))}function S(){if(y=!0,t&&c){let e=c.replace("{rating}",r);e=e.replace("{maxRating}",5),u.setAttribute("data-title",e)}else u.removeAttribute("data-title")}function T(e){if(-1===e&&(e=void 0),"number"!=typeof e&&void 0!==e)throw new Error("Value must be a number or undefined.");e<0&&(e=0),e>5&&(e=5),r=e,u.querySelector(".yasr-star-value").style.width=e/5*100+"%",u.setAttribute("data-rating",e)}void 0===r&&(u.querySelector(".yasr-star-value").style.width="0px"),y&&S(),u.addEventListener("mousemove",w),u.addEventListener("mouseleave",h);let E={setRating:T,getRating:function(){return r},disable:S,enable:function(){y=!1,u.removeAttribute("data-title")},dispose:function(){u.removeEventListener("mousemove",w),u.removeEventListener("mouseleave",h),u.removeEventListener("click",x)}};return u.addEventListener("click",x.bind(E)),E},window.yasrSetRaterValue=function(e,t,r=!1,i=.1,a=!0,n=!1,o=!1){let s;s=r||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:s,step:i,readOnly:a,rating:n,rateCallback:o})};
1
+ window.yasrTrueFalseStringConvertion=function(e){return null!=e&&""!==e||(e=!1),"true"!==e&&"1"!==e||(e=!0),"false"!==e&&"0"!==e||(e=!1),e},window.yasrValidJson=function(e){try{const t=JSON.parse(e);if(t&&"object"==typeof t)return t}catch(e){console.error("Not a valid Json Element"),console.log(e)}return!1},window.raterJs=function(e){let t=!0;if(void 0===e.element||null===e.element)return void console.info("missing rating element");if(null!==e.element&&e.element.classList.contains("yasr-star-rating"))return;if(void 0!==e.showToolTip&&(t=!!e.showToolTip),void 0!==e.step&&(e.step<=0||e.step>1))throw new Error("step must be a number between 0 and 1");let r,i,a=e.starSize||16,n=e.step||1,o=e.onHover,s=e.onLeave,l=yasrTrueFalseStringConvertion(yasrWindowVar.isRtl),u=e.element;u.classList.add("yasr-star-rating");let d=document.createElement("div");d.classList.add("yasr-star-value"),d.style.backgroundSize=a+"px",u.appendChild(d),u.style.width=5*a+"px",u.style.height=a+"px",u.style.backgroundSize=a+"px";let c,f,v,y=e.rateCallback,m=!!e.readOnly,g=!1,p=e.isBusyText;if(c=void 0!==e.disableText?e.disableText:"{rating}/{maxRating}",m||(u.style.cursor="pointer"),v=void 0!==e.ratingText?e.ratingText:"{rating}/{maxRating}",e.rating)T(e.rating);else{var b=u.dataset.rating;b&&T(+b)}function w(e){if(!0===m||!0===g)return;let i;if(!0===l){let t=this.getBoundingClientRect(),r=e.pageX-t.left,a=u.offsetWidth;i=(a-r)/(a/100)}else i=e.offsetX/u.offsetWidth*100;if(i<101){if(1===n)f=Math.ceil(i/100*5);else{let e=i/100*5;for(let t=0;;t+=n)if(t>=e){f=t;break}}if(f>5&&(f=5),u.querySelector(".yasr-star-value").style.width=f/5*100+"%",t){let e=v.replace("{rating}",f);e=e.replace("{maxRating}",5),u.setAttribute("data-title",e)}"function"==typeof o&&o(f,r)}}function h(e){void 0!==r?(u.querySelector(".yasr-star-value").style.width=r/5*100+"%",u.setAttribute("data-rating",r)):(u.querySelector(".yasr-star-value").style.width="0%",u.removeAttribute("data-rating")),"function"==typeof s&&s(f,r)}function x(e){!0!==m&&!0!==g&&(void 0===y&&!1===typeof y||(g=!0,i=f,void 0===p?u.removeAttribute("data-title"):u.setAttribute("data-title",p),y.call(this,i,(function(){!1===m&&u.removeAttribute("data-title"),g=!1}))))}function S(){if(m=!0,t&&c){let e=c.replace("{rating}",r);e=e.replace("{maxRating}",5),u.setAttribute("data-title",e)}else u.removeAttribute("data-title")}function T(e){if(-1===e&&(e=void 0),"number"!=typeof e&&void 0!==e)throw new Error("Value must be a number or undefined.");e<0&&(e=0),e>5&&(e=5),r=e,u.querySelector(".yasr-star-value").style.width=e/5*100+"%",u.setAttribute("data-rating",e)}void 0===r&&(u.querySelector(".yasr-star-value").style.width="0px"),m&&S(),u.addEventListener("mousemove",w),u.addEventListener("mouseleave",h);let E={setRating:T,getRating:function(){return r},disable:S,enable:function(){m=!1,u.removeAttribute("data-title")},dispose:function(){u.removeEventListener("mousemove",w),u.removeEventListener("mouseleave",h),u.removeEventListener("click",x)}};return u.addEventListener("click",x.bind(E)),E},window.yasrSetRaterValue=function(e,t,r=!1,i=.1,a=!0,n=!1,o=!1){let s;s=r||document.getElementById(t),e=parseInt(e),raterJs({starSize:e,showToolTip:!1,element:s,step:i,readOnly:a,rating:n,rateCallback:o})};
includes/shortcodes/classes/YasrOverallRating.php CHANGED
@@ -28,7 +28,6 @@ if (!defined('ABSPATH')) {
28
  */
29
  class YasrOverallRating extends YasrShortcode {
30
 
31
- protected $html_stars;
32
  protected $overall_rating;
33
 
34
  /**
@@ -117,7 +116,7 @@ class YasrOverallRating extends YasrShortcode {
117
  * before yasr_overall_rating
118
  *
119
  * @param void
120
- * @return string | void
121
  *
122
  */
123
  protected function customTextBefore() {
28
  */
29
  class YasrOverallRating extends YasrShortcode {
30
 
 
31
  protected $overall_rating;
32
 
33
  /**
116
  * before yasr_overall_rating
117
  *
118
  * @param void
119
+ * @return string
120
  *
121
  */
122
  protected function customTextBefore() {
includes/shortcodes/classes/YasrRankings.php CHANGED
@@ -22,9 +22,12 @@ if (!defined('ABSPATH')) {
22
  } // Exit if accessed directly
23
 
24
  /**
 
 
 
25
  * Class YasrRankings
26
  */
27
- class YasrRankings extends YasrShortcode {
28
 
29
  protected $query_highest_rated_overall;
30
  public $query_result_most_rated_visitor;
@@ -172,14 +175,16 @@ class YasrRankings extends YasrShortcode {
172
  if ($this->query_highest_rated_overall) {
173
 
174
  $table_id = 'yasr_overall_ranking_'.str_shuffle(uniqid());
175
- $array_with_title = self::rankingData($this->query_highest_rated_overall);
 
 
176
 
177
  $table_attributes = json_encode($sql_params);
178
 
179
  $this->shortcode_html .= "<table
180
  class='yasr-rankings yasr-stars-rankings'
181
  id=$table_id
182
- data-ranking-data='".json_encode($array_with_title)."'
183
  data-ranking-source='".json_encode($source)."'
184
  data-ranking-params='$table_attributes'
185
  data-ranking-size='".$this->starSize()."'
@@ -221,7 +226,7 @@ class YasrRankings extends YasrShortcode {
221
  $this->shortcode_html .= "<table
222
  class='yasr-rankings yasr-stars-rankings'
223
  id='$table_id'
224
- data-ranking-data='".json_encode($array_with_title)."'
225
  data-ranking-source='".json_encode($source)."'
226
  data-ranking-params='$table_attributes'
227
  data-ranking-size='".$this->starSize()."'
22
  } // Exit if accessed directly
23
 
24
  /**
25
+ * Extends YasrMultiSet instead of YasrShortcode because it also works with this->set_id
26
+ *
27
+ * @author Dario Curvino <@dudo>
28
  * Class YasrRankings
29
  */
30
+ class YasrRankings extends YasrMultiSet {
31
 
32
  protected $query_highest_rated_overall;
33
  public $query_result_most_rated_visitor;
175
  if ($this->query_highest_rated_overall) {
176
 
177
  $table_id = 'yasr_overall_ranking_'.str_shuffle(uniqid());
178
+ $array_with_title = htmlspecialchars(
179
+ json_encode(self::rankingData($this->query_highest_rated_overall)),ENT_QUOTES, 'UTF-8'
180
+ );
181
 
182
  $table_attributes = json_encode($sql_params);
183
 
184
  $this->shortcode_html .= "<table
185
  class='yasr-rankings yasr-stars-rankings'
186
  id=$table_id
187
+ data-ranking-data='".$array_with_title."'
188
  data-ranking-source='".json_encode($source)."'
189
  data-ranking-params='$table_attributes'
190
  data-ranking-size='".$this->starSize()."'
226
  $this->shortcode_html .= "<table
227
  class='yasr-rankings yasr-stars-rankings'
228
  id='$table_id'
229
+ data-ranking-data='".htmlspecialchars(json_encode($array_with_title),ENT_QUOTES, 'UTF-8')."'
230
  data-ranking-source='".json_encode($source)."'
231
  data-ranking-params='$table_attributes'
232
  data-ranking-size='".$this->starSize()."'
includes/shortcodes/classes/YasrShortcodesAjax.php CHANGED
@@ -63,16 +63,24 @@ class YasrShortcodesAjax {
63
  * @since refactor in 2.7.7
64
  */
65
  public function saveVV() {
66
- if (isset($_POST['rating'], $_POST['post_id'], $_POST['nonce_visitor'])) {
 
 
67
  $rating = (int) $_POST['rating'];
68
  $post_id = (int) $_POST['post_id'];
69
- $nonce_visitor = $_POST['nonce_visitor'];
70
  $is_singular = $_POST['is_singular'];
71
  }
72
  else {
 
73
  die();
74
  }
75
 
 
 
 
 
 
 
76
  $array_action_visitor_vote = array('post_id' => $post_id, 'is_singular' => $is_singular);
77
 
78
  do_action('yasr_action_on_visitor_vote', $array_action_visitor_vote);
@@ -83,7 +91,8 @@ class YasrShortcodesAjax {
83
  }
84
 
85
  if(YASR_ALLOWED_USER === 'logged_only' && !is_user_logged_in()) {
86
- die(esc_html__('Only logged in user can rate', 'yet-anothter-stars-rating'));
 
87
  }
88
 
89
  if ($rating < 1) {
@@ -128,6 +137,11 @@ class YasrShortcodesAjax {
128
  }
129
 
130
  /**
 
 
 
 
 
131
  * @author Dario Curvino <@dudo>
132
  * @since 2.7.7
133
  *
@@ -285,7 +299,7 @@ class YasrShortcodesAjax {
285
  $array_to_return['sum_votes'] = $array_visitor_votes['sum_votes'];
286
 
287
  //this means is an ajax call
288
- if (isset($_GET['action']) && $_GET['action'] === 'yasr_load_vv') {
289
  $array_to_echo['yasr_visitor_votes'] = $array_to_return;
290
  echo json_encode($array_to_echo);
291
  die();
@@ -303,6 +317,8 @@ class YasrShortcodesAjax {
303
  * @since 2.7.7
304
  */
305
  public function saveMV() {
 
 
306
  if (isset($_POST['post_id']) && isset($_POST['rating']) && isset($_POST['set_id'])) {
307
  $post_id = (int) $_POST['post_id'];
308
  $rating = $_POST['rating'];
@@ -505,6 +521,8 @@ class YasrShortcodesAjax {
505
  * @since 2.7.7
506
  */
507
  public function returnVVStats() {
 
 
508
  if (isset($_POST['post_id']) && $_POST['post_id'] !== '') {
509
  $post_id = (int)$_POST['post_id'];
510
  }
@@ -516,7 +534,7 @@ class YasrShortcodesAjax {
516
  die();
517
  }
518
 
519
- $votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
520
  $average_rating = $votes_array['average'];
521
 
522
  $missing_vote = null; //avoid undefined variable
@@ -651,14 +669,13 @@ class YasrShortcodesAjax {
651
  * @return array|false|false[]
652
  */
653
  public static function rankingData($source=false, $request=false) {
654
- $is_ajax = false;
655
  $nonce_visitor = false;
656
 
657
  if (isset($_GET['action']) && isset($_GET['source']) && isset($_GET['nonce_rankings'])) {
658
  $request = $_GET;
659
  $source = (string)$_GET['source'];
660
  $nonce_visitor = $_GET['nonce_rankings'];
661
- $is_ajax = true;
662
  }
663
 
664
  if($is_ajax === true) {
@@ -735,4 +752,14 @@ class YasrShortcodesAjax {
735
  return $data_to_return;
736
 
737
  }
 
 
 
 
 
 
 
 
 
 
738
  }
63
  * @since refactor in 2.7.7
64
  */
65
  public function saveVV() {
66
+ $this->dieIfNotAjax();
67
+
68
+ if (isset($_POST['rating'], $_POST['post_id'])) {
69
  $rating = (int) $_POST['rating'];
70
  $post_id = (int) $_POST['post_id'];
 
71
  $is_singular = $_POST['is_singular'];
72
  }
73
  else {
74
+ echo ($this->returnErrorResponse(__('Error in Ajax Call, missing required param.', 'yet-another-stars-rating')));
75
  die();
76
  }
77
 
78
+ if(isset($_POST['nonce_visitor'])) {
79
+ $nonce_visitor = $_POST['nonce_visitor'];
80
+ } else {
81
+ $nonce_visitor = false;
82
+ }
83
+
84
  $array_action_visitor_vote = array('post_id' => $post_id, 'is_singular' => $is_singular);
85
 
86
  do_action('yasr_action_on_visitor_vote', $array_action_visitor_vote);
91
  }
92
 
93
  if(YASR_ALLOWED_USER === 'logged_only' && !is_user_logged_in()) {
94
+ echo ($this->returnErrorResponse(__('Only logged in user can rate.', 'yet-another-stars-rating')));
95
+ die();
96
  }
97
 
98
  if ($rating < 1) {
137
  }
138
 
139
  /**
140
+ * Save VV rating
141
+ *
142
+ * wpdb prepare not needed here
143
+ * https://wordpress.stackexchange.com/questions/25947/wpdb-insert-do-i-need-to-prepare-against-sql-injection
144
+ *
145
  * @author Dario Curvino <@dudo>
146
  * @since 2.7.7
147
  *
299
  $array_to_return['sum_votes'] = $array_visitor_votes['sum_votes'];
300
 
301
  //this means is an ajax call
302
+ if (wp_doing_ajax() === true) {
303
  $array_to_echo['yasr_visitor_votes'] = $array_to_return;
304
  echo json_encode($array_to_echo);
305
  die();
317
  * @since 2.7.7
318
  */
319
  public function saveMV() {
320
+ $this->dieIfNotAjax();
321
+
322
  if (isset($_POST['post_id']) && isset($_POST['rating']) && isset($_POST['set_id'])) {
323
  $post_id = (int) $_POST['post_id'];
324
  $rating = $_POST['rating'];
521
  * @since 2.7.7
522
  */
523
  public function returnVVStats() {
524
+ $this->dieIfNotAjax();
525
+
526
  if (isset($_POST['post_id']) && $_POST['post_id'] !== '') {
527
  $post_id = (int)$_POST['post_id'];
528
  }
534
  die();
535
  }
536
 
537
+ $votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
538
  $average_rating = $votes_array['average'];
539
 
540
  $missing_vote = null; //avoid undefined variable
669
  * @return array|false|false[]
670
  */
671
  public static function rankingData($source=false, $request=false) {
672
+ $is_ajax = wp_doing_ajax();
673
  $nonce_visitor = false;
674
 
675
  if (isset($_GET['action']) && isset($_GET['source']) && isset($_GET['nonce_rankings'])) {
676
  $request = $_GET;
677
  $source = (string)$_GET['source'];
678
  $nonce_visitor = $_GET['nonce_rankings'];
 
679
  }
680
 
681
  if($is_ajax === true) {
752
  return $data_to_return;
753
 
754
  }
755
+
756
+ /**
757
+ * @author Dario Curvino <@dudo>
758
+ * @since 3.0.5
759
+ */
760
+ private function dieIfNotAjax() {
761
+ if(wp_doing_ajax() === false) {
762
+ die(esc_html__('Not in Ajax Contest', 'yet-anothter-stars-rating'));
763
+ }
764
+ }
765
  }
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -168,7 +168,6 @@ class YasrVisitorVotes extends YasrShortcode {
168
  * @return int|bool|void
169
  */
170
  public static function showTextBelowStars ($cookie_value, $post_id=false) {
171
-
172
  $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
173
  $div_bottom_line = false;
174
  $span_bottom_line_content = false;
168
  * @return int|bool|void
169
  */
170
  public static function showTextBelowStars ($cookie_value, $post_id=false) {
 
171
  $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
172
  $div_bottom_line = false;
173
  $span_bottom_line_content = false;
includes/shortcodes/yasr-shortcode-functions.php CHANGED
@@ -60,9 +60,7 @@ function shortcode_overall_rating_callback ($atts, $content=false, $shortcode_ta
60
  if (YASR_SHOW_OVERALL_IN_LOOP === 'disabled' && !is_singular() && is_main_query()) {
61
  return;
62
  }
63
- $overall_rating = new YasrOverallRating($atts, $shortcode_tag);
64
-
65
- return $overall_rating->returnShortcode();
66
  } //end function
67
 
68
 
@@ -82,9 +80,7 @@ function shortcode_visitor_votes_callback($atts, $content=false, $shortcode_tag=
82
  return;
83
  }
84
 
85
- $visitor_votes = new YasrVisitorVotes($atts, $shortcode_tag);
86
-
87
- return $visitor_votes->returnShortcode();
88
 
89
  } //End function shortcode_visitor_votes_callback
90
 
@@ -100,9 +96,7 @@ add_shortcode ('yasr_multiset', 'yasr_multiset_callback');
100
  * @return bool|string
101
  */
102
  function yasr_multiset_callback($atts, $content, $shortcode_tag) {
103
- $multiset = new YasrMultiSet($atts, $shortcode_tag);
104
-
105
- return $multiset->printMultiset();
106
  }
107
 
108
  /****** Add shortcode for multiset writable by users ******/
@@ -117,11 +111,9 @@ add_shortcode ('yasr_visitor_multiset', 'yasr_visitor_multiset_callback');
117
  * @return string
118
  */
119
  function yasr_visitor_multiset_callback($atts, $content, $shortcode_tag) {
120
- $multiset = new YasrVisitorMultiSet($atts, $shortcode_tag);
121
- return $multiset->printVisitorMultiSet();
122
  }
123
 
124
-
125
  /*
126
  * @deprecated deprecated since version 2.6.2
127
  * @todo remove DEC 2023
@@ -142,9 +134,7 @@ add_shortcode ('yasr_ov_ranking', 'yasr_ov_ranking_callback');
142
  * @return string
143
  */
144
  function yasr_ov_ranking_callback($atts, $content, $shortcode_tag) {
145
- $top_ten_highest_obj = new YasrRankings(false, $shortcode_tag);
146
-
147
- return $top_ten_highest_obj->returnHighestRatedOverall($atts);
148
  } //End function
149
 
150
 
@@ -158,9 +148,7 @@ add_shortcode ('yasr_most_or_highest_rated_posts', 'yasr_most_or_highest_rated_p
158
  * @return string
159
  */
160
  function yasr_most_or_highest_rated_posts_callback($atts, $content, $shortcode_tag) {
161
- $most_highest_obj = new YasrRankings(false, $shortcode_tag);
162
-
163
- return $most_highest_obj->vvReturnMostHighestRated($atts);
164
  } //End function
165
 
166
 
@@ -200,7 +188,6 @@ add_shortcode ('yasr_most_active_users', 'yasr_ranking_users_callback');
200
  function yasr_ranking_users_callback ($atts, $content, $shortcode_tag) {
201
  $ranking_users_obj = new YasrNoStarsRankings(false, $shortcode_tag);
202
 
203
-
204
  if($shortcode_tag === 'yasr_top_reviewers' || $shortcode_tag === 'yasr_top_5_reviewers') {
205
  return $ranking_users_obj->returnTopReviewers($atts);
206
  }
@@ -212,16 +199,13 @@ function yasr_ranking_users_callback ($atts, $content, $shortcode_tag) {
212
  add_shortcode ('yasr_multi_set_ranking', 'yasr_multi_set_ranking_callback');
213
 
214
  function yasr_multi_set_ranking_callback($atts, $content, $shortcode_tag) {
215
- $yasr_ranking = new YasrRankings($atts, $shortcode_tag);
216
- return $yasr_ranking->returnMulti($atts);
217
  } //End function
218
 
219
  add_shortcode ('yasr_visitor_multi_set_ranking', 'yasr_visitor_multi_set_ranking_callback');
220
 
221
  function yasr_visitor_multi_set_ranking_callback($atts, $content, $shortcode_tag) {
222
- $yasr_ranking = new YasrRankings($atts, $shortcode_tag);
223
-
224
- return $yasr_ranking->returnMultiVisitor($atts);
225
  } //End function
226
 
227
  /**
@@ -230,7 +214,6 @@ function yasr_visitor_multi_set_ranking_callback($atts, $content, $shortcode_tag
230
  add_shortcode('yasr_user_rate_history', 'yasr_users_front_widget_callback');
231
  add_action('wp_ajax_yasr_change_user_log_page_front', 'yasr_users_front_widget_callback');
232
  function yasr_users_front_widget_callback() {
233
- $log_widget = new YasrLogDashboardWidget();
234
- return $log_widget->userWidgetShortcode();
235
  } //End callback function
236
 
60
  if (YASR_SHOW_OVERALL_IN_LOOP === 'disabled' && !is_singular() && is_main_query()) {
61
  return;
62
  }
63
+ return (new YasrOverallRating($atts, $shortcode_tag))->returnShortcode();
 
 
64
  } //end function
65
 
66
 
80
  return;
81
  }
82
 
83
+ return (new YasrVisitorVotes($atts, $shortcode_tag))->returnShortcode();
 
 
84
 
85
  } //End function shortcode_visitor_votes_callback
86
 
96
  * @return bool|string
97
  */
98
  function yasr_multiset_callback($atts, $content, $shortcode_tag) {
99
+ return (new YasrMultiSet($atts, $shortcode_tag))->printMultiset();
 
 
100
  }
101
 
102
  /****** Add shortcode for multiset writable by users ******/
111
  * @return string
112
  */
113
  function yasr_visitor_multiset_callback($atts, $content, $shortcode_tag) {
114
+ return (new YasrVisitorMultiSet($atts, $shortcode_tag))->printVisitorMultiSet();
 
115
  }
116
 
 
117
  /*
118
  * @deprecated deprecated since version 2.6.2
119
  * @todo remove DEC 2023
134
  * @return string
135
  */
136
  function yasr_ov_ranking_callback($atts, $content, $shortcode_tag) {
137
+ return (new YasrRankings(false, $shortcode_tag))->returnHighestRatedOverall($atts);
 
 
138
  } //End function
139
 
140
 
148
  * @return string
149
  */
150
  function yasr_most_or_highest_rated_posts_callback($atts, $content, $shortcode_tag) {
151
+ return (new YasrRankings(false, $shortcode_tag))->vvReturnMostHighestRated($atts);
 
 
152
  } //End function
153
 
154
 
188
  function yasr_ranking_users_callback ($atts, $content, $shortcode_tag) {
189
  $ranking_users_obj = new YasrNoStarsRankings(false, $shortcode_tag);
190
 
 
191
  if($shortcode_tag === 'yasr_top_reviewers' || $shortcode_tag === 'yasr_top_5_reviewers') {
192
  return $ranking_users_obj->returnTopReviewers($atts);
193
  }
199
  add_shortcode ('yasr_multi_set_ranking', 'yasr_multi_set_ranking_callback');
200
 
201
  function yasr_multi_set_ranking_callback($atts, $content, $shortcode_tag) {
202
+ return (new YasrRankings($atts, $shortcode_tag))->returnMulti($atts);
 
203
  } //End function
204
 
205
  add_shortcode ('yasr_visitor_multi_set_ranking', 'yasr_visitor_multi_set_ranking_callback');
206
 
207
  function yasr_visitor_multi_set_ranking_callback($atts, $content, $shortcode_tag) {
208
+ return (new YasrRankings($atts, $shortcode_tag))->returnMultiVisitor($atts);
 
 
209
  } //End function
210
 
211
  /**
214
  add_shortcode('yasr_user_rate_history', 'yasr_users_front_widget_callback');
215
  add_action('wp_ajax_yasr_change_user_log_page_front', 'yasr_users_front_widget_callback');
216
  function yasr_users_front_widget_callback() {
217
+ return (new YasrLogDashboardWidget())->userWidgetShortcode();
 
218
  } //End callback function
219
 
includes/yasr-includes-functions.php CHANGED
@@ -22,123 +22,6 @@ if (!defined('ABSPATH')) {
22
  exit('You\'re not allowed to see this page');
23
  } // Exit if accessed directly
24
 
25
- /***** Adding global js and css needed on both admin and public *****/
26
- add_action('wp_enqueue_scripts', 'yasr_add_scripts_includes', 11);
27
- add_action('admin_enqueue_scripts', 'yasr_add_scripts_includes', 11);
28
-
29
- function yasr_add_scripts_includes() {
30
- //This is required to use wp_localize_script without dependency
31
- //https://wordpress.stackexchange.com/a/311279/48442
32
- wp_register_script( 'yasr-global-data', '', [], '', true );
33
- wp_enqueue_script( 'yasr-global-data' );
34
-
35
- $yasr_visitor_votes_loader =
36
- '<div id="loader-visitor-rating" style="display: inline-block">&nbsp; '.
37
- '<img src="' . esc_url(YASR_IMG_DIR . 'loader.gif').'"
38
- title="yasr-loader" alt="yasr-loader" height="16" width="16">'.
39
- '</div>';
40
-
41
-
42
- $yasr_common_data = array(
43
- 'siteUrl' => site_url(),
44
- 'adminUrl' => admin_url(), //keep this for pricing page
45
- 'ajaxurl' => admin_url('admin-ajax.php'),
46
- 'visitorStatsEnabled' => YASR_VISITORS_STATS,
47
- 'ajaxEnabled' => YASR_ENABLE_AJAX,
48
- 'loaderHtml' => $yasr_visitor_votes_loader,
49
- 'loaderUrl' => esc_url(YASR_IMG_DIR . 'loader.gif'),
50
- 'isRtl' => json_encode(is_rtl())
51
- );
52
-
53
- //check if wp_localize_script has already run before
54
- //since version 2.9.8 wp_localize_script is used again instead of wp_add_inline_script.
55
- //For some reasons, wp_add_inline_script simply didn't run in some cases
56
- // (e.g. https://wordpress.org/support/topic/yellow-star-not-appear/)
57
- if(!defined('YASR_GLOBAL_DATA_EXISTS')) {
58
- wp_localize_script(
59
- 'yasr-global-data',
60
- 'yasrCommonData',
61
- $yasr_common_data
62
- );
63
-
64
- //use a constant to be sure that yasrCommonData is not loaded twice
65
- define ('YASR_GLOBAL_DATA_EXISTS', true);
66
- }
67
-
68
- $yasr_multiset_theme_handle = 'yasrcsslightscheme';
69
- $yasr_multiset_theme = 'yasr-table-light.css';
70
-
71
- //default css is the light one
72
- if (YASR_SCHEME_COLOR === 'dark') {
73
- $yasr_multiset_theme_handle = 'yasrcssdarkscheme';
74
- $yasr_multiset_theme = 'yasr-table-dark.css';
75
- }
76
-
77
- wp_enqueue_style(
78
- $yasr_multiset_theme_handle,
79
- YASR_CSS_DIR_INCLUDES . $yasr_multiset_theme,
80
- '',
81
- YASR_VERSION_NUM
82
- );
83
-
84
- }
85
-
86
- /*** Css rules for stars set, from version 1.2.7
87
- * Here I use add_action instead of directly use wp_add_inline_style so I can
88
- * use remove_action if needed (e.g. Yasr Stylish)
89
- ***/
90
- add_action('yasr_add_front_script_css', 'yasr_css_stars_set');
91
- add_action('yasr_add_admin_scripts_end', 'yasr_css_stars_set');
92
-
93
- function yasr_css_stars_set() {
94
-
95
- //if star selected is "rater", select the images
96
- if (YASR_STARS_SET === 'rater') {
97
- $star_grey = YASR_IMG_DIR . 'star_0.svg';
98
- $star_yellow = YASR_IMG_DIR . 'star_1.svg';
99
- } elseif (YASR_STARS_SET === 'rater-oxy') {
100
- $star_grey = YASR_IMG_DIR . 'star_oxy_0.svg';
101
- $star_yellow = YASR_IMG_DIR . 'star_oxy_1.svg';
102
- } //by default, use the one provided by Yasr
103
- else {
104
- $star_grey = YASR_IMG_DIR . 'star_2.svg';
105
- $star_yellow = YASR_IMG_DIR . 'star_3.svg';
106
- }
107
-
108
-
109
- $yasr_st_css = "
110
- .yasr-star-rating {
111
- background-image: url(\"$star_grey\");
112
- }
113
- .yasr-star-rating .yasr-star-value {
114
- background: url(\"$star_yellow\") ;
115
- }
116
- ";
117
-
118
- wp_add_inline_style('yasrcss', $yasr_st_css);
119
-
120
- }
121
-
122
- add_action('yasr_add_front_script_css', 'yasr_rtl_support');
123
- add_action('yasr_add_admin_scripts_end', 'yasr_rtl_support');
124
-
125
- function yasr_rtl_support() {
126
- if (is_rtl()) {
127
- $yasr_rtl_css = '.yasr-star-rating .yasr-star-value {
128
- -moz-transform: scaleX(-1);
129
- -o-transform: scaleX(-1);
130
- -webkit-transform: scaleX(-1);
131
- transform: scaleX(-1);
132
- filter: FlipH;
133
- -ms-filter: "FlipH";
134
- right: 0;
135
- left: auto;
136
- }';
137
-
138
- wp_add_inline_style('yasrcss', $yasr_rtl_css);
139
- }
140
- }
141
-
142
  /****** Translating YASR ******/
143
  add_action('init', 'yasr_translate');
144
 
22
  exit('You\'re not allowed to see this page');
23
  } // Exit if accessed directly
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  /****** Translating YASR ******/
26
  add_action('init', 'yasr_translate');
27
 
includes/yasr-includes-init.php CHANGED
@@ -36,6 +36,7 @@ define('YASR_MULTI_SET_FIELDS_TABLE', $wpdb->prefix . 'yasr_multi_set_fields');
36
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-includes-functions.php';
37
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-includes-db-functions.php';
38
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-widgets.php';
 
39
 
40
 
41
  /**
@@ -57,98 +58,42 @@ function yasr_autoload_includes_classes($class) {
57
  if (file_exists($file_name)) {
58
  require($file_name);
59
  }
60
-
61
  }
62
 
63
  //AutoLoad Yasr Classes, only when a object is created
64
  spl_autoload_register('yasr_autoload_includes_classes');
65
 
66
- require YASR_ABSOLUTE_PATH_INCLUDES . '/shortcodes/yasr-shortcode-functions.php';
67
-
68
-
69
- /****** Getting options ******/
70
- //Get general options
71
-
72
- $settings = new YasrSettingsValues();
73
- $yasr_general_settings = $settings->getGeneralSettings();
74
-
75
- if(isset($yasr_general_settings['auto_insert_enabled'])) {
76
- define('YASR_AUTO_INSERT_ENABLED', (int)$yasr_general_settings['auto_insert_enabled']);
77
- } else {
78
- define('YASR_AUTO_INSERT_ENABLED', 0);
79
- }
80
-
81
- if (YASR_AUTO_INSERT_ENABLED === 1) {
82
- define('YASR_AUTO_INSERT_WHAT', $yasr_general_settings['auto_insert_what']);
83
- define('YASR_AUTO_INSERT_WHERE', $yasr_general_settings['auto_insert_where']);
84
- define('YASR_AUTO_INSERT_ALIGN', $yasr_general_settings['auto_insert_align']);
85
- define('YASR_AUTO_INSERT_SIZE', $yasr_general_settings['auto_insert_size']);
86
- define('YASR_AUTO_INSERT_EXCLUDE_PAGES', $yasr_general_settings['auto_insert_exclude_pages']);
87
- define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', $yasr_general_settings['auto_insert_custom_post_only']);
88
- } else {
89
- define('YASR_AUTO_INSERT_WHAT', null);
90
- define('YASR_AUTO_INSERT_WHERE', null);
91
- define('YASR_AUTO_INSERT_ALIGN', null);
92
- define('YASR_AUTO_INSERT_SIZE', null);
93
- define('YASR_AUTO_INSERT_EXCLUDE_PAGES', null);
94
- define('YASR_AUTO_INSERT_CUSTOM_POST_ONLY', null);
95
- }
96
-
97
- define('YASR_STARS_TITLE', $yasr_general_settings['stars_title']);
98
 
99
- if (YASR_STARS_TITLE === 'yes') {
100
- define('YASR_STARS_TITLE_WHAT', $yasr_general_settings['stars_title_what']);
101
- define('YASR_STARS_TITLE_EXCLUDE_PAGES', $yasr_general_settings['stars_title_exclude_pages']);
102
- define('YASR_STARS_TITLE_WHERE', $yasr_general_settings['stars_title_where']);
103
- } else {
104
- define('YASR_STARS_TITLE_WHAT', null);
105
- define('YASR_STARS_TITLE_EXCLUDE_PAGES', null);
106
- define('YASR_STARS_TITLE_WHERE', null);
107
- }
108
-
109
- define('YASR_SHOW_OVERALL_IN_LOOP', $yasr_general_settings['show_overall_in_loop']);
110
- define('YASR_SHOW_VISITOR_VOTES_IN_LOOP', $yasr_general_settings['show_visitor_votes_in_loop']);
111
- define('YASR_VISITORS_STATS', $yasr_general_settings['visitors_stats']);
112
- define('YASR_ALLOWED_USER', $yasr_general_settings['allowed_user']);
113
- define('YASR_ENABLE_IP', $yasr_general_settings['enable_ip']);
114
- define('YASR_ITEMTYPE', $yasr_general_settings['snippet_itemtype']);
115
- define('YASR_PUBLISHER_TYPE', $yasr_general_settings['publisher']);
116
- define('YASR_PUBLISHER_NAME', $yasr_general_settings['publisher_name']);
117
-
118
- if (isset($yasr_general_settings['publisher_logo'])
119
- && (filter_var($yasr_general_settings['publisher_logo'], FILTER_VALIDATE_URL) !== false)) {
120
- define('YASR_PUBLISHER_LOGO', $yasr_general_settings['publisher_logo']);
121
- } else {
122
- define('YASR_PUBLISHER_LOGO', get_site_icon_url());
123
- }
124
 
125
- define('YASR_ENABLE_AJAX', $yasr_general_settings['enable_ajax']);
126
-
127
- $style_options = $settings->getStyleSettings();
128
-
129
- //Get stored style options
130
- //To better support php version < 7, I can't use an array into define
131
- //Also, I can't use const here, because it only works with primitive values
132
- //https://stackoverflow.com/questions/2447791/php-define-vs-const
133
- define('YASR_STYLE_OPTIONS', json_encode($style_options));
134
 
135
- define('YASR_STARS_SET', $style_options['stars_set_free']);
136
- define('YASR_SCHEME_COLOR', $style_options['scheme_color_multiset']);
137
- define('YASR_CUSTOM_CSS_RULES', $style_options['textarea']);
138
 
139
- //Multi set options
140
- $multi_set_options = $settings->getMultiSettings();
141
 
142
- define('YASR_MULTI_SHOW_AVERAGE', $multi_set_options['show_average']);
 
 
143
 
144
  /****** End Getting options ******/
145
 
146
- define('YASR_LOADER_IMAGE', YASR_IMG_DIR . '/loader.gif');
147
-
148
- //Text for button in settings pages
149
- $save_settings_text = __('Save All Settings', 'yet-another-stars-rating');
150
- define('YASR_SAVE_All_SETTINGS_TEXT', $save_settings_text);
151
-
152
  //To better support php version < 7, I can't use an array into define
153
  //I can use const here, because it is a primitive value
154
  //https://stackoverflow.com/questions/1290318/php-constants-containing-arrays
@@ -219,20 +164,5 @@ const YASR_SUPPORTED_SCHEMA_TYPES_ADDITIONAL_FIELDS =
219
  'yasr_softwareapplication_price_valid_until',
220
  );
221
 
222
- //run includes filters
223
- $yasr_includes_filter = new YasrIncludesFilters();
224
- $yasr_includes_filter->filterCustomTexts($yasr_general_settings);
225
-
226
- //support for caching plugins
227
- $yasr_includes_filter->cachingPluginSupport();
228
-
229
- $init_ajax = new YasrShortcodesAjax();
230
- $init_ajax->init();
231
-
232
- add_action('plugins_loaded', static function () {
233
- define('YASR_FIRST_SETID', YasrMultiSetData::returnFirstSetId());
234
- define ('YASR_CATCH_INFINITE_SCROLL_INSTALLED', yasr_is_catch_infinite_sroll_installed());
235
- });
236
-
237
  //Load rest API
238
- require YASR_ABSOLUTE_PATH_INCLUDES . '/rest/yasr-rest.php';
36
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-includes-functions.php';
37
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-includes-db-functions.php';
38
  require YASR_ABSOLUTE_PATH_INCLUDES . '/yasr-widgets.php';
39
+ require YASR_ABSOLUTE_PATH_INCLUDES . '/shortcodes/yasr-shortcode-functions.php';
40
 
41
 
42
  /**
58
  if (file_exists($file_name)) {
59
  require($file_name);
60
  }
 
61
  }
62
 
63
  //AutoLoad Yasr Classes, only when a object is created
64
  spl_autoload_register('yasr_autoload_includes_classes');
65
 
66
+ //Get settings
67
+ $settings = new YasrSettingsValues();
68
+ $general_settings = $settings->getGeneralSettings();
69
+ $style_settings = $settings->getStyleSettings();
70
+ $multi_settings = $settings->getMultiSettings();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
+ //do defines based on the settings
73
+ $do_define = new YasrDefineOptions();
74
+ $do_define->generalSettings($general_settings); //set all the defines for general settings
75
+ $do_define->styleSettings($style_settings);
76
+ $do_define->multisetSettings($multi_settings);
77
+ $do_define->onPluginsLoaded();
78
+ $do_define->misc();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ //run includes filters
81
+ $yasr_includes_filter = new YasrIncludesFilters();
82
+ $yasr_includes_filter->filterCustomTexts();
 
 
 
 
 
 
83
 
84
+ //Load window.var used by YASR
85
+ $load_script = new YasrScriptsLoader();
86
+ $load_script->loadRequiredScripts();
87
 
88
+ //support for caching plugins
89
+ $yasr_includes_filter->cachingPluginSupport();
90
 
91
+ //Init Ajax
92
+ $init_ajax = new YasrShortcodesAjax();
93
+ $init_ajax->init();
94
 
95
  /****** End Getting options ******/
96
 
 
 
 
 
 
 
97
  //To better support php version < 7, I can't use an array into define
98
  //I can use const here, because it is a primitive value
99
  //https://stackoverflow.com/questions/1290318/php-constants-containing-arrays
164
  'yasr_softwareapplication_price_valid_until',
165
  );
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  //Load rest API
168
+ require YASR_ABSOLUTE_PATH_INCLUDES . '/rest/yasr-rest.php';
readme.txt CHANGED
@@ -3,8 +3,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
3
  Tags: rating, rate post, rate page, star rating, google rating, votes
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
- Tested up to: 5.9.3
7
- Stable tag: 3.0.4
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
@@ -203,6 +203,14 @@ Yes, YASR is 100% fully compatible with PHP 8
203
 
204
  The full changelog can be found in the plugin's directory. Recent entries:
205
 
 
 
 
 
 
 
 
 
206
  = 3.0.4 =
207
  * FIX: Author multiset didn't get saved
208
  * TWEAKED: better error handling
3
  Tags: rating, rate post, rate page, star rating, google rating, votes
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
+ Tested up to: 6.0
7
+ Stable tag: 3.0.5
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
203
 
204
  The full changelog can be found in the plugin's directory. Recent entries:
205
 
206
+ = 3.0.5 =
207
+ * FIX: set_id parameter didn't work in shortcodes yasr_multi_set_ranking and yasr_visitor_multi_set_ranking
208
+ * FIX: rankings didn't show up when post title contains quotation marks ( " )
209
+ * TWEAKED: In the setting page, section "Custom texts" is now renamed in "Customize strings", and it works on two columns
210
+ (more strings will come soon)
211
+ * TWEAKED: under the hood changes.
212
+
213
+
214
  = 3.0.4 =
215
  * FIX: Author multiset didn't get saved
216
  * TWEAKED: better error handling
yet-another-stars-rating.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
- * Version: 3.0.4
8
  * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
@@ -78,7 +78,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
- define( 'YASR_VERSION_NUM', '3.0.4' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
+ * Version: 3.0.5
8
  * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
+ define( 'YASR_VERSION_NUM', '3.0.5' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );