Yasr – Yet Another Stars Rating - Version 1.8.5

Version Description

  • Fixed: is now possible to insert more than once a shortcode in the same page
  • Fixed: Full RTL support (remeber to delete all your caches)
Download this release

Release Info

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

Code changes from version 1.8.4 to 1.8.5

js/rater-js-rtl.js ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.raterJs = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
2
+ "use strict";
3
+
4
+ /*! rater-js. [c] 2018 Fredrik Olsson. MIT License */
5
+ // var css = require('./style.css');
6
+
7
+ module.exports = function rater(options) {
8
+ //private fields
9
+ var showToolTip = true;
10
+
11
+ if (typeof options.element === "undefined" || options.element === null) {
12
+ throw new Error("element required");
13
+ }
14
+
15
+ if (typeof options.showToolTip !== "undefined") {
16
+ showToolTip = !!options.showToolTip;
17
+ }
18
+
19
+ if (typeof options.step !== "undefined") {
20
+ if (options.step <= 0 || options.step > 1) {
21
+ throw new Error("step must be a number between 0 and 1");
22
+ }
23
+ }
24
+
25
+ var stars = options.max || 5;
26
+ var starSize = options.starSize || 16;
27
+ var step = options.step || 1;
28
+ var onHover = options.onHover;
29
+ var onLeave = options.onLeave;
30
+ var rating;
31
+ var myRating;
32
+ var elem = options.element;
33
+ elem.classList.add("star-rating");
34
+ var div = document.createElement("div");
35
+ div.classList.add("star-value");
36
+ div.style.backgroundSize = starSize + "px";
37
+ elem.appendChild(div);
38
+ elem.style.width = starSize * stars + "px";
39
+ elem.style.height = starSize + "px";
40
+ elem.style.backgroundSize = starSize + "px";
41
+ var callback = options.rateCallback;
42
+ var disabled = !!options.readOnly;
43
+ var disableText;
44
+ var isRating = false;
45
+ var isBusyText = options.isBusyText;
46
+ var currentRating;
47
+ var ratingText;
48
+
49
+ if (typeof options.disableText !== "undefined") {
50
+ disableText = options.disableText;
51
+ } else {
52
+ disableText = "{rating}/{maxRating}";
53
+ }
54
+
55
+ if (typeof options.ratingText !== "undefined") {
56
+ ratingText = options.ratingText;
57
+ } else {
58
+ ratingText = "{rating}/{maxRating}";
59
+ }
60
+
61
+ if (options.rating) {
62
+ setRating(options.rating);
63
+ } else {
64
+ var dataRating = elem.dataset.rating;
65
+
66
+ if (dataRating) {
67
+ setRating(+dataRating);
68
+ }
69
+ }
70
+
71
+ if (typeof rating === "undefined") {
72
+ elem.querySelector(".star-value").style.width = "0px";
73
+ }
74
+
75
+ if (disabled) {
76
+ disable();
77
+ } //private methods
78
+
79
+
80
+ function onMouseMove(e) {
81
+ if (disabled === true || isRating === true) {
82
+ return;
83
+ }
84
+
85
+ var parentOffset = this.getBoundingClientRect();
86
+
87
+ var relX = e.pageX - parentOffset.left;
88
+
89
+ var width = elem.offsetWidth;
90
+
91
+ var relXRtl= width - relX;
92
+
93
+ var valueForDivision = width/100;
94
+
95
+ var percent = relXRtl/valueForDivision;
96
+
97
+ if (percent < 101) {
98
+ if (step === 1) {
99
+ currentRating = Math.ceil(percent / 100 * stars);
100
+ } else {
101
+ var rat = percent / 100 * stars;
102
+
103
+ for (var i = 0;; i += step) {
104
+ if (i >= rat) {
105
+ currentRating = i;
106
+ break;
107
+ }
108
+ }
109
+ }
110
+
111
+ if (currentRating > 5) {
112
+ currentRating = 5;
113
+ }
114
+
115
+ elem.querySelector(".star-value").style.width = currentRating / stars * 100 + "%";
116
+
117
+ if (showToolTip) {
118
+ var toolTip = ratingText.replace("{rating}", currentRating);
119
+ toolTip = toolTip.replace("{maxRating}", stars);
120
+ elem.setAttribute("data-title", toolTip);
121
+ }
122
+
123
+ if (typeof onHover === "function") {
124
+ onHover(currentRating, rating);
125
+ }
126
+ }
127
+ }
128
+
129
+
130
+ function onStarOut(e) {
131
+ if (typeof rating !== "undefined") {
132
+ elem.querySelector(".star-value").style.width = rating / stars * 100 + "%";
133
+ elem.setAttribute("data-rating", rating);
134
+ } else {
135
+ elem.querySelector(".star-value").style.width = "0%";
136
+ elem.removeAttribute("data-rating");
137
+ }
138
+
139
+ if (typeof onLeave === "function") {
140
+ onLeave(currentRating, rating);
141
+ }
142
+ }
143
+
144
+ function onStarClick(e) {
145
+ if (disabled === true) {
146
+ return;
147
+ }
148
+
149
+ if (isRating === true) {
150
+ return;
151
+ }
152
+
153
+ if (typeof callback !== "undefined") {
154
+ isRating = true;
155
+ myRating = currentRating;
156
+
157
+ if (typeof isBusyText === "undefined") {
158
+ elem.removeAttribute("data-title");
159
+ } else {
160
+ elem.setAttribute("data-title", isBusyText);
161
+ }
162
+
163
+ callback.call(this, myRating, function () {
164
+ if (disabled === false) {
165
+ elem.removeAttribute("data-title");
166
+ }
167
+
168
+ isRating = false;
169
+ });
170
+ }
171
+ } //public methods
172
+
173
+
174
+ function disable() {
175
+ disabled = true;
176
+
177
+ if (showToolTip && !!disableText) {
178
+ var toolTip = disableText.replace("{rating}", rating);
179
+ toolTip = toolTip.replace("{maxRating}", stars);
180
+ elem.setAttribute("data-title", toolTip);
181
+ } else {
182
+ elem.removeAttribute("data-title");
183
+ }
184
+ }
185
+
186
+ function enable() {
187
+ disabled = false;
188
+ elem.removeAttribute("data-title");
189
+ }
190
+
191
+ function setRating(value) {
192
+ //Added for Yasr
193
+ if (value === -1) {
194
+ value = undefined;
195
+ }
196
+
197
+ if (typeof value !== "number" && typeof value !== "undefined") {
198
+ throw new Error("Value must be a number or undefined.");
199
+ }
200
+
201
+ if (value < 0 || value > stars) {
202
+ var ratingError = new Error("Value too high. Please set a rating of " + stars + " or below.");
203
+ ratingError.name = "ratingError";
204
+ throw ratingError;
205
+ }
206
+
207
+ rating = value;
208
+ elem.querySelector(".star-value").style.width = value / stars * 100 + "%";
209
+ elem.setAttribute("data-rating", value);
210
+ }
211
+
212
+ function getRating() {
213
+ return rating;
214
+ }
215
+
216
+ function dispose() {
217
+ elem.removeEventListener("mousemove", onMouseMove);
218
+ elem.removeEventListener("mouseleave", onStarOut);
219
+ elem.removeEventListener("click", onStarClick);
220
+ }
221
+
222
+ elem.addEventListener("mousemove", onMouseMove);
223
+ elem.addEventListener("mouseleave", onStarOut);
224
+ var module = {
225
+ setRating: setRating,
226
+ getRating: getRating,
227
+ disable: disable,
228
+ enable: enable,
229
+ dispose: dispose
230
+ };
231
+
232
+ elem.addEventListener("click", onStarClick.bind(module));
233
+ return module;
234
+ };
235
+
236
+ },{"./style.css":2}],2:[function(require,module,exports){
237
+ var css = ".star-rating {\n width: 0;\n position: relative;\n display: inline-block;\n background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDguOSIgaGVpZ2h0PSIxMDMuNiIgdmlld0JveD0iMCAwIDEwOC45IDEwMy42Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UzZTZlNjt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPnN0YXJfMDwvdGl0bGU+PGcgaWQ9IkxheWVyXzIiIGRhdGEtbmFtZT0iTGF5ZXIgMiI+PGcgaWQ9IkxheWVyXzEtMiIgZGF0YS1uYW1lPSJMYXllciAxIj48cG9seWdvbiBjbGFzcz0iY2xzLTEiIHBvaW50cz0iMTA4LjkgMzkuNiA3MS4zIDM0LjEgNTQuNCAwIDM3LjYgMzQuMSAwIDM5LjYgMjcuMiA2Ni4xIDIwLjggMTAzLjYgNTQuNCA4NS45IDg4LjEgMTAzLjYgODEuNyA2Ni4xIDEwOC45IDM5LjYiLz48L2c+PC9nPjwvc3ZnPgo=);\n background-position: 0 0;\n background-repeat: repeat-x;\n cursor: pointer;\n}\n.star-rating[data-title]:hover:after {\n content: attr(data-title);\n padding: 4px 8px;\n color: #333;\n position: absolute;\n left: 0;\n top: 100%;\n z-index: 20;\n white-space: nowrap;\n -moz-border-radius: 5px;\n -webkit-border-radius: 5px;\n border-radius: 5px;\n -moz-box-shadow: 0px 0px 4px #222;\n -webkit-box-shadow: 0px 0px 4px #222;\n box-shadow: 0px 0px 4px #222;\n background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);\n background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc));\n background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);\n background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);\n background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);\n background-image: -o-linear-gradient(top, #eeeeee, #cccccc);\n}\n.star-rating .star-value {\n height: 100%;\n position: absolute;\n}\n.star-rating .star-value {\n position: absolute;\n height: 100%;\n width: 100%;\n background: url('data:image/svg+xml;base64,PHN2ZwoJeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTA4LjkiIGhlaWdodD0iMTAzLjYiIHZpZXdCb3g9IjAgMCAxMDguOSAxMDMuNiI+Cgk8ZGVmcz4KCQk8c3R5bGU+LmNscy0xe2ZpbGw6I2YxYzk0Nzt9PC9zdHlsZT4KCTwvZGVmcz4KCTx0aXRsZT5zdGFyMTwvdGl0bGU+Cgk8ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj4KCQk8ZyBpZD0iTGF5ZXJfMS0yIiBkYXRhLW5hbWU9IkxheWVyIDEiPgoJCQk8cG9seWdvbiBjbGFzcz0iY2xzLTEiIHBvaW50cz0iNTQuNCAwIDcxLjMgMzQuMSAxMDguOSAzOS42IDgxLjcgNjYuMSA4OC4xIDEwMy42IDU0LjQgODUuOSAyMC44IDEwMy42IDI3LjIgNjYuMSAwIDM5LjYgMzcuNiAzNC4xIDU0LjQgMCIvPgoJCTwvZz4KCTwvZz4KPC9zdmc+Cg==');\n background-repeat: repeat-x;\n}\n"; (require("browserify-css").createStyle(css, { "href": "lib\\style.css" }, { "insertAt": "bottom" })); module.exports = css;
238
+ },{"browserify-css":3}],3:[function(require,module,exports){
239
+ 'use strict';
240
+ // For more information about browser field, check out the browser field at https://github.com/substack/browserify-handbook#browser-field.
241
+
242
+ var styleElementsInsertedAtTop = [];
243
+
244
+ var insertStyleElement = function(styleElement, options) {
245
+ var head = document.head || document.getElementsByTagName('head')[0];
246
+ var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
247
+
248
+ options = options || {};
249
+ options.insertAt = options.insertAt || 'bottom';
250
+
251
+ if (options.insertAt === 'top') {
252
+ if (!lastStyleElementInsertedAtTop) {
253
+ head.insertBefore(styleElement, head.firstChild);
254
+ } else if (lastStyleElementInsertedAtTop.nextSibling) {
255
+ head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
256
+ } else {
257
+ head.appendChild(styleElement);
258
+ }
259
+ styleElementsInsertedAtTop.push(styleElement);
260
+ } else if (options.insertAt === 'bottom') {
261
+ head.appendChild(styleElement);
262
+ } else {
263
+ throw new Error('Invalid value for parameter \'insertAt\'. Must be \'top\' or \'bottom\'.');
264
+ }
265
+ };
266
+
267
+ module.exports = {
268
+ // Create a <link> tag with optional data attributes
269
+ createLink: function(href, attributes) {
270
+ var head = document.head || document.getElementsByTagName('head')[0];
271
+ var link = document.createElement('link');
272
+
273
+ link.href = href;
274
+ link.rel = 'stylesheet';
275
+
276
+ for (var key in attributes) {
277
+ if ( ! attributes.hasOwnProperty(key)) {
278
+ continue;
279
+ }
280
+ var value = attributes[key];
281
+ link.setAttribute('data-' + key, value);
282
+ }
283
+
284
+ head.appendChild(link);
285
+ },
286
+ // Create a <style> tag with optional data attributes
287
+ createStyle: function(cssText, attributes, extraOptions) {
288
+ extraOptions = extraOptions || {};
289
+
290
+ var style = document.createElement('style');
291
+ style.type = 'text/css';
292
+
293
+ for (var key in attributes) {
294
+ if ( ! attributes.hasOwnProperty(key)) {
295
+ continue;
296
+ }
297
+ var value = attributes[key];
298
+ style.setAttribute('data-' + key, value);
299
+ }
300
+
301
+ if (style.sheet) { // for jsdom and IE9+
302
+ style.innerHTML = cssText;
303
+ style.sheet.cssText = cssText;
304
+ insertStyleElement(style, { insertAt: extraOptions.insertAt });
305
+ } else if (style.styleSheet) { // for IE8 and below
306
+ insertStyleElement(style, { insertAt: extraOptions.insertAt });
307
+ style.styleSheet.cssText = cssText;
308
+ } else { // for Chrome, Firefox, and Safari
309
+ style.appendChild(document.createTextNode(cssText));
310
+ insertStyleElement(style, { insertAt: extraOptions.insertAt });
311
+ }
312
+ }
313
+ };
314
+
315
+ },{}]},{},[1])(1)
316
+ });
lib/yasr-functions.php CHANGED
@@ -47,7 +47,13 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
47
  wp_add_inline_style( 'yasrcss', YASR_CUSTOM_CSS_RULES );
48
  }
49
 
50
- wp_enqueue_script( 'rater', YASR_JS_DIR . 'rater-js.js' , '', '0.6.0', TRUE );
 
 
 
 
 
 
51
  wp_enqueue_script( 'yasrfront', YASR_JS_DIR . 'yasr-front.js' , array('jquery', 'rater'), '1.0.0', TRUE );
52
  wp_enqueue_script('tippy', YASR_JS_DIR . 'tippy.all.min.js', '', '3.2.0', TRUE );
53
 
@@ -82,8 +88,15 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
82
 
83
  wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr-admin.css', FALSE, NULL, 'all' );
84
 
85
- wp_enqueue_script( 'rater', YASR_JS_DIR . 'rater-js.js' , '', '0.6.0', TRUE );
86
- wp_enqueue_script( 'yasradmin', YASR_JS_DIR . 'yasr-admin.js' , array('jquery'), '1.0.00', TRUE );
 
 
 
 
 
 
 
87
 
88
  //this is for tinymce
89
  wp_enqueue_script('yasr_shortcode_creator', YASR_JS_DIR . 'yasr-shortcode-creator.js', array('jquery'), '1.0', TRUE);
@@ -145,6 +158,7 @@ function yasr_css_stars_set() {
145
  }
146
 
147
  add_action( 'yasr_add_front_script_css', 'yasr_rtl_support' );
 
148
 
149
  function yasr_rtl_support () {
150
 
47
  wp_add_inline_style( 'yasrcss', YASR_CUSTOM_CSS_RULES );
48
  }
49
 
50
+ if (!is_rtl()) {
51
+ wp_enqueue_script( 'rater', YASR_JS_DIR . 'rater-js.js' , '', '0.6.0', TRUE );
52
+ }
53
+ else {
54
+ wp_enqueue_script( 'rater', YASR_JS_DIR . 'rater-js-rtl.js' , '', '0.6.0', TRUE );
55
+ }
56
+
57
  wp_enqueue_script( 'yasrfront', YASR_JS_DIR . 'yasr-front.js' , array('jquery', 'rater'), '1.0.0', TRUE );
58
  wp_enqueue_script('tippy', YASR_JS_DIR . 'tippy.all.min.js', '', '3.2.0', TRUE );
59
 
88
 
89
  wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr-admin.css', FALSE, NULL, 'all' );
90
 
91
+ wp_enqueue_script( 'yasradmin', YASR_JS_DIR . 'yasr-admin.js' , array('jquery'), '1.0.00', TRUE );
92
+
93
+ if (!is_rtl()) {
94
+ wp_enqueue_script( 'rater', YASR_JS_DIR . 'rater-js.js' , '', '0.6.0', TRUE );
95
+ }
96
+ else {
97
+ wp_enqueue_script( 'rater', YASR_JS_DIR . 'rater-js-rtl.js' , array('jquery'), '0.6.0', TRUE );
98
+ }
99
+
100
 
101
  //this is for tinymce
102
  wp_enqueue_script('yasr_shortcode_creator', YASR_JS_DIR . 'yasr-shortcode-creator.js', array('jquery'), '1.0', TRUE);
158
  }
159
 
160
  add_action( 'yasr_add_front_script_css', 'yasr_rtl_support' );
161
+ add_action( 'yasr_add_admin_scripts_end', 'yasr_rtl_support');
162
 
163
  function yasr_rtl_support () {
164
 
lib/yasr-shortcode-functions.php CHANGED
@@ -52,7 +52,10 @@ add_shortcode ('yasr_overall_rating', 'shortcode_overall_rating_callback');
52
 
53
  $stars_attribute = yasr_stars_size($size);
54
 
55
- $overall_rating_html_id = 'yasr-overall-rating-rater-' . $postid;
 
 
 
56
  $html_stars = "<div class=\"yasr-rater-stars\" id=\"$overall_rating_html_id\" data-rater-postid=\"$postid\" data-rating=\"$overall_rating\" data-rater-starsize=\"$stars_attribute[px_size]\" ></div>";
57
 
58
  if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
@@ -120,7 +123,9 @@ add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
120
 
121
  $votes=yasr_get_visitor_votes($post_id); //always reference it
122
 
123
- $medium_rating=0; //Avoid undefined variable
 
 
124
 
125
  if (!$votes) {
126
  $votes=0; //Avoid undefined variable if there is not rating
@@ -146,7 +151,7 @@ add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
146
  //if this come from yasr_visitor_votes_readonly...
147
  if ($readonly === TRUE || $readonly === "yes") {
148
 
149
- $htmlid = 'yasr-visitor-votes-readonly-rater-'.$post_id;
150
  $shortcode_html = "<div class=\"yasr-rater-stars-visitor-votes\" id=\"$htmlid\" data-rating=\"$medium_rating\" data-rater-starsize=\"$stars_attribute[px_size]\" data-rater-postid=\"$post_id\" data-rater-readonly=\"true\"></div>";
151
 
152
  return $shortcode_html;
@@ -288,7 +293,9 @@ add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
288
 
289
  $span_container_after_stars = "<span id=\"yasr-visitor-votes-container-after-stars-$post_id\" class='yasr-visitor-votes-after-stars-class'>";
290
 
291
- $shortcode_html .= "<div id=\"yasr-visitor-votes-rater-$post_id\" class=\"yasr-rater-stars-visitor-votes\" data-rater-postid=\"$post_id\" data-rating=\"$medium_rating\" data-rater-starsize=\"$stars_attribute[px_size]\" data-rater-readonly=\"$readonly\" data-rater-nonce=\"$ajax_nonce_visitor\"></div>";
 
 
292
 
293
  $shortcode_html .= $span_container_after_stars;
294
  $shortcode_html .= $span_dashicon;
52
 
53
  $stars_attribute = yasr_stars_size($size);
54
 
55
+ //generate an unique id to be sure that every element has a different ID
56
+ $unique_id = str_shuffle(uniqid());
57
+
58
+ $overall_rating_html_id = 'yasr-overall-rating-rater-' . $unique_id;
59
  $html_stars = "<div class=\"yasr-rater-stars\" id=\"$overall_rating_html_id\" data-rater-postid=\"$postid\" data-rating=\"$overall_rating\" data-rater-starsize=\"$stars_attribute[px_size]\" ></div>";
60
 
61
  if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
123
 
124
  $votes=yasr_get_visitor_votes($post_id); //always reference it
125
 
126
+ $unique_id = str_shuffle(uniqid());
127
+
128
+ $medium_rating=0; //Avoid undefined variable
129
 
130
  if (!$votes) {
131
  $votes=0; //Avoid undefined variable if there is not rating
151
  //if this come from yasr_visitor_votes_readonly...
152
  if ($readonly === TRUE || $readonly === "yes") {
153
 
154
+ $htmlid = 'yasr-visitor-votes-readonly-rater-'.$unique_id;
155
  $shortcode_html = "<div class=\"yasr-rater-stars-visitor-votes\" id=\"$htmlid\" data-rating=\"$medium_rating\" data-rater-starsize=\"$stars_attribute[px_size]\" data-rater-postid=\"$post_id\" data-rater-readonly=\"true\"></div>";
156
 
157
  return $shortcode_html;
293
 
294
  $span_container_after_stars = "<span id=\"yasr-visitor-votes-container-after-stars-$post_id\" class='yasr-visitor-votes-after-stars-class'>";
295
 
296
+ $htmlid = 'yasr-visitor-votes-rater-' . $unique_id ;
297
+
298
+ $shortcode_html .= "<div id=\"$htmlid\" class=\"yasr-rater-stars-visitor-votes\" data-rater-postid=\"$post_id\" data-rating=\"$medium_rating\" data-rater-starsize=\"$stars_attribute[px_size]\" data-rater-readonly=\"$readonly\" data-rater-nonce=\"$ajax_nonce_visitor\"></div>";
299
 
300
  $shortcode_html .= $span_container_after_stars;
301
  $shortcode_html .= $span_dashicon;
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.3.0
5
  Contributors: Dudo
6
  Tested up to: 5.0.2
7
  Requires PHP: 5.3
8
- Stable tag: 1.8.4
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your website, e-commerce or blog with an easy and intuitive WordPress rating system!
@@ -111,11 +111,16 @@ If doesn't, it's suggested to ask in a SEO oriented forum.
111
  3. User's ranking showing most rated posts
112
  4. User's ranking showing highest rated posts
113
  5. Ranking reviews
 
114
 
115
  == Changelog ==
116
 
117
  The full changelog can be found in the plugin's directory. Recent entries:
118
 
 
 
 
 
119
  = 1.8.4 =
120
  * Small changes on stars images to better look on dark backgrounds
121
  * Partial rtl support
@@ -159,4 +164,4 @@ External Libraries: [Rater](https://github.com/fredolss/rater-js)
159
  [tippy](https://atomiks.github.io/tippyjs/)
160
 
161
  Svg star icon made by [Freepik](http://www.freepik.com)
162
- from [www.flaticon.com](https://www.flaticon.com/) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/)
5
  Contributors: Dudo
6
  Tested up to: 5.0.2
7
  Requires PHP: 5.3
8
+ Stable tag: 1.8.5
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Boost the way people interact with your website, e-commerce or blog with an easy and intuitive WordPress rating system!
111
  3. User's ranking showing most rated posts
112
  4. User's ranking showing highest rated posts
113
  5. Ranking reviews
114
+ 6. Yasr Stars Settings
115
 
116
  == Changelog ==
117
 
118
  The full changelog can be found in the plugin's directory. Recent entries:
119
 
120
+ = 1.8.5 =
121
+ * Fixed: is now possible to insert more than once a shortcode in the same page
122
+ * Fixed: Full RTL support (remeber to delete all your caches)
123
+
124
  = 1.8.4 =
125
  * Small changes on stars images to better look on dark backgrounds
126
  * Partial rtl support
164
  [tippy](https://atomiks.github.io/tippyjs/)
165
 
166
  Svg star icon made by [Freepik](http://www.freepik.com)
167
+ 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
@@ -4,7 +4,7 @@
4
  * Plugin Name: Yet Another Stars Rating
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 testimonials to your website posts, pages and CPT, without affecting its speed.
7
- * Version: 1.8.4
8
  * Author: Dario Curvino
9
  * Author URI: https://yetanotherstarsrating.com/
10
  * 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', '1.8.4' );
81
  //Plugin relative path
82
  define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
83
  //Plugin RELATIVE PATH without slashes (just the directory's name)
4
  * Plugin Name: Yet Another Stars Rating
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 testimonials to your website posts, pages and CPT, without affecting its speed.
7
+ * Version: 1.8.5
8
  * Author: Dario Curvino
9
  * Author URI: https://yetanotherstarsrating.com/
10
  * 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', '1.8.5' );
81
  //Plugin relative path
82
  define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
83
  //Plugin RELATIVE PATH without slashes (just the directory's name)