Yasr – Yet Another Stars Rating - Version 2.3.6

Version Description

  • FIXED: visitor multiset doesn't allow user to vote in some circumstances
  • TWEAKED : minor changes in ajax call for yasr_visitor_votes
Download this release

Release Info

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

Code changes from version 2.3.5 to 2.3.6

admin/classes/YasrSettings.php CHANGED
@@ -76,60 +76,4 @@ class YasrSettings {
76
  } //end foreach
77
  }
78
 
79
- /**
80
- * @param bool | string $option_title
81
- * @param array $array_options
82
- * @param string $name
83
- * @param string $class
84
- * @param bool | string | int $default_value
85
- * @param bool | string $id
86
- */
87
- public static function printRadioType($option_title, $array_options, $name, $class, $default_value=false, $id=false) {
88
-
89
- if($option_title) {
90
- echo '<strong>' . $option_title . '</strong><br />';
91
- }
92
-
93
- if(is_array($array_options)) {
94
-
95
- echo '<div class="yasr-indented-answer">';
96
-
97
- foreach ($array_options as $value => $label) {
98
- $id_string = $id . '-' . strtolower(trim(str_replace(' ', '', $value)));
99
- //must be inside foreach, or when loop arrive to last element
100
- //checked is defined
101
- $checked = '';
102
-
103
- //If db_value === false, there is no need to check for db value
104
- //so checked is the medium star (i.e. ranking page)
105
- if($default_value === $value) {
106
- $checked = 'checked';
107
- }
108
-
109
- //string value must be empty
110
- if($value === 0) {
111
- $value = '';
112
- }
113
-
114
- echo sprintf('<div>
115
- <label for="%s">
116
- <input type="radio"
117
- name="%s"
118
- value="%s"
119
- class="%s"
120
- id="%s"
121
- %s
122
- >
123
- %s
124
- </label>
125
- </div>',
126
- $id_string, $name, $value, $class, $id_string, $checked,
127
- __(ucwords($label), 'yet-another-stars-rating'));
128
-
129
- } //end foreach
130
-
131
- echo '</div>';
132
- }
133
- }
134
-
135
  }
76
  } //end foreach
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
admin/editor/YasrMetaboxSchemaFields.php CHANGED
@@ -31,11 +31,10 @@ if (!defined('ABSPATH')) {
31
  class YasrMetaboxSchemaFields {
32
 
33
  private $saved_data;
34
- private $input;
35
 
36
  public function __construct($saved_data) {
37
  $this->saved_data = $saved_data;
38
- $this->input = new YasrPhpFieldsHelper('yasr-itemtype-row-container-label-input');
39
  }
40
 
41
  /**
@@ -256,24 +255,24 @@ class YasrMetaboxSchemaFields {
256
  foreach ($itemType_array as $property) {
257
  if (isset($property['type'])) {
258
  if ($property['type'] === 'select') {
259
- $string_input = $this->input->select(
260
  '', $property['label'], $property['options'], $property['name'], '', esc_attr($this->saved_data[$property['name']])
261
  );
262
  }
263
  elseif ($property['type'] === 'textarea') {
264
- $string_input = $this->input->textArea('', $property['label'], $property['name'], '', '',
265
  $this->saved_data[$property['name']] );
266
  }
267
  }
268
  else {
269
- $string_input = $this->input->text(
270
  '', $property['label'], $property['name'], '', $property['label'], esc_attr($this->saved_data[$property['name']])
271
  );
272
  }
273
 
274
  echo $string_input;
275
 
276
- if(isset( $property['description'] ) && $property['description'] !== '') {
277
  echo '<div class="yasr-itemtype-row-container-description">'
278
  . $property['description'] .
279
  '</div>';
@@ -328,12 +327,12 @@ class YasrMetaboxSchemaFields {
328
  'OnlineOnly', 'OutOfStock', 'PreOrder'. 'PreSale', 'SoldOut'
329
  );
330
 
331
- $string_input = $this->input->select(
332
  '', $info['label'], $array_global_availability, $info['name'], '', esc_attr($saved_data[$info['name']])
333
  );
334
  }
335
  else {
336
- $string_input = $this->input->text(
337
  '', $info['label'], $info['name'], '', '', esc_attr($saved_data[$info['name']])
338
  );
339
  }
31
  class YasrMetaboxSchemaFields {
32
 
33
  private $saved_data;
 
34
 
35
  public function __construct($saved_data) {
36
  $this->saved_data = $saved_data;
37
+ new YasrPhpFieldsHelper('yasr-itemtype-row-container-label-input');
38
  }
39
 
40
  /**
255
  foreach ($itemType_array as $property) {
256
  if (isset($property['type'])) {
257
  if ($property['type'] === 'select') {
258
+ $string_input = YasrPhpFieldsHelper::select(
259
  '', $property['label'], $property['options'], $property['name'], '', esc_attr($this->saved_data[$property['name']])
260
  );
261
  }
262
  elseif ($property['type'] === 'textarea') {
263
+ $string_input = YasrPhpFieldsHelper::textArea('', $property['label'], $property['name'], '', '',
264
  $this->saved_data[$property['name']] );
265
  }
266
  }
267
  else {
268
+ $string_input = YasrPhpFieldsHelper::text(
269
  '', $property['label'], $property['name'], '', $property['label'], esc_attr($this->saved_data[$property['name']])
270
  );
271
  }
272
 
273
  echo $string_input;
274
 
275
+ if(isset($property['description'] ) && $property['description'] !== '') {
276
  echo '<div class="yasr-itemtype-row-container-description">'
277
  . $property['description'] .
278
  '</div>';
327
  'OnlineOnly', 'OutOfStock', 'PreOrder'. 'PreSale', 'SoldOut'
328
  );
329
 
330
+ $string_input = YasrPhpFieldsHelper::select(
331
  '', $info['label'], $array_global_availability, $info['name'], '', esc_attr($saved_data[$info['name']])
332
  );
333
  }
334
  else {
335
+ $string_input = YasrPhpFieldsHelper::text(
336
  '', $info['label'], $info['name'], '', '', esc_attr($saved_data[$info['name']])
337
  );
338
  }
admin/js/yasr-admin.js CHANGED
@@ -1,133 +1 @@
1
- /******/ (function(modules) { // webpackBootstrap
2
- /******/ // The module cache
3
- /******/ var installedModules = {};
4
- /******/
5
- /******/ // The require function
6
- /******/ function __webpack_require__(moduleId) {
7
- /******/
8
- /******/ // Check if module is in cache
9
- /******/ if(installedModules[moduleId]) {
10
- /******/ return installedModules[moduleId].exports;
11
- /******/ }
12
- /******/ // Create a new module (and put it into the cache)
13
- /******/ var module = installedModules[moduleId] = {
14
- /******/ i: moduleId,
15
- /******/ l: false,
16
- /******/ exports: {}
17
- /******/ };
18
- /******/
19
- /******/ // Execute the module function
20
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
- /******/
22
- /******/ // Flag the module as loaded
23
- /******/ module.l = true;
24
- /******/
25
- /******/ // Return the exports of the module
26
- /******/ return module.exports;
27
- /******/ }
28
- /******/
29
- /******/
30
- /******/ // expose the modules object (__webpack_modules__)
31
- /******/ __webpack_require__.m = modules;
32
- /******/
33
- /******/ // expose the module cache
34
- /******/ __webpack_require__.c = installedModules;
35
- /******/
36
- /******/ // define getter function for harmony exports
37
- /******/ __webpack_require__.d = function(exports, name, getter) {
38
- /******/ if(!__webpack_require__.o(exports, name)) {
39
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40
- /******/ }
41
- /******/ };
42
- /******/
43
- /******/ // define __esModule on exports
44
- /******/ __webpack_require__.r = function(exports) {
45
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47
- /******/ }
48
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
49
- /******/ };
50
- /******/
51
- /******/ // create a fake namespace object
52
- /******/ // mode & 1: value is a module id, require it
53
- /******/ // mode & 2: merge all properties of value into the ns
54
- /******/ // mode & 4: return value when already ns object
55
- /******/ // mode & 8|1: behave like require
56
- /******/ __webpack_require__.t = function(value, mode) {
57
- /******/ if(mode & 1) value = __webpack_require__(value);
58
- /******/ if(mode & 8) return value;
59
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60
- /******/ var ns = Object.create(null);
61
- /******/ __webpack_require__.r(ns);
62
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64
- /******/ return ns;
65
- /******/ };
66
- /******/
67
- /******/ // getDefaultExport function for compatibility with non-harmony modules
68
- /******/ __webpack_require__.n = function(module) {
69
- /******/ var getter = module && module.__esModule ?
70
- /******/ function getDefault() { return module['default']; } :
71
- /******/ function getModuleExports() { return module; };
72
- /******/ __webpack_require__.d(getter, 'a', getter);
73
- /******/ return getter;
74
- /******/ };
75
- /******/
76
- /******/ // Object.prototype.hasOwnProperty.call
77
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78
- /******/
79
- /******/ // __webpack_public_path__
80
- /******/ __webpack_require__.p = "";
81
- /******/
82
- /******/
83
- /******/ // Load entry module and return exports
84
- /******/ return __webpack_require__(__webpack_require__.s = 0);
85
- /******/ })
86
- /************************************************************************/
87
- /******/ ({
88
-
89
- /***/ "./admin/js/src/yasr-dashboard.js":
90
- /*!****************************************!*\
91
- !*** ./admin/js/src/yasr-dashboard.js ***!
92
- \****************************************/
93
- /*! no static exports found */
94
- /***/ (function(module, exports) {
95
-
96
- eval("//Vote log\njQuery(document).ready(function () {\n\n //Log\n jQuery('.yasr-log-pagenum').on('click', function () {\n\n jQuery('#yasr-loader-log-metabox').show();\n\n var data = {\n action: 'yasr_change_log_page',\n pagenum: jQuery(this).val(),\n totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')\n\n };\n\n jQuery.post(ajaxurl, data, function (response) {\n jQuery('#yasr-loader-log-metabox').hide();\n jQuery('#yasr-log-container').html(response);\n });\n\n });\n\n jQuery(document).ajaxComplete(function (event, xhr, settings) {\n var isYasrAjaxCall = true;\n\n if(settings.data !== 'undefined') {\n //check if the ajax call is done by yasr with action yasr_change_log_page\n isYasrAjaxCall = settings.data.search(\"action=yasr_change_log_page\");\n }\n\n if (isYasrAjaxCall !== -1) {\n jQuery('.yasr-log-pagenum').on('click', function () {\n jQuery('#yasr-loader-log-metabox').show();\n\n var data = {\n action: 'yasr_change_log_page',\n pagenum: jQuery(this).val(),\n totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')\n };\n\n jQuery.post(ajaxurl, data, function (response) {\n jQuery('#yasr-log-container').html(response); //This will hide the loader gif too\n });\n });\n }\n\n });\n\n});\n\n\n//Vote user log\njQuery(document).ready(function () {\n\n //Log\n jQuery('.yasr-user-log-page-num').on('click', function () {\n jQuery('#yasr-loader-user-log-metabox').show();\n var data = {\n action: 'yasr_change_user_log_page',\n pagenum: jQuery(this).val(),\n totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')\n\n };\n jQuery.post(ajaxurl, data, function (response) {\n jQuery('#yasr-loader-log-metabox').hide();\n jQuery('#yasr-user-log-container').html(response);\n });\n });\n\n jQuery(document).ajaxComplete(function (event, xhr, settings) {\n var isYasrAjaxCall = true;\n\n if (typeof settings.data === 'undefined') {\n return;\n }\n\n //check if the ajax call is done by yasr with action yasr_change_log_page\n isYasrAjaxCall = settings.data.search(\"action=yasr_change_user_log_page\");\n\n if (isYasrAjaxCall !== -1) {\n jQuery('.yasr-user-log-page-num').on('click', function () {\n jQuery('#yasr-loader-user-log-metabox').show();\n\n var data = {\n action: 'yasr_change_user_log_page',\n pagenum: jQuery(this).val(),\n totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-log-total-pages')\n };\n\n jQuery.post(ajaxurl, data, function (response) {\n jQuery('#yasr-user-log-container').html(response); //This will hide the loader gif too\n });\n });\n\n }\n\n });\n\n});\n\n//# sourceURL=webpack:///./admin/js/src/yasr-dashboard.js?");
97
-
98
- /***/ }),
99
-
100
- /***/ "./admin/js/src/yasr-functions.js":
101
- /*!****************************************!*\
102
- !*** ./admin/js/src/yasr-functions.js ***!
103
- \****************************************/
104
- /*! no static exports found */
105
- /***/ (function(module, exports) {
106
-
107
- eval("copyToClipboard = string => {\n const el = document.createElement('textarea');\n el.value = string;\n el.setAttribute('readonly', '');\n el.style.position = 'absolute';\n el.style.left = '-9999px';\n document.body.appendChild(el);\n el.select();\n document.execCommand('copy');\n document.body.removeChild(el);\n};\n\ntippy(\n document.querySelectorAll('.yasr-copy-shortcode'),\n {\n content: 'Copied! Insert into your post!',\n theme: 'yasr',\n arrow: 'true',\n arrowType: 'round',\n trigger: 'click'\n }\n);\n\n//# sourceURL=webpack:///./admin/js/src/yasr-functions.js?");
108
-
109
- /***/ }),
110
-
111
- /***/ "./admin/js/src/yasr-settings-page.js":
112
- /*!********************************************!*\
113
- !*** ./admin/js/src/yasr-settings-page.js ***!
114
- \********************************************/
115
- /*! no static exports found */
116
- /***/ (function(module, exports) {
117
-
118
- eval("/****** Yasr Settings Page ******/\n\ndocument.addEventListener('DOMContentLoaded', function(event) {\n\n if (typeof document.getElementsByClassName('nav-tab-active')[0] === 'undefined') {\n return;\n }\n\n //get active Tab\n let activeTab = document.getElementsByClassName('nav-tab-active')[0].id;\n\n //-------------------General Settings Code---------------------\n if (activeTab === 'general_settings') {\n\n let autoInsertEnabled = document.getElementById('yasr_auto_insert_switch').checked;\n let textBeforeStars = document.getElementById('yasr-general-options-text-before-stars-switch').checked;\n\n if (autoInsertEnabled === false) {\n jQuery('.yasr-auto-insert-options-class').prop('disabled', true);\n }\n\n //First Div, for auto insert\n jQuery('#yasr_auto_insert_switch').change(function () {\n if (jQuery(this).is(':checked')) {\n jQuery('.yasr-auto-insert-options-class').prop('disabled', false);\n } else {\n jQuery('.yasr-auto-insert-options-class').prop('disabled', true);\n }\n });\n\n //for text before stars\n if (textBeforeStars === false) {\n jQuery('.yasr-general-options-text-before').prop('disabled', true);\n }\n\n jQuery('#yasr-general-options-text-before-stars-switch').change(function () {\n if (jQuery(this).is(':checked')) {\n\n jQuery('.yasr-general-options-text-before').prop('disabled', false);\n jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');\n jQuery('#yasr-general-options-custom-text-before-visitor').val('Click to rate this post!');\n jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');\n jQuery('#yasr-general-options-custom-text-must-sign-in').val('You must sign in to vote');\n jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted for this article');\n\n } else {\n jQuery('.yasr-general-options-text-before').prop('disabled', true);\n }\n\n });\n\n jQuery('#yasr-doc-custom-text-link').on('click', function () {\n jQuery('#yasr-doc-custom-text-div').toggle('slow');\n return false;\n });\n\n jQuery('#yasr-stats-explained-link').on('click', function () {\n jQuery('#yasr-stats-explained').toggle('slow');\n return false;\n });\n\n } //End if general settings\n\n\n //--------------Multi Sets Page ------------------\n if (activeTab === 'manage_multi') {\n\n let nMultiSet = document.getElementById('n-multiset').value;\n\n jQuery('#yasr-multi-set-doc-link').on('click', function () {\n jQuery('#yasr-multi-set-doc-box').toggle(\"slow\");\n });\n\n jQuery('#yasr-multi-set-doc-link-hide').on('click', function () {\n jQuery('#yasr-multi-set-doc-box').toggle(\"slow\");\n });\n\n if (nMultiSet === 1) {\n var counter = jQuery(\"#yasr-edit-form-number-elements\").attr('value');\n\n counter++;\n\n jQuery(\"#yasr-add-field-edit-multiset\").on('click', function () {\n if (counter > 9) {\n jQuery('#yasr-element-limit').show();\n jQuery('#yasr-add-field-edit-multiset').hide();\n return false;\n }\n\n var newTextBoxDiv = jQuery(document.createElement('tr'));\n newTextBoxDiv.html('<td colspan=\"2\">Element #' + counter + ' <input type=\"text\" name=\"edit-multi-set-element-' + counter + '\" value=\"\" ></td>');\n newTextBoxDiv.appendTo(\"#yasr-table-form-edit-multi-set\");\n counter++;\n });\n\n\n } //End if ($n_multi_set == 1)\n\n if (nMultiSet > 1) {\n\n //If more then 1 set is used...\n jQuery('#yasr-button-select-set-edit-form').on(\"click\", function () {\n\n var data = {\n action: 'yasr_get_multi_set',\n set_id: jQuery('#yasr_select_edit_set').val()\n };\n\n jQuery.post(ajaxurl, data, function (response) {\n jQuery('#yasr-multi-set-response').show();\n jQuery('#yasr-multi-set-response').html(response);\n });\n\n return false; // prevent default click action from happening!\n\n });\n\n jQuery(document).ajaxComplete(function () {\n var counter = jQuery(\"#yasr-edit-form-number-elements\").attr('value');\n counter++;\n\n jQuery(\"#yasr-add-field-edit-multiset\").on('click', function () {\n if (counter > 9) {\n jQuery('#yasr-element-limit').show();\n jQuery('#yasr-add-field-edit-multiset').hide();\n return false;\n }\n var newTextBoxDiv = jQuery(document.createElement('tr'));\n newTextBoxDiv.html('<td colspan=\"2\">Element #' + counter + ' <input type=\"text\" name=\"edit-multi-set-element-' + counter + '\" value=\"\" ></td>');\n newTextBoxDiv.appendTo(\"#yasr-table-form-edit-multi-set\");\n counter++;\n });\n\n });\n\n } //End if ($n_multi_set > 1)\n\n } //end if active_tab=='manage_multi'\n\n if (activeTab === 'style_options') {\n wp.codeEditor.initialize(\n document.getElementById('yasr_style_options_textarea'),\n yasr_cm_settings\n );\n\n jQuery('#yasr-color-scheme-preview-link').on('click', function () {\n jQuery('#yasr-color-scheme-preview').toggle('slow');\n return false; // prevent default click action from happening!\n });\n\n }\n\n if (activeTab === 'migration_tools') {\n jQuery('#yasr-import-ratemypost-submit').on('click', function () {\n\n //show loader on click\n document.getElementById('yasr-import-ratemypost-answer').innerHTML = '<img src=\"'\n + yasrCommonDataAdmin.loaderHtml + '\"</img>';\n\n var nonce = document.getElementById('yasr-import-rmp-nonce').value;\n\n var data = {\n action: 'yasr_import_ratemypost',\n nonce: nonce\n };\n\n jQuery.post(ajaxurl, data, function (response) {\n response = JSON.parse(response);\n document.getElementById('yasr-import-ratemypost-answer').innerHTML = response;\n });\n\n });\n\n jQuery('#yasr-import-wppr-submit').on('click', function () {\n\n //show loader on click\n document.getElementById('yasr-import-wppr-answer').innerHTML = '<img src=\"'\n + yasrCommonDataAdmin.loaderHtml + '\"</img>';\n\n var nonce = document.getElementById('yasr-import-wppr-nonce').value;\n\n var data = {\n action: 'yasr_import_wppr',\n nonce: nonce\n };\n\n jQuery.post(ajaxurl, data, function (response) {\n //response = JSON.parse(response);\n document.getElementById('yasr-import-wppr-answer').innerHTML = response;\n });\n\n });\n\n jQuery('#yasr-import-kksr-submit').on('click', function () {\n\n //show loader on click\n document.getElementById('yasr-import-kksr-answer').innerHTML = '<img src=\"'\n + yasrCommonDataAdmin.loaderHtml + '\"</img>';\n\n var nonce = document.getElementById('yasr-import-kksr-nonce').value;\n\n var data = {\n action: 'yasr_import_kksr',\n nonce: nonce\n };\n\n jQuery.post(ajaxurl, data, function (response) {\n //response = JSON.parse(response);\n document.getElementById('yasr-import-kksr-answer').innerHTML = response;\n });\n\n });\n\n //import multi rating\n jQuery('#yasr-import-mr-submit').on('click', function () {\n\n //show loader on click\n document.getElementById('yasr-import-mr-answer').innerHTML = '<img src=\"'\n + yasrCommonDataAdmin.loaderHtml + '\"</img>';\n\n var nonce = document.getElementById('yasr-import-mr-nonce').value;\n\n var data = {\n action: 'yasr_import_mr',\n nonce: nonce\n };\n\n jQuery.post(ajaxurl, data, function (response) {\n //response = JSON.parse(response);\n document.getElementById('yasr-import-mr-answer').innerHTML = response;\n });\n\n });\n }\n});\n\n/****** End Yasr Settings Page ******/\n\n//# sourceURL=webpack:///./admin/js/src/yasr-settings-page.js?");
119
-
120
- /***/ }),
121
-
122
- /***/ 0:
123
- /*!********************************************************************************************************************!*\
124
- !*** multi ./admin/js/src/yasr-functions.js ./admin/js/src/yasr-dashboard.js ./admin/js/src/yasr-settings-page.js ***!
125
- \********************************************************************************************************************/
126
- /*! no static exports found */
127
- /***/ (function(module, exports, __webpack_require__) {
128
-
129
- eval("__webpack_require__(/*! ./admin/js/src/yasr-functions.js */\"./admin/js/src/yasr-functions.js\");\n__webpack_require__(/*! ./admin/js/src/yasr-dashboard.js */\"./admin/js/src/yasr-dashboard.js\");\nmodule.exports = __webpack_require__(/*! ./admin/js/src/yasr-settings-page.js */\"./admin/js/src/yasr-settings-page.js\");\n\n\n//# sourceURL=webpack:///multi_./admin/js/src/yasr-functions.js_./admin/js/src/yasr-dashboard.js_./admin/js/src/yasr-settings-page.js?");
130
-
131
- /***/ })
132
-
133
- /******/ });
1
+ !function(e){var t={};function r(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(o,a,function(t){return e[t]}.bind(null,a));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1),r(2),e.exports=r(3)},function(e,t){copyToClipboard=e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)},tippy(document.querySelectorAll(".yasr-copy-shortcode"),{content:"Copied! Insert into your post!",theme:"yasr",arrow:"true",arrowType:"round",trigger:"click"})},function(e,t){jQuery(document).ready((function(){jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,r){var o=!0;"undefined"!==r.data&&(o=r.data.search("action=yasr_change_log_page")),-1!==o&&jQuery(".yasr-log-pagenum").on("click",(function(){jQuery("#yasr-loader-log-metabox").show();var e={action:"yasr_change_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-log-container").html(e)}))}))}))})),jQuery(document).ready((function(){jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-loader-log-metabox").hide(),jQuery("#yasr-user-log-container").html(e)}))})),jQuery(document).ajaxComplete((function(e,t,r){void 0!==r.data&&-1!==r.data.search("action=yasr_change_user_log_page")&&jQuery(".yasr-user-log-page-num").on("click",(function(){jQuery("#yasr-loader-user-log-metabox").show();var e={action:"yasr_change_user_log_page",pagenum:jQuery(this).val(),totalpages:jQuery("#yasr-user-log-total-pages").data("yasr-log-total-pages")};jQuery.post(ajaxurl,e,(function(e){jQuery("#yasr-user-log-container").html(e)}))}))}))}))},function(e,t){document.addEventListener("DOMContentLoaded",(function(e){if(void 0===document.getElementsByClassName("nav-tab-active")[0])return;let t=document.getElementsByClassName("nav-tab-active")[0].id;if("general_settings"===t){let e=document.getElementById("yasr_auto_insert_switch").checked,t=document.getElementById("yasr-general-options-text-before-stars-switch").checked;!1===e&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),jQuery("#yasr_auto_insert_switch").change((function(){jQuery(this).is(":checked")?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),!1===t&&jQuery(".yasr-general-options-text-before").prop("disabled",!0),jQuery("#yasr-general-options-text-before-stars-switch").change((function(){jQuery(this).is(":checked")?(jQuery(".yasr-general-options-text-before").prop("disabled",!1),jQuery("#yasr-general-options-custom-text-before-overall").val("Our Score"),jQuery("#yasr-general-options-custom-text-before-visitor").val("Click to rate this post!"),jQuery("#yasr-general-options-custom-text-after-visitor").val("[Total: %total_count% Average: %average%]"),jQuery("#yasr-general-options-custom-text-must-sign-in").val("You must sign in to vote"),jQuery("#yasr-general-options-custom-text-already-rated").val("You have already voted for this article")):jQuery(".yasr-general-options-text-before").prop("disabled",!0)})),jQuery("#yasr-doc-custom-text-link").on("click",(function(){return jQuery("#yasr-doc-custom-text-div").toggle("slow"),!1})),jQuery("#yasr-stats-explained-link").on("click",(function(){return jQuery("#yasr-stats-explained").toggle("slow"),!1}))}if("manage_multi"===t){let e=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===e){var r=jQuery("#yasr-edit-form-number-elements").attr("value");r++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(r>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+r+' <input type="text" name="edit-multi-set-element-'+r+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),r++}))}e>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++}))})))}"style_options"===t&&(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}))),"migration_tools"===t&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,e,(function(e){e=JSON.parse(e),document.getElementById("yasr-import-ratemypost-answer").innerHTML=e}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-wppr-answer").innerHTML=e}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-kksr-answer").innerHTML=e}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonDataAdmin.loaderHtml+'"</img>';var e={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,e,(function(e){document.getElementById("yasr-import-mr-answer").innerHTML=e}))})))}))}]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/settings/yasr-settings-functions.php CHANGED
@@ -199,7 +199,7 @@ function yasr_auto_insert_callback($option) {
199
  $name = 'yasr_general_options[auto_insert_what]';
200
  $class = 'yasr-auto-insert-options-class';
201
 
202
- YasrSettings::printRadioType( $option_title, $array_options, $name, $class, $default);
203
  ?>
204
  </div>
205
 
@@ -216,7 +216,7 @@ function yasr_auto_insert_callback($option) {
216
  $name = 'yasr_general_options[auto_insert_where]';
217
  $class = 'yasr-auto-insert-options-class';
218
 
219
- YasrSettings::printRadioType( $option_title, $array_options, $name, $class, $default);
220
  ?>
221
  </div>
222
 
@@ -234,7 +234,7 @@ function yasr_auto_insert_callback($option) {
234
  $name = 'yasr_general_options[auto_insert_align]';
235
  $class = 'yasr-auto-insert-options-class';
236
 
237
- YasrSettings::printRadioType($option_title, $array_options, $name, $class, $default);
238
  ?>
239
 
240
  </div>
@@ -265,7 +265,7 @@ function yasr_auto_insert_callback($option) {
265
  $name = 'yasr_general_options[auto_insert_exclude_pages]';
266
  $class = 'yasr-auto-insert-options-class';
267
 
268
- YasrSettings::printRadioType($option_title, $array_options, $name, $class, $default);
269
  ?>
270
  <p>&nbsp;</p>
271
  </div>
@@ -287,7 +287,7 @@ function yasr_auto_insert_callback($option) {
287
  $name = 'yasr_general_options[auto_insert_custom_post_only]';
288
  $class = 'yasr-auto-insert-options-class';
289
 
290
- YasrSettings::printRadioType($option_title, $array_options, $name, $class, $default);
291
 
292
  echo '</div>';
293
  ?>
@@ -309,10 +309,7 @@ function yasr_auto_insert_callback($option) {
309
  <?php
310
  }
311
 
312
- ?>
313
-
314
- <?php
315
- submit_button(YASR_SAVE_All_SETTINGS_TEXT);
316
  ?>
317
 
318
  </div>
@@ -346,69 +343,74 @@ function yasr_custom_text_callback($option) {
346
 
347
  <br/> <br/>
348
 
349
- <input type='text' name='yasr_general_options[text_before_overall]'
350
- id="yasr-general-options-custom-text-before-overall"
351
- class='yasr-general-options-text-before' <?php printf('value="%s"', $text_before_overall); ?>
352
- maxlength="40"/>
353
- <?php _e('Custom text to display before Overall Rating', 'yet-another-stars-rating') ?>
 
 
354
 
355
  <br/> <br/> <br/>
356
 
357
- <input type='text' name='yasr_general_options[text_before_visitor_rating]'
358
- id="yasr-general-options-custom-text-before-visitor"
359
- class='yasr-general-options-text-before' <?php printf('value="%s"', $text_before_visitor_rating); ?>
360
- maxlength="80"/>
361
- <?php _e('Custom text to display BEFORE Visitor Rating', 'yet-another-stars-rating') ?>
 
 
362
 
363
  <br/> <br/>
364
 
365
- <input type='text' name='yasr_general_options[text_after_visitor_rating]'
366
- id="yasr-general-options-custom-text-after-visitor"
367
- class='yasr-general-options-text-before' <?php printf('value="%s"', $text_after_visitor_rating); ?>
368
- maxlength="80"/>
369
- <?php _e('Custom text to display AFTER Visitor Rating', 'yet-another-stars-rating') ?>
 
 
370
 
371
  <br/> <br/> <br/>
372
 
373
- <input type='text' name='yasr_general_options[custom_text_must_sign_in]'
374
- id="yasr-general-options-custom-text-must-sign-in"
375
- class='yasr-general-options-text-before' <?php printf('value="%s"', $custom_text_must_sign_in); ?>
376
- maxlength="60"/>
377
- <?php _e('Custom text to display when login is required to vote', 'yet-another-stars-rating') ?>
378
-
 
379
  <br/> <br/>
380
 
381
- <input type='text' name='yasr_general_options[custom_text_user_voted]'
382
- id="yasr-general-options-custom-text-already-rated"
383
- class='yasr-general-options-text-before' <?php printf('value="%s"', $custom_text_user_votes); ?>
384
- maxlength="60"/>
385
- <?php _e('Custom text to display when a non logged user has already rated', 'yet-another-stars-rating') ?>
386
-
 
387
 
388
  <br/> <br/>
389
 
390
  <a href="#" id="yasr-doc-custom-text-link"><?php _e('Help', 'yet-another-stars-rating'); ?></a>
391
 
392
  <div id="yasr-doc-custom-text-div" class="yasr-help-box-settings">
393
-
394
  <?php
395
- $string_custom_overall = sprintf(__('In the first field you can use %s pattern to show the overall rating.',
396
- 'yet-another-stars-rating'), '<strong>%overall_rating%</strong>');
397
 
398
- $string_custom_visitor = sprintf(__('In the Second and Third fields you can use %s pattern to show the
399
- total count, and %s pattern to show the average', 'yet-another-stars-rating'),
400
- '<strong>%total_count%</strong>', '<strong>%average%</strong>');
401
 
402
- echo $string_custom_overall;
403
- echo '<br /><br/>';
404
- echo $string_custom_visitor;
405
- echo '<br /><br/>';
406
-
407
- _e('You can use these html tags:', 'yet-another-stars-rating');
408
- echo ' <strong>' . esc_html('<strong>, <p>') . '.</strong>';
409
 
 
 
410
  ?>
411
-
412
  </div>
413
 
414
  <p>&nbsp;</p>
@@ -478,7 +480,7 @@ function yasr_allow_only_logged_in_callback($option) {
478
  $name = 'yasr_general_options[allowed_user]';
479
  $class = 'yasr_auto_insert_loggedonly';
480
 
481
- YasrSettings::printRadioType( false, $array_options, $name, $class, $default );
482
  ?>
483
 
484
  <br />
@@ -649,7 +651,7 @@ function yasr_choose_snippet_callback($option) {
649
  $name = 'yasr_general_options[publisher]';
650
  $id = 'yasr-general-options-publisher';
651
 
652
- YasrSettings::printRadioType( $option_title, $array_options, $name, '', $default, $id );
653
  ?>
654
 
655
  <br/>
199
  $name = 'yasr_general_options[auto_insert_what]';
200
  $class = 'yasr-auto-insert-options-class';
201
 
202
+ echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
203
  ?>
204
  </div>
205
 
216
  $name = 'yasr_general_options[auto_insert_where]';
217
  $class = 'yasr-auto-insert-options-class';
218
 
219
+ echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
220
  ?>
221
  </div>
222
 
234
  $name = 'yasr_general_options[auto_insert_align]';
235
  $class = 'yasr-auto-insert-options-class';
236
 
237
+ echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
238
  ?>
239
 
240
  </div>
265
  $name = 'yasr_general_options[auto_insert_exclude_pages]';
266
  $class = 'yasr-auto-insert-options-class';
267
 
268
+ echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
269
  ?>
270
  <p>&nbsp;</p>
271
  </div>
287
  $name = 'yasr_general_options[auto_insert_custom_post_only]';
288
  $class = 'yasr-auto-insert-options-class';
289
 
290
+ echo YasrPhpFieldsHelper::radio( $option_title, $class, $array_options, $name, $default );
291
 
292
  echo '</div>';
293
  ?>
309
  <?php
310
  }
311
 
312
+ submit_button(YASR_SAVE_All_SETTINGS_TEXT);
 
 
 
313
  ?>
314
 
315
  </div>
343
 
344
  <br/> <br/>
345
 
346
+ <label for="yasr-general-options-custom-text-before-overall">
347
+ <input type='text' name='yasr_general_options[text_before_overall]'
348
+ id="yasr-general-options-custom-text-before-overall"
349
+ class='yasr-general-options-text-before' <?php printf('value="%s"', $text_before_overall); ?>
350
+ maxlength="40"/>
351
+ <?php _e('Custom text to display before Overall Rating', 'yet-another-stars-rating') ?>
352
+ </label>
353
 
354
  <br/> <br/> <br/>
355
 
356
+ <label for="yasr-general-options-custom-text-before-visitor">
357
+ <input type='text' name='yasr_general_options[text_before_visitor_rating]'
358
+ id="yasr-general-options-custom-text-before-visitor"
359
+ class='yasr-general-options-text-before' <?php printf('value="%s"', $text_before_visitor_rating); ?>
360
+ maxlength="80"/>
361
+ <?php _e('Custom text to display BEFORE Visitor Rating', 'yet-another-stars-rating') ?>
362
+ </label>
363
 
364
  <br/> <br/>
365
 
366
+ <label for="yasr-general-options-custom-text-after-visitor">
367
+ <input type='text' name='yasr_general_options[text_after_visitor_rating]'
368
+ id="yasr-general-options-custom-text-after-visitor"
369
+ class='yasr-general-options-text-before' <?php printf('value="%s"', $text_after_visitor_rating); ?>
370
+ maxlength="80"/>
371
+ <?php _e('Custom text to display AFTER Visitor Rating', 'yet-another-stars-rating') ?>
372
+ </label>
373
 
374
  <br/> <br/> <br/>
375
 
376
+ <label for="yasr-general-options-custom-text-must-sign-in">
377
+ <input type='text' name='yasr_general_options[custom_text_must_sign_in]'
378
+ id="yasr-general-options-custom-text-must-sign-in"
379
+ class='yasr-general-options-text-before' <?php printf('value="%s"', $custom_text_must_sign_in); ?>
380
+ maxlength="60"/>
381
+ <?php _e('Custom text to display when login is required to vote', 'yet-another-stars-rating') ?>
382
+ </label>
383
  <br/> <br/>
384
 
385
+ <label for="yasr-general-options-custom-text-already-rated">
386
+ <input type='text' name='yasr_general_options[custom_text_user_voted]'
387
+ id="yasr-general-options-custom-text-already-rated"
388
+ class='yasr-general-options-text-before' <?php printf('value="%s"', $custom_text_user_votes); ?>
389
+ maxlength="60"/>
390
+ <?php _e('Custom text to display when a non logged user has already rated', 'yet-another-stars-rating') ?>
391
+ </label>
392
 
393
  <br/> <br/>
394
 
395
  <a href="#" id="yasr-doc-custom-text-link"><?php _e('Help', 'yet-another-stars-rating'); ?></a>
396
 
397
  <div id="yasr-doc-custom-text-div" class="yasr-help-box-settings">
 
398
  <?php
399
+ $string_custom_overall = sprintf(__('In the first field you can use %s pattern to show the overall rating.',
400
+ 'yet-another-stars-rating'), '<strong>%overall_rating%</strong>');
401
 
402
+ $string_custom_visitor = sprintf(__('In the Second and Third fields you can use %s pattern to show the
403
+ total count, and %s pattern to show the average', 'yet-another-stars-rating'),
404
+ '<strong>%total_count%</strong>', '<strong>%average%</strong>');
405
 
406
+ echo $string_custom_overall;
407
+ echo '<br /><br/>';
408
+ echo $string_custom_visitor;
409
+ echo '<br /><br/>';
 
 
 
410
 
411
+ _e('You can use these html tags:', 'yet-another-stars-rating');
412
+ echo ' <strong>' . esc_html('<strong>, <p>') . '.</strong>';
413
  ?>
 
414
  </div>
415
 
416
  <p>&nbsp;</p>
480
  $name = 'yasr_general_options[allowed_user]';
481
  $class = 'yasr_auto_insert_loggedonly';
482
 
483
+ echo YasrPhpFieldsHelper::radio( false, $class, $array_options, $name, $default );
484
  ?>
485
 
486
  <br />
651
  $name = 'yasr_general_options[publisher]';
652
  $id = 'yasr-general-options-publisher';
653
 
654
+ echo YasrPhpFieldsHelper::radio( $option_title, '', $array_options, $name, $default, $id );
655
  ?>
656
 
657
  <br/>
includes/classes/YasrPhpFieldsHelper.php CHANGED
@@ -18,14 +18,80 @@ class YasrPhpFieldsHelper {
18
  *
19
  * @var string
20
  */
21
- public $field_class;
22
 
23
  public function __construct($field_class=false) {
24
  if($field_class) {
25
- $this->field_class = htmlspecialchars($field_class);
26
  }
27
  }
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  /**
30
  * @param bool|string $class
31
  * @param bool|string|int $label
@@ -36,8 +102,8 @@ class YasrPhpFieldsHelper {
36
  *
37
  * @return string
38
  */
39
- public function text($class=false, $label=false, $name=false, $id=false, $placeholder=false, $default_value=false) {
40
- $attribute = $this->escape_attributes($class, $label, $name, $id, $default_value, $placeholder);
41
 
42
  $container = "<div class='$attribute[class]'>";
43
  $label_string = "<label for='$attribute[id]'>$attribute[label]</label>";
@@ -58,9 +124,9 @@ class YasrPhpFieldsHelper {
58
  *
59
  * @return string
60
  */
61
- public function select($class=false, $label=false, $options=[], $name=false, $id=false, $default_value=false) {
62
- $attribute = $this->escape_attributes($class, $label, $name, $id, $default_value);
63
- $select_options = $this->escape_array($options);
64
 
65
  $container = "<div class='$attribute[class]'>";
66
  $label_string = "<label for='$attribute[id]'>$attribute[label]</label>";
@@ -89,8 +155,8 @@ class YasrPhpFieldsHelper {
89
  *
90
  * @return string
91
  */
92
- public function textArea($class=false, $label=false, $name=false, $id=false, $placeholder=false, $default_value=false) {
93
- $attribute = $this->escape_attributes($class, $label, $name, $id, $default_value, $placeholder);
94
 
95
  $container = "<div class='$attribute[class]'>";
96
  $label_string = "<label for='$attribute[id]'>$attribute[label]</label>";
@@ -112,10 +178,25 @@ class YasrPhpFieldsHelper {
112
  *
113
  * @return array
114
  */
115
- private function escape_attributes($class=false, $label=false, $name=false, $id=false, $default_value=false, $placeholder=false ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  //Use the $this->field_class attribute if $class is false or empty
117
- if(!$class && $this->field_class) {
118
- $class = $this->field_class;
119
  }
120
 
121
  //if id is not set but name is, id get same value as name
@@ -133,16 +214,16 @@ class YasrPhpFieldsHelper {
133
  }
134
 
135
  return array(
136
- 'class' => htmlspecialchars($class, ENT_QUOTES),
137
- 'id' => htmlspecialchars($id, ENT_QUOTES),
138
- 'label' => htmlspecialchars($label, ENT_QUOTES),
139
- 'name' => htmlspecialchars($name, ENT_QUOTES),
140
- 'placeholder' => htmlspecialchars($placeholder, ENT_QUOTES),
141
- 'value' => htmlspecialchars($default_value, ENT_QUOTES),
142
  );
143
  }
144
 
145
- private function escape_array($array=[]) {
146
  $cleaned_array = [];
147
  if(!is_array($array)) {
148
  return $cleaned_array;
18
  *
19
  * @var string
20
  */
21
+ public static $field_class;
22
 
23
  public function __construct($field_class=false) {
24
  if($field_class) {
25
+ self::$field_class = htmlspecialchars($field_class);
26
  }
27
  }
28
 
29
+ /**
30
+ * @param bool|string $title
31
+ * @param bool|string $class
32
+ * @param array $options
33
+ * @param bool|string $name
34
+ * @param bool|string|int $default_value
35
+ * @param bool|string $id
36
+ */
37
+ public static function radio($title=false, $class=false, $options=[], $name=false, $default_value=false, $id=false) {
38
+ $attribute = self::escape_attributes($class, $title, $name, $id, $default_value, false );
39
+ $radio_options = self::escape_array($options);
40
+
41
+ $container = '';
42
+ $end_container = '';
43
+
44
+ $title_string = '';
45
+ if($attribute['title']) {
46
+ $title_string .= '<strong>' . $attribute['title'] . '</strong><br />';
47
+ }
48
+
49
+ if (is_array($radio_options)) {
50
+
51
+ $container .= '<div class="yasr-indented-answer">';
52
+
53
+ $radio_fields = '';
54
+ foreach ( $options as $value => $label ) {
55
+ $id_string = $id . '-' . strtolower( trim( str_replace( ' ', '', $value ) ) );
56
+ //must be inside foreach, or when loop arrive to last element
57
+ //checked is defined
58
+ $checked = '';
59
+
60
+ //If db_value === false, there is no need to check for db value
61
+ //so checked is the medium star (i.e. ranking page)
62
+ if ( $default_value === $value ) {
63
+ $checked = 'checked';
64
+ }
65
+
66
+ //string value must be empty
67
+ if ( $value === 0 ) {
68
+ $value = '';
69
+ }
70
+
71
+ $radio_fields .= sprintf( '<div>
72
+ <label for="%s">
73
+ <input type="radio"
74
+ name="%s"
75
+ value="%s"
76
+ class="%s"
77
+ id="%s"
78
+ %s
79
+ >
80
+ %s
81
+ </label>
82
+ </div>',
83
+ $id_string, $name, $value, $class, $id_string, $checked,
84
+ __( ucwords( $label ), 'yet-another-stars-rating' ) );
85
+
86
+ } //end foreach
87
+
88
+ $end_container .= '</div>';
89
+
90
+ return $container . $title_string . $radio_fields . $end_container;
91
+ }
92
+ return false;
93
+ }
94
+
95
  /**
96
  * @param bool|string $class
97
  * @param bool|string|int $label
102
  *
103
  * @return string
104
  */
105
+ public static function text($class=false, $label=false, $name=false, $id=false, $placeholder=false, $default_value=false) {
106
+ $attribute = self::escape_attributes($class, $label, $name, $id, $default_value, $placeholder);
107
 
108
  $container = "<div class='$attribute[class]'>";
109
  $label_string = "<label for='$attribute[id]'>$attribute[label]</label>";
124
  *
125
  * @return string
126
  */
127
+ public static function select($class=false, $label=false, $options=[], $name=false, $id=false, $default_value=false) {
128
+ $attribute = self::escape_attributes($class, $label, $name, $id, $default_value);
129
+ $select_options = self::escape_array($options);
130
 
131
  $container = "<div class='$attribute[class]'>";
132
  $label_string = "<label for='$attribute[id]'>$attribute[label]</label>";
155
  *
156
  * @return string
157
  */
158
+ public static function textArea($class=false, $label=false, $name=false, $id=false, $placeholder=false, $default_value=false) {
159
+ $attribute = self::escape_attributes($class, $label, $name, $id, $default_value, $placeholder);
160
 
161
  $container = "<div class='$attribute[class]'>";
162
  $label_string = "<label for='$attribute[id]'>$attribute[label]</label>";
178
  *
179
  * @return array
180
  */
181
+ private static function escape_attributes($class=false, $label=false, $name=false, $id=false, $default_value=false, $placeholder=false ) {
182
+
183
+ $dbt=debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,2);
184
+ $caller = isset($dbt[1]['function']) ? $dbt[1]['function'] : null;
185
+
186
+ //defalt value
187
+ $title_or_label = 'label';
188
+
189
+ if($caller === 'radio') {
190
+ $title_or_label = 'title';
191
+ if(!$name) {
192
+ $name = 'radio_group';
193
+
194
+ }
195
+ }
196
+
197
  //Use the $this->field_class attribute if $class is false or empty
198
+ if(!$class && self::$field_class) {
199
+ $class = self::$field_class;
200
  }
201
 
202
  //if id is not set but name is, id get same value as name
214
  }
215
 
216
  return array(
217
+ 'class' => htmlspecialchars($class, ENT_QUOTES),
218
+ 'id' => htmlspecialchars($id, ENT_QUOTES),
219
+ $title_or_label => htmlspecialchars($label, ENT_QUOTES),
220
+ 'name' => htmlspecialchars($name, ENT_QUOTES),
221
+ 'placeholder' => htmlspecialchars($placeholder, ENT_QUOTES),
222
+ 'value' => htmlspecialchars($default_value, ENT_QUOTES),
223
  );
224
  }
225
 
226
+ private static function escape_array($array=[]) {
227
  $cleaned_array = [];
228
  if(!is_array($array)) {
229
  return $cleaned_array;
includes/js/src/yasr-front.js ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { __ } = wp.i18n; // Import __() from wp.i18n
2
+
3
+ /*** Constant used by yasr
4
+
5
+ yasrCommonData (postid, ajaxurl, loggedUser, visitorStatsEnabled, loaderHtml, tooltipValues')
6
+
7
+ ***/
8
+
9
+ /****** Do this actions on document load ******/
10
+ document.addEventListener('DOMContentLoaded', function(event) {
11
+
12
+ //At pageload, check if there is some shortcode with class yasr-rater-stars
13
+ var yasrRaterInDom = document.getElementsByClassName('yasr-rater-stars');
14
+ //If so, call the function to set the rating
15
+ if (yasrRaterInDom.length > 0) {
16
+
17
+ //load this on everypageload
18
+ yasrSetRatingOnLoad(yasrRaterInDom);
19
+
20
+ }
21
+
22
+ //check if shortcode yasr_visitor_votes is used
23
+ var yasrRaterVVInDom = document.getElementsByClassName('yasr-rater-stars-visitor-votes');
24
+
25
+ if (yasrRaterVVInDom.length > 0) {
26
+ yasrVisitorVotesFront(yasrRaterVVInDom);
27
+ }
28
+
29
+ var yasrMultiSetVisitorInDom = document.getElementsByClassName('yasr-multiset-visitors-rater');
30
+
31
+ if (yasrMultiSetVisitorInDom.length > 0) {
32
+ yasrRaterVisitorsMultiSet(yasrMultiSetVisitorInDom)
33
+ }
34
+
35
+
36
+ //Check to draw tooltips
37
+ if (yasrRaterVVInDom) {
38
+ if (yasrCommonData.visitorStatsEnabled === 'yes') {
39
+ var yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
40
+ if (yasrStatsInDom) {
41
+ yasrDrawTipsProgress (yasrStatsInDom);
42
+ }
43
+ }
44
+ }
45
+
46
+ if (typeof yasrMostHighestRanking !== 'undefined') {
47
+
48
+ //By default, hide the highest rated chart
49
+ document.getElementById('yasr-highest-rated-posts').style.display = 'none';
50
+
51
+ }
52
+
53
+ });
54
+
55
+
56
+ //This work on top10 ranking chart, show the highest rated and hide most rated
57
+ function yasrShowHighest () {
58
+ document.getElementById('yasr-most-rated-posts').style.display = 'none';
59
+ document.getElementById('yasr-highest-rated-posts').style.display = '';
60
+ }
61
+
62
+ //Vice versa
63
+ function yasrShowMost () {
64
+ document.getElementById('yasr-highest-rated-posts').style.display = 'none';
65
+ document.getElementById('yasr-most-rated-posts').style.display = '';
66
+ }
67
+
68
+
69
+ /****** End Yasr shortcode page ******/
70
+
71
+
72
+ /****** Tooltip function ******/
73
+
74
+ //used in shortcode page and ajax page
75
+ function yasrDrawTipsProgress (yasrStatsInDom) {
76
+
77
+ //htmlcheckid declared false
78
+ var htmlIdChecked = false;
79
+
80
+ for (var i = 0; i < yasrStatsInDom.length; i++) {
81
+
82
+ (function (i) {
83
+
84
+ var htmlId = '#'+yasrStatsInDom.item(i).id;
85
+ var postId = yasrStatsInDom.item(i).getAttribute('data-postid');
86
+
87
+ var data = {
88
+ action: 'yasr_stats_visitors_votes',
89
+ post_id: postId
90
+ };
91
+
92
+ //Convert in a string
93
+ //var dataToSend = jsObject_to_URLEncoded(data);
94
+
95
+ var initialContent = '<span style="color: #0a0a0a">Loading...</span>';
96
+
97
+ tippy(htmlId, {
98
+ content: initialContent,
99
+ theme: 'yasr',
100
+ arrow: 'true',
101
+ arrowType: 'round',
102
+
103
+ //When support for IE will be dropped out, this will become onShow(tip)
104
+ onShow: function onShow(tip) {
105
+
106
+ if (htmlId !== htmlIdChecked) {
107
+ jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
108
+ response = JSON.parse(response);
109
+ tip.setContent(response);
110
+ });
111
+ }
112
+ },
113
+ onHidden: function onHidden() {
114
+ htmlIdChecked = htmlId;
115
+ }
116
+
117
+ });
118
+
119
+ })(i);
120
+
121
+ }
122
+
123
+ }
124
+
125
+ /****** End tooltipfunction ******/
126
+
127
+ //this is the function that print the overall rating shortcode, get overall rating and starsize
128
+ function yasrSetRaterValue (starSize, htmlId) {
129
+
130
+ //convert to be a number
131
+ starSize = parseInt(starSize);
132
+
133
+ raterJs({
134
+ starSize: starSize,
135
+ step: 0.1,
136
+ showToolTip: false,
137
+ readOnly: true,
138
+ element: document.getElementById(htmlId),
139
+ });
140
+
141
+ }
142
+
143
+ function yasrSetRatingOnLoad (yasrRatingsInDom) {
144
+
145
+ //Check in the object
146
+ for (var i = 0; i < yasrRatingsInDom.length; i++) {
147
+ var htmlId = yasrRatingsInDom.item(i).id;
148
+ var starSize = yasrRatingsInDom.item(i).getAttribute('data-rater-starsize');
149
+
150
+ yasrSetRaterValue(starSize, htmlId);
151
+ }
152
+
153
+ }
154
+
155
+ function yasrVisitorVotesFront (yasrRaterVVInDom) {
156
+
157
+ //Check in the object
158
+ for (var i = 0; i < yasrRaterVVInDom.length; i++) {
159
+
160
+ (function(i) {
161
+
162
+ let rating = yasrRaterVVInDom.item(i).getAttribute('data-rating');
163
+ let readonly = yasrRaterVVInDom.item(i).getAttribute('data-rater-readonly');
164
+
165
+ let postId = yasrRaterVVInDom.item(i).getAttribute('data-rater-postid');
166
+ let htmlId = yasrRaterVVInDom.item(i).id;
167
+ let uniqueId = htmlId.replace('yasr-visitor-votes-rater-', '');
168
+ let starSize = parseInt(yasrRaterVVInDom.item(i).getAttribute('data-rater-starsize'));
169
+ let nonce = yasrRaterVVInDom.item(i).getAttribute('data-rater-nonce');
170
+ let isSingular = yasrRaterVVInDom.item(i).getAttribute('data-issingular');
171
+
172
+ let containerVotesNumber = 'yasr-vv-votes-number-container-' + uniqueId;
173
+ let containerAverageNumber = 'yasr-vv-average-container-' + uniqueId;
174
+ let containerAfterStarsID = 'yasr-visitor-votes-container-after-stars-' + uniqueId;
175
+ let spanBottom = false;
176
+
177
+ if(yasrCommonData.ajaxEnabled === 'yes') {
178
+ let cpt = yasrRaterVVInDom.item(i).getAttribute('data-cpt');
179
+
180
+ if(cpt === '') {
181
+ cpt = 'posts';
182
+ }
183
+
184
+ let urlVisitorVotes = 'wp/v2/'+ cpt +'/' + postId + '?_fields=yasr_visitor_votes&_wpnonce='+yasrCommonData.nonce;
185
+
186
+ jQuery.post(yasrCommonData.restEndpoint + urlVisitorVotes).done(
187
+ function (data) {
188
+ readonly = data.yasr_visitor_votes.stars_attributes.read_only;
189
+
190
+ if (data.yasr_visitor_votes.number_of_votes > 0) {
191
+ rating = data.yasr_visitor_votes.sum_votes / data.yasr_visitor_votes.number_of_votes;
192
+ } else {
193
+ rating = 0;
194
+ }
195
+ rating = rating.toFixed(1);
196
+ rating = parseFloat(rating);
197
+
198
+ document.getElementById(containerVotesNumber).innerHTML = data.yasr_visitor_votes.number_of_votes;
199
+ document.getElementById(containerAverageNumber).innerHTML = rating;
200
+
201
+ yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular, containerAfterStarsID);
202
+
203
+ //insert span with text after the average
204
+ if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false) {
205
+ spanBottom = data.yasr_visitor_votes.stars_attributes.span_bottom;
206
+ let yasrTotalAverageContainer = document.getElementById(containerAfterStarsID);
207
+ yasrTotalAverageContainer.insertAdjacentHTML('beforeend', spanBottom);
208
+ }
209
+
210
+ }).fail(
211
+ function(e, x, settings, exception) {
212
+ console.info(__('YASR ajax call failed. Showing ratings from html', 'yet-another-stars-rating'));
213
+ yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular, containerAfterStarsID);
214
+ });
215
+
216
+ } else {
217
+ yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular, containerAfterStarsID);
218
+ }
219
+
220
+ })(i);
221
+
222
+ }//End for
223
+
224
+ }
225
+
226
+ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular, containerAfterStarsID) {
227
+
228
+ //Be sure is a number and not a string
229
+ rating = parseFloat(rating);
230
+
231
+ //raterjs accepts only boolean for readOnly element
232
+ readonly = yasrTrueFalseStringConvertion(readonly);
233
+
234
+ raterJs({
235
+ starSize: starSize,
236
+ rating: rating,
237
+ step: 1,
238
+ showToolTip: false,
239
+ readOnly: readonly,
240
+ element: document.getElementById(htmlId),
241
+
242
+ rateCallback: function rateCallback(rating, done) {
243
+ //show the loader
244
+ document.getElementById(containerAfterStarsID).innerHTML = yasrCommonData.loaderHtml;
245
+
246
+ //Creating an object with data to send
247
+ var data = {
248
+ action: 'yasr_send_visitor_rating',
249
+ rating: rating,
250
+ post_id: postId,
251
+ nonce_visitor: nonce,
252
+ is_singular : isSingular
253
+ };
254
+
255
+ this.setRating(rating);
256
+ this.disable();
257
+
258
+ //Send value to the Server
259
+ jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
260
+ //decode json
261
+ response = JSON.parse(response);
262
+ document.getElementById(containerAfterStarsID).innerHTML = response;
263
+ });
264
+ done();
265
+ }
266
+ });
267
+
268
+ }
269
+
270
+ function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
271
+
272
+ //will have field id and vote
273
+ var ratingObject = "";
274
+
275
+ //an array with all the ratings objects
276
+ var ratingArray = [];
277
+
278
+ //Check in the object
279
+ for (var i = 0; i < yasrMultiSetVisitorInDom.length; i++) {
280
+
281
+ (function (i) {
282
+
283
+ var htmlId = yasrMultiSetVisitorInDom.item(i).id;
284
+ var readonly = yasrMultiSetVisitorInDom.item(i).getAttribute('data-rater-readonly');
285
+
286
+ readonly = yasrTrueFalseStringConvertion(readonly);
287
+
288
+ var elem = document.querySelector("#" + htmlId);
289
+ raterJs({
290
+ starSize: 16,
291
+ step: 1,
292
+ showToolTip: false,
293
+ readOnly: readonly,
294
+ element: elem,
295
+
296
+ rateCallback: function rateCallback(rating, done) {
297
+
298
+ var postId = elem.getAttribute('data-rater-postid');
299
+ var setId = elem.getAttribute('data-rater-setid');
300
+ var setIdField = elem.getAttribute('data-rater-set-field-id');
301
+
302
+ //Just leave 1 number after the .
303
+ rating = rating.toFixed(1);
304
+ //Be sure is a number and not a string
305
+ var vote = parseInt(rating);
306
+
307
+ this.setRating(vote); //set the new rating
308
+
309
+ ratingObject = {
310
+ postid: postId,
311
+ setid: setId,
312
+ field: setIdField,
313
+ rating: vote
314
+ };
315
+
316
+ //creating rating array
317
+ ratingArray.push(ratingObject);
318
+
319
+ done();
320
+
321
+ }
322
+
323
+ });
324
+
325
+ })(i);
326
+
327
+ }
328
+
329
+ jQuery('.yasr-send-visitor-multiset').on('click', function() {
330
+
331
+ const multiSetPostId = this.getAttribute('data-postid');
332
+ const multiSetId = this.getAttribute('data-setid');
333
+ const nonce = this.getAttribute('data-nonce');
334
+
335
+ jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
336
+ jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
337
+
338
+ var data = {
339
+ action: 'yasr_visitor_multiset_field_vote',
340
+ nonce: nonce,
341
+ post_id: multiSetPostId,
342
+ rating: ratingArray,
343
+ set_type: multiSetId
344
+ };
345
+
346
+ //Send value to the Server
347
+ jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
348
+ jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).text(response);
349
+ });
350
+
351
+ });
352
+
353
+ } //End function
354
+
355
+
356
+ function yasrTrueFalseStringConvertion(string) {
357
+
358
+ if (typeof string === 'undefined' || string === null || string === '') {
359
+ string = true;
360
+ }
361
+
362
+ //Convert string to boolean
363
+ if (string === 'true' || string === '1') {
364
+ string = true;
365
+ }
366
+ if (string === 'false' || string === '0') {
367
+ string = false;
368
+ }
369
+
370
+ return string;
371
+
372
+ }
includes/js/yasr-front.js CHANGED
@@ -1,384 +1 @@
1
-
2
- /*** Constant used by yasr
3
-
4
- yasrCommonData (postid, ajaxurl, loggedUser, visitorStatsEnabled, loaderHtml, tooltipValues')
5
-
6
- yasrMultiSetData (setType, nonce)
7
-
8
-
9
- ***/
10
-
11
-
12
- /****** Do this actions on document load ******/
13
- document.addEventListener('DOMContentLoaded', function(event) {
14
-
15
- //At pageload, check if there is some shortcode with class yasr-rater-stars
16
- var yasrRaterInDom = document.getElementsByClassName('yasr-rater-stars');
17
- //If so, call the function to set the rating
18
- if (yasrRaterInDom.length > 0) {
19
-
20
- //load this on everypageload
21
- yasrSetRatingOnLoad(yasrRaterInDom);
22
-
23
- }
24
-
25
- //check if shortcode yasr_visitor_votes is used
26
- var yasrRaterVVInDom = document.getElementsByClassName('yasr-rater-stars-visitor-votes');
27
-
28
- if (yasrRaterVVInDom.length > 0) {
29
- yasrVisitorVotesFront(yasrRaterVVInDom);
30
- }
31
-
32
- var yasrMultiSetVisitorInDom = document.getElementsByClassName('yasr-multiset-visitors-rater');
33
-
34
- if (yasrMultiSetVisitorInDom.length > 0) {
35
- yasrRaterVisitorsMultiSet(yasrMultiSetVisitorInDom)
36
- }
37
-
38
-
39
- //Check to draw tooltips
40
- if (yasrRaterVVInDom) {
41
- if (yasrCommonData.visitorStatsEnabled === 'yes') {
42
- var yasrStatsInDom = document.getElementsByClassName('yasr-dashicons-visitor-stats');
43
- if (yasrStatsInDom) {
44
- yasrDrawTipsProgress (yasrStatsInDom);
45
- }
46
- }
47
- }
48
-
49
- if (typeof yasrMostHighestRanking !== 'undefined') {
50
-
51
- //By default, hide the highest rated chart
52
- document.getElementById('yasr-highest-rated-posts').style.display = 'none';
53
-
54
- }
55
-
56
- });
57
-
58
-
59
- //This work on top10 ranking chart, show the highest rated and hide most rated
60
- function yasrShowHighest () {
61
-
62
- document.getElementById('yasr-most-rated-posts').style.display = 'none';
63
- document.getElementById('yasr-highest-rated-posts').style.display = '';
64
-
65
- }
66
-
67
- //Vice versa
68
- function yasrShowMost () {
69
-
70
- document.getElementById('yasr-highest-rated-posts').style.display = 'none';
71
- document.getElementById('yasr-most-rated-posts').style.display = '';
72
-
73
- }
74
-
75
-
76
- /****** End Yasr shortcode page ******/
77
-
78
-
79
- /****** Tooltip function ******/
80
-
81
- //used in shortcode page and ajax page
82
- function yasrDrawTipsProgress (yasrStatsInDom) {
83
-
84
- //htmlcheckid declared false
85
- var htmlIdChecked = false;
86
-
87
- for (var i = 0; i < yasrStatsInDom.length; i++) {
88
-
89
- (function (i) {
90
-
91
- var htmlId = '#'+yasrStatsInDom.item(i).id;
92
- var postId = yasrStatsInDom.item(i).getAttribute('data-postid');
93
-
94
- var data = {
95
- action: 'yasr_stats_visitors_votes',
96
- post_id: postId
97
- };
98
-
99
- //Convert in a string
100
- //var dataToSend = jsObject_to_URLEncoded(data);
101
-
102
- var initialContent = '<span style="color: #0a0a0a">Loading...</span>';
103
-
104
- tippy(htmlId, {
105
- content: initialContent,
106
- theme: 'yasr',
107
- arrow: 'true',
108
- arrowType: 'round',
109
-
110
- //When support for IE will be dropped out, this will become onShow(tip)
111
- onShow: function onShow(tip) {
112
-
113
- if (htmlId !== htmlIdChecked) {
114
- jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
115
- response = JSON.parse(response);
116
- tip.setContent(response);
117
-
118
- });
119
- }
120
- },
121
- onHidden: function onHidden() {
122
- htmlIdChecked = htmlId;
123
- }
124
-
125
- });
126
-
127
- })(i);
128
-
129
- }
130
-
131
- }
132
-
133
-
134
-
135
- /****** End tooltipfunction ******/
136
-
137
-
138
- /**** ****/
139
-
140
- //this is the function that print the overall rating shortcode, get overall rating and starsize
141
- function yasrSetRaterValue (starSize, htmlId) {
142
-
143
- //convert to be a number
144
- starSize = parseInt(starSize);
145
-
146
- raterJs({
147
- starSize: starSize,
148
- step: 0.1,
149
- showToolTip: false,
150
- readOnly: true,
151
- element: document.getElementById(htmlId),
152
- });
153
-
154
- }
155
-
156
- function yasrSetRatingOnLoad (yasrRatingsInDom) {
157
-
158
- //Check in the object
159
- for (var i = 0; i < yasrRatingsInDom.length; i++) {
160
-
161
- var htmlId = yasrRatingsInDom.item(i).id;
162
- var starSize = yasrRatingsInDom.item(i).getAttribute('data-rater-starsize');
163
-
164
- yasrSetRaterValue(starSize, htmlId);
165
-
166
- }
167
-
168
- }
169
-
170
- function yasrVisitorVotesFront (yasrRaterVVInDom) {
171
-
172
- //Check in the object
173
- for (var i = 0; i < yasrRaterVVInDom.length; i++) {
174
-
175
- (function(i) {
176
-
177
- let rating = yasrRaterVVInDom.item(i).getAttribute('data-rating');
178
- let readonly = yasrRaterVVInDom.item(i).getAttribute('data-rater-readonly');
179
-
180
- let postId = yasrRaterVVInDom.item(i).getAttribute('data-rater-postid');
181
- let htmlId = yasrRaterVVInDom.item(i).id;
182
- let uniqueId = htmlId.replace('yasr-visitor-votes-rater-', '');
183
- let starSize = parseInt(yasrRaterVVInDom.item(i).getAttribute('data-rater-starsize'));
184
- let nonce = yasrRaterVVInDom.item(i).getAttribute('data-rater-nonce');
185
- let isSingular = yasrRaterVVInDom.item(i).getAttribute('data-issingular');
186
-
187
- let containerVotesNumber = 'yasr-vv-votes-number-container-' + uniqueId;
188
- let containerAverageNumber = 'yasr-vv-average-container-' + uniqueId;
189
- let containerAfterStarsID = 'yasr-visitor-votes-container-after-stars-' + uniqueId;
190
- let spanBottom = false;
191
-
192
- //this means that attribute data-rating is not set
193
- if (rating === null && readonly === null) {
194
-
195
- let cpt = yasrRaterVVInDom.item(i).getAttribute('data-cpt');
196
-
197
- let urlVisitorVotes = 'wp/v2/'+ cpt +'/' + postId + '?_fields=yasr_visitor_votes&_wpnonce='+yasrCommonData.nonce;
198
-
199
- fetch(yasrCommonData.restEndpoint + urlVisitorVotes).then(response => {
200
- return response.json();
201
- }).then(data => {
202
- // Work with JSON data here
203
-
204
- readonly = data.yasr_visitor_votes.stars_attributes.read_only;
205
-
206
- if (data.yasr_visitor_votes.number_of_votes > 0) {
207
- rating = data.yasr_visitor_votes.sum_votes / data.yasr_visitor_votes.number_of_votes;
208
- } else {
209
- rating = 0;
210
- }
211
- rating = rating.toFixed(1);
212
- rating = parseFloat(rating);
213
-
214
- document.getElementById(containerVotesNumber).innerHTML = data.yasr_visitor_votes.number_of_votes;
215
- document.getElementById(containerAverageNumber).innerHTML = rating;
216
-
217
- yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular, containerAfterStarsID);
218
-
219
- //insert span with text after the average
220
- if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false) {
221
- spanBottom = data.yasr_visitor_votes.stars_attributes.span_bottom;
222
- let yasrTotalAverageContainer = document.getElementById(containerAfterStarsID);
223
- yasrTotalAverageContainer.insertAdjacentHTML('beforeend', spanBottom);
224
- }
225
-
226
- }).catch(err => {
227
- // Do something for an error here
228
- });
229
- } else {
230
- yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular, containerAfterStarsID);
231
- }
232
-
233
- })(i);
234
-
235
- }//End for
236
-
237
- }
238
-
239
- function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular, containerAfterStarsID) {
240
-
241
- //Be sure is a number and not a string
242
- rating = parseFloat(rating);
243
-
244
- //raterjs accept only boolean for readOnly element
245
- readonly = yasrTrueFalseStringConvertion(readonly);
246
-
247
- raterJs({
248
- starSize: starSize,
249
- rating: rating,
250
- step: 1,
251
- showToolTip: false,
252
- readOnly: readonly,
253
- element: document.getElementById(htmlId),
254
-
255
- rateCallback: function rateCallback(rating, done) {
256
- //show the loader
257
- document.getElementById(containerAfterStarsID).innerHTML = yasrCommonData.loaderHtml;
258
-
259
- //Creating an object with data to send
260
- var data = {
261
- action: 'yasr_send_visitor_rating',
262
- rating: rating,
263
- post_id: postId,
264
- nonce_visitor: nonce,
265
- is_singular : isSingular
266
- };
267
-
268
- this.setRating(rating);
269
- this.disable();
270
-
271
- //Send value to the Server
272
- jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
273
- //decode json
274
- response = JSON.parse(response);
275
- document.getElementById(containerAfterStarsID).innerHTML = response;
276
- });
277
- done();
278
- }
279
- });
280
-
281
- }
282
-
283
- function yasrRaterVisitorsMultiSet (yasrMultiSetVisitorInDom) {
284
-
285
- //will have field id and vote
286
- var ratingObject = "";
287
-
288
- //an array with all the ratings objects
289
- var ratingArray = [];
290
-
291
- //Check in the object
292
- for (var i = 0; i < yasrMultiSetVisitorInDom.length; i++) {
293
-
294
- (function (i) {
295
-
296
- var htmlId = yasrMultiSetVisitorInDom.item(i).id;
297
- var readonly = yasrMultiSetVisitorInDom.item(i).getAttribute('data-rater-readonly');
298
-
299
- readonly = yasrTrueFalseStringConvertion(readonly);
300
-
301
- var elem = document.querySelector("#" + htmlId);
302
- raterJs({
303
- starSize: 16,
304
- step: 1,
305
- showToolTip: false,
306
- readOnly: readonly,
307
- element: elem,
308
-
309
- rateCallback: function rateCallback(rating, done) {
310
-
311
- var postId = elem.getAttribute('data-rater-postid');
312
- var setId = elem.getAttribute('data-rater-setid');
313
- var setIdField = elem.getAttribute('data-rater-set-field-id');
314
-
315
- //Just leave 1 number after the .
316
- rating = rating.toFixed(1);
317
- //Be sure is a number and not a string
318
- var vote = parseInt(rating);
319
-
320
- this.setRating(vote); //set the new rating
321
-
322
- ratingObject = {
323
- postid: postId,
324
- setid: setId,
325
- field: setIdField,
326
- rating: vote
327
- };
328
-
329
- //creating rating array
330
- ratingArray.push(ratingObject);
331
-
332
- done();
333
-
334
- }
335
-
336
- });
337
-
338
- })(i);
339
-
340
- }
341
-
342
- jQuery('.yasr-send-visitor-multiset').on('click', function() {
343
-
344
- var multiSetPostId = this.getAttribute('data-postid');
345
- var multiSetId = this.getAttribute('data-setid');
346
-
347
- jQuery('#yasr-send-visitor-multiset-'+multiSetPostId+'-'+multiSetId).hide();
348
- jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).show();
349
-
350
- var data = {
351
- action: 'yasr_visitor_multiset_field_vote',
352
- nonce: yasrMultiSetData.nonceVisitor,
353
- post_id: multiSetPostId,
354
- rating: ratingArray,
355
- set_type: multiSetId
356
- };
357
-
358
- //Send value to the Server
359
- jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
360
- jQuery('#yasr-loader-multiset-visitor-'+multiSetPostId+'-'+multiSetId).text(response);
361
- });
362
-
363
- });
364
-
365
- } //End function
366
-
367
-
368
- function yasrTrueFalseStringConvertion(string) {
369
-
370
- if (typeof string === 'undefined' || string === null || string === '') {
371
- string = true;
372
- }
373
-
374
- //Convert string to boolean
375
- if (string === 'true' || string === '1') {
376
- string = true;
377
- }
378
- if (string === 'false' || string === '0') {
379
- string = false;
380
- }
381
-
382
- return string;
383
-
384
- }
1
+ !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e){const{__:r}=wp.i18n;function a(t,e){t=parseInt(t),raterJs({starSize:t,step:.1,showToolTip:!1,readOnly:!0,element:document.getElementById(e)})}function n(t,e,r,a,n,s,i,u,d){e=parseFloat(e),a=o(a),raterJs({starSize:t,rating:e,step:1,showToolTip:!1,readOnly:a,element:document.getElementById(n),rateCallback:function(t,e){document.getElementById(d).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:i,is_singular:u};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),document.getElementById(d).innerHTML=t})),e()}})}function o(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}document.addEventListener("DOMContentLoaded",(function(t){var e=document.getElementsByClassName("yasr-rater-stars");e.length>0&&function(t){for(var e=0;e<t.length;e++){var r=t.item(e).id;a(t.item(e).getAttribute("data-rater-starsize"),r)}}(e);var s=document.getElementsByClassName("yasr-rater-stars-visitor-votes");s.length>0&&function(t){for(var e=0;e<t.length;e++)!function(e){let a=t.item(e).getAttribute("data-rating"),o=t.item(e).getAttribute("data-rater-readonly"),s=t.item(e).getAttribute("data-rater-postid"),i=t.item(e).id,u=i.replace("yasr-visitor-votes-rater-",""),d=parseInt(t.item(e).getAttribute("data-rater-starsize")),l=t.item(e).getAttribute("data-rater-nonce"),m=t.item(e).getAttribute("data-issingular"),c="yasr-vv-votes-number-container-"+u,y="yasr-vv-average-container-"+u,f="yasr-visitor-votes-container-after-stars-"+u,v=!1;if("yes"===yasrCommonData.ajaxEnabled){let p=t.item(e).getAttribute("data-cpt");""===p&&(p="posts");let g="wp/v2/"+p+"/"+s+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.post(yasrCommonData.restEndpoint+g).done((function(t){if(o=t.yasr_visitor_votes.stars_attributes.read_only,a=t.yasr_visitor_votes.number_of_votes>0?t.yasr_visitor_votes.sum_votes/t.yasr_visitor_votes.number_of_votes:0,a=a.toFixed(1),a=parseFloat(a),document.getElementById(c).innerHTML=t.yasr_visitor_votes.number_of_votes,document.getElementById(y).innerHTML=a,n(d,a,s,o,i,u,l,m,f),!1!==t.yasr_visitor_votes.stars_attributes.span_bottom){v=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(f).insertAdjacentHTML("beforeend",v)}})).fail((function(t,e,c,y){console.info(r("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),n(d,a,s,o,i,u,l,m,f)}))}else n(d,a,s,o,i,u,l,m,f)}(e)}(s);var i=document.getElementsByClassName("yasr-multiset-visitors-rater");if(i.length>0&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){var n=t.item(a).id,s=t.item(a).getAttribute("data-rater-readonly");s=o(s);var i=document.querySelector("#"+n);raterJs({starSize:16,step:1,showToolTip:!1,readOnly:s,element:i,rateCallback:function(t,a){var n=i.getAttribute("data-rater-postid"),o=i.getAttribute("data-rater-setid"),s=i.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var u=parseInt(t);this.setRating(u),e={postid:n,setid:o,field:s,rating:u},r.push(e),a()}})}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){const t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_type:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(i),s&&"yes"===yasrCommonData.visitorStatsEnabled){var u=document.getElementsByClassName("yasr-dashicons-visitor-stats");u&&function(t){for(var e=!1,r=0;r<t.length;r++)!function(r){var a="#"+t.item(r).id,n={action:"yasr_stats_visitors_votes",post_id:t.item(r).getAttribute("data-postid")};tippy(a,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){a!==e&&jQuery.post(yasrCommonData.ajaxurl,n,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){e=a}})}(r)}(u)}"undefined"!=typeof yasrMostHighestRanking&&(document.getElementById("yasr-highest-rated-posts").style.display="none")}))}]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/rest/classes/YasrCustomFields.php CHANGED
@@ -87,7 +87,7 @@ class YasrCustomFields extends WP_REST_Controller {
87
  );
88
 
89
  $cookie_value = YasrVisitorVotes::checkCookie();
90
- $stars_enabled = YasrVisitorVotes::starsEnalbed($cookie_value);
91
 
92
  //if user is enabled to rate, readonly must be false
93
  if($stars_enabled === 'true_logged' || $stars_enabled === 'true_not_logged') {
87
  );
88
 
89
  $cookie_value = YasrVisitorVotes::checkCookie();
90
+ $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
91
 
92
  //if user is enabled to rate, readonly must be false
93
  if($stars_enabled === 'true_logged' || $stars_enabled === 'true_not_logged') {
includes/shortcodes/classes/YasrShortcode.php CHANGED
@@ -92,4 +92,44 @@ abstract class YasrShortcode {
92
  }
93
  return $px_size;
94
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
92
  }
93
  return $px_size;
94
  }
95
+
96
+ /**
97
+ * Enable or disable stars, works for both VisitorVotes and VisitorMultiSet
98
+ *
99
+ * @param $cookie_value
100
+ *
101
+ * @return string|bool;
102
+ */
103
+ public static function starsEnalbed($cookie_value) {
104
+ $is_user_logged_in = is_user_logged_in();
105
+
106
+ //Logged in user is always able to vote
107
+ if ( $is_user_logged_in === true ) {
108
+ return 'true_logged';
109
+ }
110
+
111
+ //If only logged in users can vote
112
+ if (YASR_ALLOWED_USER === 'logged_only') {
113
+ //IF user is not logged in
114
+ if ( $is_user_logged_in === false ) {
115
+ return 'false_not_logged';
116
+ }
117
+ }
118
+
119
+ //if anonymous are allowed to vote
120
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
121
+ //I've to check if is user is not logged in
122
+ if ($is_user_logged_in === false) {
123
+ //if cookie !== false means that exists, and user can't vote
124
+ if ($cookie_value !== false) {
125
+ return 'false_already_voted';
126
+ }
127
+
128
+ return 'true_not_logged';
129
+ }
130
+ } //end if YASR_ALLOWED_USER === 'allow_anonymous'
131
+
132
+ //this should never happen
133
+ return false;
134
+ }
135
  }
includes/shortcodes/classes/YasrVisitorMultiSet.php CHANGED
@@ -46,18 +46,21 @@ class YasrVisitorMultiSet extends YasrMultiSet {
46
 
47
  $this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
48
 
 
 
49
  $image = YASR_IMG_DIR . "/loader.gif";
50
  $this->loader_html = "<span class='yasr-loader-multiset-visitor'
51
- id='yasr-loader-multiset-visitor-$this->post_id-$this->set_id'>
52
  &nbsp;<img src='$image' title='yasr-loader' alt='yasr-loader'>
53
  </span>";
54
 
55
  $this->button_html = "<input type='submit'
56
  name='submit'
57
- id='yasr-send-visitor-multiset-$this->post_id-$this->set_id'
58
  class='button button-primary yasr-send-visitor-multiset'
59
  data-postid='$this->post_id'
60
  data-setid='$this->set_id'
 
61
  value='" . __('Submit!', 'yet-another-stars-rating') . "'
62
  />";
63
 
@@ -81,6 +84,7 @@ class YasrVisitorMultiSet extends YasrMultiSet {
81
 
82
  $this->shortcode_html .= "<table class='yasr_table_multi_set_shortcode'>";
83
 
 
84
  $this->printMultisetRows($set_name_content, true);
85
 
86
  //Submit row and button
@@ -96,30 +100,10 @@ class YasrVisitorMultiSet extends YasrMultiSet {
96
  $this->shortcode_html .= "</table>";
97
  $this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
98
 
99
- wp_localize_script(
100
- 'yasrfront',
101
- "yasrMultiSetData",
102
- array(
103
- 'nonceVisitor' => $ajax_nonce_visitor_multiset,
104
- 'setType' => $this->set_id
105
- )
106
- );
107
-
108
  return $this->shortcode_html;
109
  }
110
 
111
- /**
112
- * This function first check if a cookie is set,
113
- * Then who can rate and set attributes to:
114
- * $this->button
115
- * $this->star_readonly
116
- * $this->span_message_content
117
- *
118
- * @param void
119
- * @return void
120
- *
121
- */
122
- protected function multisetAttributes() {
123
  $yasr_cookiename = 'yasr_multi_visitor_cookie';
124
 
125
  //Check cookie and if voting is allowed only to logged in users
@@ -132,49 +116,59 @@ class YasrVisitorMultiSet extends YasrMultiSet {
132
  if (is_array($cookie_data)) {
133
  foreach ($cookie_data as $value) {
134
  $cookie_post_id = (int)$value['post_id'];
135
- $cookie_set_id = (int)$value['set_id'];
136
 
137
  if ($cookie_post_id === $this->post_id && $cookie_set_id === $this->set_id) {
138
- $this->button = "";
139
- $this->star_readonly = 'true';
140
- $this->span_message_content = __('Thank you for voting!', 'yet-another-stars-rating');
141
-
142
- //Stop doing foreach, here we've found the rating for current post
143
- break;
144
- } else {
145
- $this->button = $this->button_html;
146
- $this->star_readonly = 'false';
147
- $this->span_message_content = "";
148
  }
149
  }
 
 
150
  }
151
- } else {
152
- //If user is not logged in
153
- if (!is_user_logged_in()) {
154
- if (YASR_ALLOWED_USER === 'allow_anonymous') {
155
- $this->button = $this->button_html;
156
- $this->star_readonly = 'false';
157
- $this->span_message_content = "";
158
- } elseif (YASR_ALLOWED_USER === 'logged_only') {
159
- $this->button = $this->button_html_disabled;
160
- $this->star_readonly = 'true';
161
- $this->span_message_content = '<span class="yasr-visitor-votes-must-sign-in">';
162
-
163
- if (defined('YASR_CUSTOM_TEXT_MUST_SIGN_IN') && YASR_CUSTOM_TEXT_MUST_SIGN_IN !== '') {
164
- $this->span_message_content .= YASR_CUSTOM_TEXT_MUST_SIGN_IN;
165
- } else {
166
- $this->span_message_content .= __('You must sign in to vote', 'yet-another-stars-rating');
167
- }
168
- $this->span_message_content .= '</span>';
169
- }
170
- } //End if user logged in
171
 
172
- //User is logged in
173
- else {
174
- $this->button = $this->button_html;
175
- $this->star_readonly = 'false';
176
- $this->span_message_content = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
 
178
  }
179
  }
180
  }
46
 
47
  $this->shortcode_html = '<!-- Yasr Visitor Multi Set Shortcode-->';
48
 
49
+ $post_set_id = $this->post_id.'-'.$this->set_id;
50
+
51
  $image = YASR_IMG_DIR . "/loader.gif";
52
  $this->loader_html = "<span class='yasr-loader-multiset-visitor'
53
+ id='yasr-loader-multiset-visitor-$post_set_id'>
54
  &nbsp;<img src='$image' title='yasr-loader' alt='yasr-loader'>
55
  </span>";
56
 
57
  $this->button_html = "<input type='submit'
58
  name='submit'
59
+ id='yasr-send-visitor-multiset-$post_set_id'
60
  class='button button-primary yasr-send-visitor-multiset'
61
  data-postid='$this->post_id'
62
  data-setid='$this->set_id'
63
+ data-nonce='$ajax_nonce_visitor_multiset'
64
  value='" . __('Submit!', 'yet-another-stars-rating') . "'
65
  />";
66
 
84
 
85
  $this->shortcode_html .= "<table class='yasr_table_multi_set_shortcode'>";
86
 
87
+ //print the single rows
88
  $this->printMultisetRows($set_name_content, true);
89
 
90
  //Submit row and button
100
  $this->shortcode_html .= "</table>";
101
  $this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
102
 
 
 
 
 
 
 
 
 
 
103
  return $this->shortcode_html;
104
  }
105
 
106
+ public function checkCookie() {
 
 
 
 
 
 
 
 
 
 
 
107
  $yasr_cookiename = 'yasr_multi_visitor_cookie';
108
 
109
  //Check cookie and if voting is allowed only to logged in users
116
  if (is_array($cookie_data)) {
117
  foreach ($cookie_data as $value) {
118
  $cookie_post_id = (int)$value['post_id'];
119
+ $cookie_set_id = (int)$value['set_id'];
120
 
121
  if ($cookie_post_id === $this->post_id && $cookie_set_id === $this->set_id) {
122
+ return true;
 
 
 
 
 
 
 
 
 
123
  }
124
  }
125
+ //if foreach ends, return false
126
+ return false;
127
  }
128
+ //if cookie is not an array, should never happens
129
+ return false;
130
+ }
131
+ return false;
132
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
+ /**
135
+ * This function first check if a cookie is set,
136
+ * Then who can rate and set attributes to:
137
+ * $this->button
138
+ * $this->star_readonly
139
+ * $this->span_message_content
140
+ *
141
+ * @param void
142
+ * @return void
143
+ *
144
+ */
145
+ protected function multisetAttributes() {
146
+
147
+ $this->checkCookie();
148
+
149
+ $set_enabled = YasrShortcode::starsEnalbed( $this->checkCookie() );
150
+
151
+ if($set_enabled === 'true_logged' || $set_enabled === 'true_not_logged') {
152
+ $this->button = $this->button_html;
153
+ $this->star_readonly = 'false';
154
+ $this->span_message_content = "";
155
+ }
156
+ else if( $set_enabled === 'false_already_voted') {
157
+ $this->button = "";
158
+ $this->star_readonly = 'true';
159
+ $this->span_message_content = __('Thank you for voting!', 'yet-another-stars-rating');
160
+ }
161
+ elseif ($set_enabled === 'false_not_logged') {
162
+ $this->button = $this->button_html_disabled;
163
+ $this->star_readonly = 'true';
164
+ $this->span_message_content = '<span class="yasr-visitor-votes-must-sign-in">';
165
+
166
+ if (defined('YASR_CUSTOM_TEXT_MUST_SIGN_IN') && YASR_CUSTOM_TEXT_MUST_SIGN_IN !== '') {
167
+ $this->span_message_content .= YASR_CUSTOM_TEXT_MUST_SIGN_IN;
168
+ } else {
169
+ $this->span_message_content .= __('You must sign in to vote', 'yet-another-stars-rating');
170
  }
171
+ $this->span_message_content .= '</span>';
172
  }
173
  }
174
  }
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -49,26 +49,6 @@ class YasrVisitorVotes extends YasrShortcode {
49
 
50
  }
51
 
52
- public function printVisitorVotesAjax() {
53
-
54
- $htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
55
-
56
- $this->textBeforeAfterStars(false, false);
57
-
58
- $this->shortcode_html .= "<div id='$htmlid'
59
- class='yasr-rater-stars-visitor-votes'
60
- data-rater-postid='$this->post_id'
61
- data-rater-starsize='".$this->starSize()."'
62
- data-rater-nonce='$this->ajax_nonce_visitor'
63
- data-issingular='$this->is_singular'
64
- data-cpt='$this->post_type'
65
- ></div>";
66
-
67
- return $this->returnYasrVisitorVotes(false);
68
-
69
- }
70
-
71
-
72
  /**
73
  * Print the visitor votes shortcode
74
  *
@@ -99,14 +79,16 @@ class YasrVisitorVotes extends YasrShortcode {
99
  data-rating='$average_rating'
100
  data-rater-starsize='".$this->starSize()."'
101
  data-rater-postid='$this->post_id'
102
- data-rater-readonly='true'>
 
 
103
  </div>";
104
 
105
  return $this->shortcode_html;
106
  }
107
 
108
  $cookie_value = self::checkCookie($this->post_id);
109
- $stars_enabled = self::starsEnalbed($cookie_value);
110
 
111
  if($stars_enabled === 'true_logged' || $stars_enabled === 'true_not_logged') {
112
  $this->readonly = 'false'; //Always false if user is logged in
@@ -117,14 +99,15 @@ class YasrVisitorVotes extends YasrShortcode {
117
  $this->textBeforeAfterStars($number_of_votes, $average_rating);
118
 
119
  $this->shortcode_html .= "<div id='$htmlid'
120
- class='yasr-rater-stars-visitor-votes'
121
- data-rater-postid='$this->post_id'
122
- data-rating='$average_rating'
123
- data-rater-starsize='".$this->starSize()."'
124
- data-rater-readonly='$this->readonly'
125
- data-rater-nonce='$this->ajax_nonce_visitor'
126
- data-issingular='$this->is_singular'>
127
- </div>";
 
128
 
129
  return $this->returnYasrVisitorVotes($cookie_value);
130
 
@@ -181,47 +164,6 @@ class YasrVisitorVotes extends YasrShortcode {
181
  return $cookie_value;
182
  }
183
 
184
- /**
185
- * Enable or disable stars
186
- *
187
- * @param $cookie_value
188
- *
189
- * @return string|bool;
190
- */
191
- public static function starsEnalbed ($cookie_value) {
192
-
193
- $is_user_logged_in = is_user_logged_in();
194
-
195
- //Logged in user is always able to vote
196
- if ($is_user_logged_in === true) {
197
- return 'true_logged';
198
- }
199
-
200
- //If only logged in users can vote
201
- if (YASR_ALLOWED_USER === 'logged_only') {
202
- //IF user is not logged in
203
- if ($is_user_logged_in === false) {
204
- return 'false_not_logged';
205
- }
206
- }
207
-
208
- //if anonymous are allowed to vote
209
- if (YASR_ALLOWED_USER === 'allow_anonymous') {
210
- //I've to check if is user is not logged in
211
- if ($is_user_logged_in === false) {
212
- //if cookie !== false means that exists, and user can't vote
213
- if ($cookie_value !== false) {
214
- return 'false_already_voted';
215
- }
216
- return 'true_not_logged';
217
- }
218
- } //end if YASR_ALLOWED_USER === 'allow_anonymous'
219
-
220
- //this should never happen
221
- return false;
222
-
223
- }
224
-
225
  /**
226
  * This function show default (or custom) text depending if rating is allowed or not
227
  *
@@ -230,7 +172,7 @@ class YasrVisitorVotes extends YasrShortcode {
230
  */
231
  public static function showTextBelowStars ($cookie_value) {
232
 
233
- $stars_enabled = self::starsEnalbed($cookie_value);
234
  $span_bottom_line = false;
235
  $span_bottom_line_content = false;
236
 
@@ -427,7 +369,7 @@ class YasrVisitorVotes extends YasrShortcode {
427
  $this->shortcode_html .= $span_container_after_stars;
428
  $this->shortcode_html .= $this->visitorStats();
429
  $this->shortcode_html .= $this->span_text_after_stars;
430
- if($cookie_value !== false) {
431
  $this->shortcode_html .= self::showTextBelowStars($cookie_value);
432
  }
433
  $this->shortcode_html .= '</span>'; //Close yasr-visitor-votes-after-stars and yasr_visitor_votes
49
 
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /**
53
  * Print the visitor votes shortcode
54
  *
79
  data-rating='$average_rating'
80
  data-rater-starsize='".$this->starSize()."'
81
  data-rater-postid='$this->post_id'
82
+ data-rater-readonly='true'
83
+ data-cpt='$this->post_type'
84
+ >
85
  </div>";
86
 
87
  return $this->shortcode_html;
88
  }
89
 
90
  $cookie_value = self::checkCookie($this->post_id);
91
+ $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
92
 
93
  if($stars_enabled === 'true_logged' || $stars_enabled === 'true_not_logged') {
94
  $this->readonly = 'false'; //Always false if user is logged in
99
  $this->textBeforeAfterStars($number_of_votes, $average_rating);
100
 
101
  $this->shortcode_html .= "<div id='$htmlid'
102
+ class='yasr-rater-stars-visitor-votes'
103
+ data-rater-postid='$this->post_id'
104
+ data-rating='$average_rating'
105
+ data-rater-starsize='".$this->starSize()."'
106
+ data-rater-readonly='$this->readonly'
107
+ data-rater-nonce='$this->ajax_nonce_visitor'
108
+ data-issingular='$this->is_singular'
109
+ data-cpt='$this->post_type'>
110
+ </div>";
111
 
112
  return $this->returnYasrVisitorVotes($cookie_value);
113
 
164
  return $cookie_value;
165
  }
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  /**
168
  * This function show default (or custom) text depending if rating is allowed or not
169
  *
172
  */
173
  public static function showTextBelowStars ($cookie_value) {
174
 
175
+ $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
176
  $span_bottom_line = false;
177
  $span_bottom_line_content = false;
178
 
369
  $this->shortcode_html .= $span_container_after_stars;
370
  $this->shortcode_html .= $this->visitorStats();
371
  $this->shortcode_html .= $this->span_text_after_stars;
372
+ if($cookie_value !== false && YASR_ENABLE_AJAX !== 'yes') {
373
  $this->shortcode_html .= self::showTextBelowStars($cookie_value);
374
  }
375
  $this->shortcode_html .= '</span>'; //Close yasr-visitor-votes-after-stars and yasr_visitor_votes
includes/shortcodes/yasr-shortcode-ajax.php CHANGED
@@ -26,21 +26,19 @@ if ( ! defined( 'ABSPATH' ) ) {
26
  add_action('wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback');
27
  add_action('wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback');
28
 
 
 
 
29
  function yasr_insert_visitor_votes_callback() {
30
 
31
- if (isset($_POST['rating']) && isset($_POST['post_id']) && isset($_POST['nonce_visitor'])) {
32
-
33
  $rating = (int) $_POST['rating'];
34
  $post_id = (int) $_POST['post_id'];
35
  $nonce_visitor = $_POST['nonce_visitor'];
36
  $is_singular = $_POST['is_singular'];
37
 
38
- if (!is_int($post_id)) {
39
- exit();
40
- }
41
-
42
  } else {
43
- exit();
44
  }
45
 
46
  $array_action_visitor_vote = array('post_id' => $post_id, 'is_singular' => $is_singular);
@@ -214,28 +212,70 @@ function yasr_visitor_multiset_field_vote_callback() {
214
  //increase the counter
215
  $counter_matched_fields = $counter_matched_fields + 1;
216
 
217
- $id_field = $rating_values['field'];
218
  $rating = $rating_values['rating'];
219
 
220
- $query_success = $wpdb->insert(
221
- YASR_LOG_MULTI_SET,
222
- array(
223
- 'field_id' => $id_field,
224
- 'set_type' => $set_type,
225
- 'post_id' => $post_id,
226
- 'vote' => $rating,
227
- 'user_id' => $current_user->ID,
228
- 'date' => date('Y-m-d H:i:s'),
229
- 'ip' => $ip_adress
230
-
231
- ),
232
- array("%d", "%d", "%d", "%d", "%d", "%s", "%s")
233
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
- if ($query_success) {
236
- $array_error[] = 0;
237
  } else {
238
- $array_error[] = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
  } //End if $rating_values['postid'] == $post_id
26
  add_action('wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback');
27
  add_action('wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback');
28
 
29
+ /**
30
+ * Save yasr_visitor_votes
31
+ */
32
  function yasr_insert_visitor_votes_callback() {
33
 
34
+ if (isset($_POST['rating'], $_POST['post_id'], $_POST['nonce_visitor'])) {
 
35
  $rating = (int) $_POST['rating'];
36
  $post_id = (int) $_POST['post_id'];
37
  $nonce_visitor = $_POST['nonce_visitor'];
38
  $is_singular = $_POST['is_singular'];
39
 
 
 
 
 
40
  } else {
41
+ die();
42
  }
43
 
44
  $array_action_visitor_vote = array('post_id' => $post_id, 'is_singular' => $is_singular);
212
  //increase the counter
213
  $counter_matched_fields = $counter_matched_fields + 1;
214
 
215
+ $id_field = (int)$rating_values['field'];
216
  $rating = $rating_values['rating'];
217
 
218
+ if(is_user_logged_in()) {
219
+ $update_query_success = $wpdb->update(
220
+ YASR_LOG_MULTI_SET,
221
+ array(
222
+ 'field_id' => $id_field,
223
+ 'set_type' => $set_type,
224
+ 'post_id' => $post_id,
225
+ 'vote' => $rating,
226
+ 'user_id' => $current_user->ID,
227
+ 'date' => date( 'Y-m-d H:i:s' ),
228
+ 'ip' => $ip_adress
229
+
230
+ ),
231
+ array(
232
+ 'field_id' => $id_field,
233
+ 'set_type' => $set_type,
234
+ 'post_id' => $post_id,
235
+ 'user_id' => $current_user->ID
236
+ ),
237
+ array( "%d", "%d", "%d", "%d", "%d", "%s", "%s" ),
238
+ array( "%d", "%d", "%d", "%d" )
239
+ );
240
+
241
+ if (!$update_query_success) {
242
+ $insert_query_success = $wpdb->insert(
243
+ YASR_LOG_MULTI_SET,
244
+ array(
245
+ 'field_id' => $id_field,
246
+ 'set_type' => $set_type,
247
+ 'post_id' => $post_id,
248
+ 'vote' => $rating,
249
+ 'user_id' => $current_user->ID,
250
+ 'date' => date('Y-m-d H:i:s'),
251
+ 'ip' => $ip_adress
252
+ ),
253
+ array("%d", "%d", "%d", "%d", "%d", "%s", "%s")
254
+ );
255
+
256
+ if (!$insert_query_success) {
257
+ $array_error[] = 1;
258
+ }
259
+ }
260
 
 
 
261
  } else {
262
+ $replace_query_success = $wpdb->replace(
263
+ YASR_LOG_MULTI_SET,
264
+ array(
265
+ 'field_id' => $id_field,
266
+ 'set_type' => $set_type,
267
+ 'post_id' => $post_id,
268
+ 'vote' => $rating,
269
+ 'user_id' => $current_user->ID,
270
+ 'date' => date('Y-m-d H:i:s'),
271
+ 'ip' => $ip_adress
272
+ ),
273
+ array("%d", "%d", "%d", "%d", "%d", "%s", "%s")
274
+ );
275
+
276
+ if (!$replace_query_success) {
277
+ $array_error[] = 1;
278
+ }
279
  }
280
 
281
  } //End if $rating_values['postid'] == $post_id
includes/shortcodes/yasr-shortcode-functions.php CHANGED
@@ -86,9 +86,6 @@ function shortcode_visitor_votes_callback($atts) {
86
  $shortcode_name = 'yasr_visitor_votes';
87
  $visitor_votes = new YasrVisitorVotes($atts, $shortcode_name);
88
 
89
- if(YASR_ENABLE_AJAX === 'yes') {
90
- return $visitor_votes->printVisitorVotesAjax();
91
- }
92
  return $visitor_votes->printVisitorVotes();
93
 
94
  } //End function shortcode_visitor_votes_callback
86
  $shortcode_name = 'yasr_visitor_votes';
87
  $visitor_votes = new YasrVisitorVotes($atts, $shortcode_name);
88
 
 
 
 
89
  return $visitor_votes->printVisitorVotes();
90
 
91
  } //End function shortcode_visitor_votes_callback
public/yasr-public-actions.php CHANGED
@@ -78,7 +78,7 @@ function yasr_add_scripts() {
78
  wp_enqueue_script(
79
  'yasrfront',
80
  YASR_JS_DIR_INCLUDES . 'yasr-front.js',
81
- array('jquery', 'rater'),
82
  YASR_VERSION_NUM,
83
  true);
84
 
@@ -101,6 +101,7 @@ function yasr_add_scripts() {
101
  'restEndpoint' => esc_url_raw(rest_url()),
102
  'ajaxurl' => admin_url('admin-ajax.php'),
103
  'visitorStatsEnabled' => YASR_VISITORS_STATS,
 
104
  'loaderHtml' => $yasr_visitor_votes_loader,
105
  'nonce' => wp_create_nonce('wp_rest')
106
  )
78
  wp_enqueue_script(
79
  'yasrfront',
80
  YASR_JS_DIR_INCLUDES . 'yasr-front.js',
81
+ array('jquery','rater','wp-i18n'),
82
  YASR_VERSION_NUM,
83
  true);
84
 
101
  'restEndpoint' => esc_url_raw(rest_url()),
102
  'ajaxurl' => admin_url('admin-ajax.php'),
103
  'visitorStatsEnabled' => YASR_VISITORS_STATS,
104
+ 'ajaxEnabled' => YASR_ENABLE_AJAX,
105
  'loaderHtml' => $yasr_visitor_votes_loader,
106
  'nonce' => wp_create_nonce('wp_rest')
107
  )
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.9.0
5
  Contributors: Dudo
6
  Tested up to: 5.5
7
  Requires PHP: 5.3
8
- Stable tag: 2.3.5
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
@@ -22,7 +22,7 @@ website posts, pages and CPT, without affecting its speed.
22
  = Reviewer Vote =
23
  With the classic editor, when you create or update a page or a post, a box (metabox) will be available in the upper right corner where you'll
24
  be able to insert the overall rating.
25
- With the new Guteneberg editor, just click on the "+" icon to add a block and search for Yasr Overall Rating.
26
  You can either place the overall rating automatically at the beginning or the end of a post (look in "Settings"
27
  -> "Yet Another Stars Rating: Settings"), or wherever you want in the page using the shortcode [yasr_overall_rating] (easily added through the visual editor).
28
 
@@ -91,7 +91,6 @@ It is the vote that allows your visitors to vote: just paste this shortcode **[y
91
 
92
  [Demo page for Overall Rating and Vistor Rating](https://yetanotherstarsrating.com/yasr-basics-shortcode/)
93
 
94
-
95
  = What is "Multi Set"? =
96
  It is the feature that makes YASR awesome. Multisets give the opportunity to score different aspects for each review: for example, if you're reviewing a videogame, you can create the aspects "Graphics", "Gameplay", "Story", etc. and give a vote for each one. To create a set, just go in "Settings" -> "Yet Another Stars Rating: Settings" and click on the "Multi Sets" tab. To insert it into a post, just paste the shortcode that YASR will create for you.
97
 
@@ -147,25 +146,26 @@ If doesn't, you should work on your seo reputation.
147
 
148
  The full changelog can be found in the plugin's directory. Recent entries:
149
 
 
 
 
 
150
  = 2.3.5 =
151
  * IMPROVED: is now possible to select between "Organization" or "Person" in "Rich snippet options".
152
  You may need to save again "Publisher name" and "Image Url"
153
  * IMPROVED: code cleanup
154
 
155
-
156
  = 2.3.4 =
157
  * IMPROVED: added Software Application itemType
158
  * IMPROVED: added Organization itemType
159
  * IMPORVED: added reviewBody and description properties
160
  * FIXED: "Your ratings" widget in admin dashboard
161
 
162
-
163
  = 2.3.3 =
164
  * FIXED: "Load results with AJAX" option works with all post types, not the "posts" one
165
  * FIXED: CSS fix in settings pages
166
  * FIXED: minor fix with multiSet
167
 
168
-
169
  = 2.3.2 =
170
  * FIXED: Uncaught TypeError randomly shows up in the browser console
171
  * TWEAKED: removed deprecated multisite function
@@ -190,7 +190,6 @@ fields where reset
190
  * ENHANCEMENT: rich snippet are returned only if a YASR shortcode is in the post or page
191
  * ENHANCEMENT: changed classes names star-rating and star-value in yasr-star-rating and yasr-star-value. **DELETE YOUR BROWSER CACHE**
192
 
193
-
194
  = 2.2.8 =
195
  * FIXED: empty schema field can return error on existing post or page.
196
 
@@ -230,5 +229,4 @@ External Libraries: [Rater](https://github.com/fredolss/rater-js)
230
  [tippy](https://atomiks.github.io/tippyjs/)
231
 
232
  Flat star icon made by[Freepik](http://www.freepik.com)
233
- from [www.flaticon.com](https://www.flaticon.com/) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/)
234
-
5
  Contributors: Dudo
6
  Tested up to: 5.5
7
  Requires PHP: 5.3
8
+ Stable tag: 2.3.6
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
22
  = Reviewer Vote =
23
  With the classic editor, when you create or update a page or a post, a box (metabox) will be available in the upper right corner where you'll
24
  be able to insert the overall rating.
25
+ With the new Gutenberg editor, just click on the "+" icon to add a block and search for Yasr Overall Rating.
26
  You can either place the overall rating automatically at the beginning or the end of a post (look in "Settings"
27
  -> "Yet Another Stars Rating: Settings"), or wherever you want in the page using the shortcode [yasr_overall_rating] (easily added through the visual editor).
28
 
91
 
92
  [Demo page for Overall Rating and Vistor Rating](https://yetanotherstarsrating.com/yasr-basics-shortcode/)
93
 
 
94
  = What is "Multi Set"? =
95
  It is the feature that makes YASR awesome. Multisets give the opportunity to score different aspects for each review: for example, if you're reviewing a videogame, you can create the aspects "Graphics", "Gameplay", "Story", etc. and give a vote for each one. To create a set, just go in "Settings" -> "Yet Another Stars Rating: Settings" and click on the "Multi Sets" tab. To insert it into a post, just paste the shortcode that YASR will create for you.
96
 
146
 
147
  The full changelog can be found in the plugin's directory. Recent entries:
148
 
149
+ = 2.3.6 =
150
+ * FIXED: visitor multiset doesn't allow user to vote in some circumstances
151
+ * TWEAKED : minor changes in ajax call for yasr_visitor_votes
152
+
153
  = 2.3.5 =
154
  * IMPROVED: is now possible to select between "Organization" or "Person" in "Rich snippet options".
155
  You may need to save again "Publisher name" and "Image Url"
156
  * IMPROVED: code cleanup
157
 
 
158
  = 2.3.4 =
159
  * IMPROVED: added Software Application itemType
160
  * IMPROVED: added Organization itemType
161
  * IMPORVED: added reviewBody and description properties
162
  * FIXED: "Your ratings" widget in admin dashboard
163
 
 
164
  = 2.3.3 =
165
  * FIXED: "Load results with AJAX" option works with all post types, not the "posts" one
166
  * FIXED: CSS fix in settings pages
167
  * FIXED: minor fix with multiSet
168
 
 
169
  = 2.3.2 =
170
  * FIXED: Uncaught TypeError randomly shows up in the browser console
171
  * TWEAKED: removed deprecated multisite function
190
  * ENHANCEMENT: rich snippet are returned only if a YASR shortcode is in the post or page
191
  * ENHANCEMENT: changed classes names star-rating and star-value in yasr-star-rating and yasr-star-value. **DELETE YOUR BROWSER CACHE**
192
 
 
193
  = 2.2.8 =
194
  * FIXED: empty schema field can return error on existing post or page.
195
 
229
  [tippy](https://atomiks.github.io/tippyjs/)
230
 
231
  Flat star icon made by[Freepik](http://www.freepik.com)
232
+ from [www.flaticon.com](https://www.flaticon.com/) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/)
 
yet-another-stars-rating.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
  * testimonials to your website posts, pages and CPT, without affecting its speed.
8
- * Version: 2.3.5
9
  * Author: Dario Curvino
10
  * Author URI: https://dariocurvino.it/
11
  * Text Domain: yet-another-stars-rating
@@ -77,7 +77,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
77
  yasr_fs();
78
  // Signal that SDK was initiated.
79
  do_action( 'yasr_fs_loaded' );
80
- define( 'YASR_VERSION_NUM', '2.3.5' );
81
  //Plugin absolute path
82
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
83
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
  * testimonials to your website posts, pages and CPT, without affecting its speed.
8
+ * Version: 2.3.6
9
  * Author: Dario Curvino
10
  * Author URI: https://dariocurvino.it/
11
  * Text Domain: yet-another-stars-rating
77
  yasr_fs();
78
  // Signal that SDK was initiated.
79
  do_action( 'yasr_fs_loaded' );
80
+ define( 'YASR_VERSION_NUM', '2.3.6' );
81
  //Plugin absolute path
82
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
83
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );