Yasr – Yet Another Stars Rating - Version 2.3.9

Version Description

  • FIXED: yasr_visitor_votes readonly didn't show up if load results with ajax is enabled
  • FIXED: missing fragment error if gutenber used
  • FIXED: empty tooltip on yasr_visitor_votes
Download this release

Release Info

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

Code changes from version 2.3.8 to 2.3.9

admin/js/src/guten/yasr-guten-panel.js CHANGED
@@ -2,6 +2,7 @@ const {registerPlugin} = wp.plugins;
2
  const {PluginSidebar, PluginSidebarMoreMenuItem} = wp.editPost;
3
  const {TextControl, PanelBody, PanelRow} = wp.components;
4
  const {BlockControls,InspectorControls} = wp.editor;
 
5
 
6
  const yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
7
  const yasrRichSnippetOptions = __('Rich snippet options', 'yet-another-stars-rating');
2
  const {PluginSidebar, PluginSidebarMoreMenuItem} = wp.editPost;
3
  const {TextControl, PanelBody, PanelRow} = wp.components;
4
  const {BlockControls,InspectorControls} = wp.editor;
5
+ const {Fragment} = wp.element;
6
 
7
  const yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
8
  const yasrRichSnippetOptions = __('Rich snippet options', 'yet-another-stars-rating');
admin/js/yasr-guten-panel.js CHANGED
@@ -1,348 +1 @@
1
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
6
-
7
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
8
-
9
- var registerPlugin = wp.plugins.registerPlugin;
10
- var _wp$editPost = wp.editPost,
11
- PluginSidebar = _wp$editPost.PluginSidebar,
12
- PluginSidebarMoreMenuItem = _wp$editPost.PluginSidebarMoreMenuItem;
13
- var _wp$components = wp.components,
14
- TextControl = _wp$components.TextControl,
15
- PanelBody = _wp$components.PanelBody,
16
- PanelRow = _wp$components.PanelRow;
17
- var _wp$editor = wp.editor,
18
- BlockControls = _wp$editor.BlockControls,
19
- InspectorControls = _wp$editor.InspectorControls;
20
-
21
-
22
- var yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
23
- var yasrRichSnippetOptions = __('Rich snippet options', 'yet-another-stars-rating');
24
- var yasrPostExcluded = __('Is this a review?', 'yet-another-stars-rating');
25
- var yasrSelectSnippetTitle = __('Select ItemType ', 'yet-another-stars-rating');
26
-
27
- var ContentBelowSidebar = function ContentBelowSidebar() {
28
- return React.createElement('div', null);
29
- };
30
-
31
- var YasrDivRatingOverall = function (_React$Component) {
32
- _inherits(YasrDivRatingOverall, _React$Component);
33
-
34
- _createClass(YasrDivRatingOverall, [{
35
- key: 'shouldComponentUpdate',
36
- value: function shouldComponentUpdate(nextProps, nextState) {
37
- return false;
38
- }
39
- }]);
40
-
41
- function YasrDivRatingOverall(props) {
42
- _classCallCheck(this, YasrDivRatingOverall);
43
-
44
- var _this = _possibleConstructorReturn(this, (YasrDivRatingOverall.__proto__ || Object.getPrototypeOf(YasrDivRatingOverall)).call(this, props));
45
-
46
- _this.yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
47
- _this.yasrOverallMoreInfo = __("This is the same value that you find the \"Yasr: Overall Rating\" block.", 'yet-another-stars-rating');
48
- return _this;
49
- }
50
-
51
- _createClass(YasrDivRatingOverall, [{
52
- key: 'printDivOverallRater',
53
- value: function printDivOverallRater() {
54
- return React.createElement(
55
- 'div',
56
- null,
57
- React.createElement('div', { id: 'overall-rater-panel', ref: function ref() {
58
- return raterJs({
59
- starSize: 32,
60
- step: 0.1,
61
- showToolTip: false,
62
- rating: wp.data.select('core/editor').getCurrentPost().meta.yasr_overall_rating,
63
- readOnly: false,
64
- element: document.querySelector("#overall-rater-panel"),
65
- rateCallback: function rateCallback(rating, done) {
66
-
67
- rating = rating.toFixed(1);
68
- rating = parseFloat(rating);
69
-
70
- wp.data.dispatch('core/editor').editPost({ meta: { yasr_overall_rating: rating } });
71
-
72
- this.setRating(rating);
73
-
74
- done();
75
- }
76
- });
77
- }
78
- }),
79
- React.createElement('br', null),
80
- this.yasrOverallMoreInfo
81
- );
82
- }
83
- }, {
84
- key: 'render',
85
- value: function render() {
86
- return React.createElement(
87
- 'div',
88
- null,
89
- this.yasrOverallRateThis,
90
- React.createElement(
91
- 'div',
92
- null,
93
- this.printDivOverallRater()
94
- )
95
- );
96
- }
97
- }]);
98
-
99
- return YasrDivRatingOverall;
100
- }(React.Component);
101
-
102
- var YasrSideBarAutoInsert = function (_React$Component2) {
103
- _inherits(YasrSideBarAutoInsert, _React$Component2);
104
-
105
- function YasrSideBarAutoInsert(props) {
106
- _classCallCheck(this, YasrSideBarAutoInsert);
107
-
108
- var _this2 = _possibleConstructorReturn(this, (YasrSideBarAutoInsert.__proto__ || Object.getPrototypeOf(YasrSideBarAutoInsert)).call(this, props));
109
-
110
- var isThisPostExluded = wp.data.select('core/editor').getCurrentPost().meta.yasr_auto_insert_disabled;
111
- var isThisPostExludedCheckbox = false;
112
-
113
- if (isThisPostExluded === 'yes') {
114
- isThisPostExludedCheckbox = true;
115
- }
116
-
117
- _this2.state = { postExcluded: isThisPostExludedCheckbox };
118
-
119
- _this2.yasrUpdatePostMetaAutoInsert = _this2.yasrUpdatePostMetaAutoInsert.bind(_this2);
120
- return _this2;
121
- }
122
-
123
- _createClass(YasrSideBarAutoInsert, [{
124
- key: 'yasrUpdatePostMetaAutoInsert',
125
- value: function yasrUpdatePostMetaAutoInsert(event) {
126
- var target = event.target;
127
- var postExcluded = target.type === 'checkbox' ? target.checked : target.value;
128
-
129
- this.setState({ postExcluded: postExcluded });
130
-
131
- if (postExcluded === true) {
132
- wp.data.dispatch('core/editor').editPost({ meta: { yasr_auto_insert_disabled: 'yes' } });
133
- } else {
134
- wp.data.dispatch('core/editor').editPost({ meta: { yasr_auto_insert_disabled: 'no' } });
135
- }
136
- }
137
- }, {
138
- key: 'render',
139
- value: function render() {
140
- return React.createElement(
141
- 'div',
142
- { className: 'yasr-guten-block-panel-center' },
143
- React.createElement('hr', null),
144
- React.createElement(
145
- 'label',
146
- null,
147
- React.createElement(
148
- 'span',
149
- null,
150
- yasrDisableAutoInsert
151
- )
152
- ),
153
- React.createElement(
154
- 'div',
155
- { className: 'yasr-onoffswitch-big yasr-onoffswitch-big-center', id: 'yasr-switcher-disable-auto-insert' },
156
- React.createElement('input', { type: 'checkbox',
157
- name: 'yasr_auto_insert_disabled',
158
- className: 'yasr-onoffswitch-checkbox',
159
- value: 'yes',
160
- id: 'yasr-auto-insert-disabled-switch',
161
- defaultChecked: this.state.postExcluded,
162
- onChange: this.yasrUpdatePostMetaAutoInsert
163
- }),
164
- React.createElement(
165
- 'label',
166
- { className: 'yasr-onoffswitch-label', htmlFor: 'yasr-auto-insert-disabled-switch' },
167
- React.createElement('span', { className: 'yasr-onoffswitch-inner' }),
168
- React.createElement('span', { className: 'yasr-onoffswitch-switch' })
169
- )
170
- )
171
- );
172
- }
173
- }]);
174
-
175
- return YasrSideBarAutoInsert;
176
- }(React.Component);
177
-
178
- /*class YasrDivIsReview extends React.Component {
179
-
180
- constructor(props) {
181
- super(props);
182
-
183
- let isThisPostReview = wp.data.select('core/editor').getCurrentPost().meta.yasr_post_is_review;
184
- let isThisPostReviewCheckbox = false;
185
-
186
- if (isThisPostReview === 'yes') {
187
- isThisPostReviewCheckbox = true;
188
- }
189
-
190
- this.state = {postIsReview: isThisPostReviewCheckbox};
191
-
192
- this.yasrUpdatePostMetaIsReview = this.yasrUpdatePostMetaIsReview.bind(this);
193
- }
194
-
195
- yasrUpdatePostMetaIsReview(event) {
196
-
197
- const target = event.target;
198
- const postIsReview = target.type === 'checkbox' ? target.checked : target.value;
199
-
200
- this.setState({postIsReview: postIsReview});
201
-
202
- if (postIsReview === true) {
203
- wp.data.dispatch('core/editor').editPost(
204
- { meta: { yasr_post_is_review: 'yes' } }
205
- );
206
- } else {
207
- wp.data.dispatch('core/editor').editPost(
208
- { meta: { yasr_post_is_review: 'no' } }
209
- );
210
- }
211
-
212
- }
213
-
214
- render () {
215
- return (
216
- <div className="yasr-guten-block-panel-center">
217
- <div className="rich-snippet-title">{yasrRichSnippetOptions}</div>
218
- <label><span>{yasrPostExcluded}</span></label>
219
- <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-post-is-review">
220
- <input type="checkbox"
221
- name="yasr_post_is_review"
222
- className="yasr-onoffswitch-checkbox"
223
- value="yes"
224
- id="yasr-post-is-review-switch"
225
- defaultChecked={this.state.postIsReview}
226
- onChange={this.yasrUpdatePostMetaIsReview}
227
- />
228
- <label className="yasr-onoffswitch-label" htmlFor="yasr-post-is-review-switch">
229
- <span className="yasr-onoffswitch-inner"></span>
230
- <span className="yasr-onoffswitch-switch"></span>
231
- </label>
232
- </div>
233
- <p></p>
234
- </div>
235
- );
236
- }
237
-
238
- }
239
-
240
- class YasrSideBarSelectSnippets extends React.Component {
241
-
242
- supportedItemtype;
243
-
244
- constructor(props) {
245
- super(props);
246
-
247
- //at the begin, get the default type
248
- let snippetType = yasrConstantGutenberg.defaultItemType;
249
-
250
- //get array with all supported itemtypes
251
- this.supportedItemtype = wp.data.select('core/editor').getCurrentPost().yasr_all_itemtypes;
252
-
253
- //get postmeta itemtype
254
- let postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
255
-
256
- //if the postmeta is in the array of all item, set in the select the postmeta_itemtype
257
- if(this.supportedItemtype.includes(postMetaItemType)) {
258
- snippetType = postMetaItemType;
259
- }
260
-
261
- this.state = {snippet: snippetType};
262
-
263
- this.yasrSetItemType = this.yasrSetItemType.bind(this);
264
- }
265
-
266
- yasrSetItemType(event) {
267
- this.setState({snippet: event.target.value});
268
-
269
- wp.data.dispatch( 'core/editor' ).editPost(
270
- { meta: { yasr_review_type: event.target.value } }
271
- );
272
- }
273
-
274
- render() {
275
- return (
276
- <div className="yasr-guten-block-panel-center">
277
- <label><span>{yasrSelectSnippetTitle}</span></label>
278
- <select value={this.state.snippet} onChange={this.yasrSetItemType}>
279
- {this.supportedItemtype.map((snippet) => {
280
- return <option value={snippet}>{snippet}</option>;
281
- })}
282
- </select>
283
- </div>
284
- );
285
- }
286
- }*/
287
-
288
- var yasrSidebar = function (_React$Component3) {
289
- _inherits(yasrSidebar, _React$Component3);
290
-
291
- function yasrSidebar(props) {
292
- _classCallCheck(this, yasrSidebar);
293
-
294
- var _this3 = _possibleConstructorReturn(this, (yasrSidebar.__proto__ || Object.getPrototypeOf(yasrSidebar)).call(this, props));
295
-
296
- var yasrAutoInsertEnabled = false;
297
-
298
- //this is not for the post, but from settings
299
- if (yasrConstantGutenberg.autoInsert !== 'disabled') {
300
- yasrAutoInsertEnabled = true;
301
- }
302
-
303
- _this3.state = { yasrAutoInsertEnabled: yasrAutoInsertEnabled };
304
-
305
- return _this3;
306
- }
307
-
308
- _createClass(yasrSidebar, [{
309
- key: 'render',
310
- value: function render() {
311
- return React.createElement(
312
- Fragment,
313
- null,
314
- React.createElement(
315
- PluginSidebarMoreMenuItem,
316
- { name: 'yasr-sidebar', type: 'sidebar', target: 'yasr-guten-sidebar' },
317
- __('YASR post settings', 'yet-another-stars-rating')
318
- ),
319
- React.createElement(
320
- PluginSidebar,
321
- { name: 'yasr-guten-sidebar', title: 'YASR Settings' },
322
- React.createElement(
323
- PanelBody,
324
- null,
325
- React.createElement(
326
- 'div',
327
- { className: 'yasr-guten-block-panel yasr-guten-block-panel-center' },
328
- React.createElement(YasrDivRatingOverall, null),
329
- this.state.yasrAutoInsertEnabled && React.createElement(YasrSideBarAutoInsert, null),
330
- React.createElement(ContentBelowSidebar, null)
331
- )
332
- )
333
- )
334
- );
335
- }
336
- }]);
337
-
338
- return yasrSidebar;
339
- }(React.Component);
340
-
341
- //Custom sidebar
342
-
343
-
344
- registerPlugin('yasr-sidebar', {
345
- icon: 'star-half',
346
- title: __('Yasr: Page Settings', 'yet-another-stars-rating'),
347
- render: yasrSidebar
348
- });
1
+ !function(e){var t={};function a(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=e,a.c=t,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,a){e.exports=a(1)},function(e,t){const{registerPlugin:a}=wp.plugins,{PluginSidebar:r,PluginSidebarMoreMenuItem:n}=wp.editPost,{TextControl:s,PanelBody:l,PanelRow:o}=wp.components,{BlockControls:i,InspectorControls:c}=wp.editor,{Fragment:u}=wp.element,d=__("Disable auto insert for this post or page?","yet-another-stars-rating"),p=(__("Rich snippet options","yet-another-stars-rating"),__("Is this a review?","yet-another-stars-rating"),__("Select ItemType ","yet-another-stars-rating"),()=>React.createElement("div",null));class y extends React.Component{shouldComponentUpdate(e,t){return!1}constructor(e){super(e),this.yasrOverallRateThis=__("Rate this article / item","yet-another-stars-rating"),this.yasrOverallMoreInfo=__('This is the same value that you find the "Yasr: Overall Rating" block.',"yet-another-stars-rating")}printDivOverallRater(){return React.createElement("div",null,React.createElement("div",{id:"overall-rater-panel",ref:()=>raterJs({starSize:32,step:.1,showToolTip:!1,rating:wp.data.select("core/editor").getCurrentPost().meta.yasr_overall_rating,readOnly:!1,element:document.querySelector("#overall-rater-panel"),rateCallback:function(e,t){e=e.toFixed(1),e=parseFloat(e),wp.data.dispatch("core/editor").editPost({meta:{yasr_overall_rating:e}}),this.setRating(e),t()}})}),React.createElement("br",null),this.yasrOverallMoreInfo)}render(){return React.createElement("div",null,this.yasrOverallRateThis,React.createElement("div",null,this.printDivOverallRater()))}}class h extends React.Component{constructor(e){super(e);let t=!1;"yes"===wp.data.select("core/editor").getCurrentPost().meta.yasr_auto_insert_disabled&&(t=!0),this.state={postExcluded:t},this.yasrUpdatePostMetaAutoInsert=this.yasrUpdatePostMetaAutoInsert.bind(this)}yasrUpdatePostMetaAutoInsert(e){const t=e.target,a="checkbox"===t.type?t.checked:t.value;this.setState({postExcluded:a}),!0===a?wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"yes"}}):wp.data.dispatch("core/editor").editPost({meta:{yasr_auto_insert_disabled:"no"}})}render(){return React.createElement("div",{className:"yasr-guten-block-panel-center"},React.createElement("hr",null),React.createElement("label",null,React.createElement("span",null,d)),React.createElement("div",{className:"yasr-onoffswitch-big yasr-onoffswitch-big-center",id:"yasr-switcher-disable-auto-insert"},React.createElement("input",{type:"checkbox",name:"yasr_auto_insert_disabled",className:"yasr-onoffswitch-checkbox",value:"yes",id:"yasr-auto-insert-disabled-switch",defaultChecked:this.state.postExcluded,onChange:this.yasrUpdatePostMetaAutoInsert}),React.createElement("label",{className:"yasr-onoffswitch-label",htmlFor:"yasr-auto-insert-disabled-switch"},React.createElement("span",{className:"yasr-onoffswitch-inner"}),React.createElement("span",{className:"yasr-onoffswitch-switch"}))))}}class m extends React.Component{constructor(e){super(e);let t=!1;"disabled"!==yasrConstantGutenberg.autoInsert&&(t=!0),this.state={yasrAutoInsertEnabled:t}}render(){return React.createElement(u,null,React.createElement(n,{name:"yasr-sidebar",type:"sidebar",target:"yasr-guten-sidebar"},__("YASR post settings","yet-another-stars-rating")),React.createElement(r,{name:"yasr-guten-sidebar",title:"YASR Settings"},React.createElement(l,null,React.createElement("div",{className:"yasr-guten-block-panel yasr-guten-block-panel-center"},React.createElement(y,null),this.state.yasrAutoInsertEnabled&&React.createElement(h,null),React.createElement(p,null)))))}}a("yasr-sidebar",{icon:"star-half",title:__("Yasr: Page Settings","yet-another-stars-rating"),render:m})}]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/css/yasr.css CHANGED
@@ -199,6 +199,7 @@ yasr_pro_comment_reviews_stats shortcode too***/
199
 
200
  .tippy-tooltip.yasr-theme {
201
  background-color: white;
 
202
  }
203
 
204
  /* If `animateFill: false` */
199
 
200
  .tippy-tooltip.yasr-theme {
201
  background-color: white;
202
+ color: black;
203
  }
204
 
205
  /* If `animateFill: false` */
includes/js/src/yasr-front.js CHANGED
@@ -104,7 +104,9 @@ function yasrDrawTipsProgress (yasrStatsInDom) {
104
  onShow: function onShow(tip) {
105
 
106
  if (htmlId !== htmlIdChecked) {
107
- jQuery.get(yasrCommonData.ajaxurl, data, function (response) {
 
 
108
  response = JSON.parse(response);
109
  tip.setContent(response);
110
  });
@@ -155,12 +157,16 @@ function yasrSetRatingOnLoad (yasrRatingsInDom) {
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;
@@ -185,7 +191,13 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
185
 
186
  jQuery.get(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;
@@ -195,16 +207,19 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
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(
104
  onShow: function onShow(tip) {
105
 
106
  if (htmlId !== htmlIdChecked) {
107
+
108
+ //must be post or wont work
109
+ jQuery.post(yasrCommonData.ajaxurl, data, function (response) {
110
  response = JSON.parse(response);
111
  tip.setContent(response);
112
  });
157
  function yasrVisitorVotesFront (yasrRaterVVInDom) {
158
 
159
  //Check in the object
160
+ for (let i = 0; i < yasrRaterVVInDom.length; i++) {
161
 
162
  (function(i) {
163
 
164
+ let rating = yasrRaterVVInDom.item(i).getAttribute('data-rating');
165
+ let readonlyShortcode = yasrRaterVVInDom.item(i).getAttribute('data-rater-readonly');
166
+
167
+ readonlyShortcode = yasrTrueFalseStringConvertion(readonlyShortcode);
168
+
169
+ let readonly = readonlyShortcode;
170
 
171
  let postId = yasrRaterVVInDom.item(i).getAttribute('data-rater-postid');
172
  let htmlId = yasrRaterVVInDom.item(i).id;
191
 
192
  jQuery.get(yasrCommonData.restEndpoint + urlVisitorVotes).done(
193
  function (data) {
194
+ let readonly;
195
+ //if has readonly attribute, it is always true
196
+ if(readonlyShortcode === true) {
197
+ readonly = true;
198
+ } else {
199
+ readonly = data.yasr_visitor_votes.stars_attributes.read_only;
200
+ }
201
 
202
  if (data.yasr_visitor_votes.number_of_votes > 0) {
203
  rating = data.yasr_visitor_votes.sum_votes / data.yasr_visitor_votes.number_of_votes;
207
  rating = rating.toFixed(1);
208
  rating = parseFloat(rating);
209
 
 
 
 
210
  yasrSetVisitorVotesRater(starSize, rating, postId, readonly, htmlId, uniqueId, nonce, isSingular, containerAfterStarsID);
211
 
212
+ //do this only if yasr_visitor_votes has not the readonly attribute
213
+ if(readonlyShortcode !== true) {
214
+ document.getElementById(containerVotesNumber).innerHTML = data.yasr_visitor_votes.number_of_votes;
215
+ document.getElementById(containerAverageNumber).innerHTML = rating;
216
+
217
+ //insert span with text after the average
218
+ if(data.yasr_visitor_votes.stars_attributes.span_bottom !== false) {
219
+ spanBottom = data.yasr_visitor_votes.stars_attributes.span_bottom;
220
+ let yasrTotalAverageContainer = document.getElementById(containerAfterStarsID);
221
+ yasrTotalAverageContainer.insertAdjacentHTML('beforeend', spanBottom);
222
+ }
223
  }
224
 
225
  }).fail(
includes/js/yasr-front.js CHANGED
@@ -1 +1 @@
1
- !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e){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,i,s,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:s,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 i=document.getElementsByClassName("yasr-rater-stars-visitor-votes");i.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"),i=t.item(e).getAttribute("data-rater-postid"),s=t.item(e).id,u=s.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 g=t.item(e).getAttribute("data-cpt");""===g&&(g="posts");let p="wp/v2/"+g+"/"+i+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+p).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,i,o,s,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,i,o,s,u,l,m,f)}))}else n(d,a,i,o,s,u,l,m,f)}(e)}(i);var s=document.getElementsByClassName("yasr-multiset-visitors-rater");if(s.length>0&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){var n=t.item(a).id,i=t.item(a).getAttribute("data-rater-readonly");i=o(i);var s=document.querySelector("#"+n);raterJs({starSize:16,step:1,showToolTip:!1,readOnly:i,element:s,rateCallback:function(t,a){var n=s.getAttribute("data-rater-postid"),o=s.getAttribute("data-rater-setid"),i=s.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var u=parseInt(t);this.setRating(u),e={postid:n,setid:o,field:i,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)}))}))}(s),i&&"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.get(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")}))}]);
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,i,s,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:s,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 i=document.getElementsByClassName("yasr-rater-stars-visitor-votes");i.length>0&&function(t){for(let e=0;e<t.length;e++)!function(e){let a=t.item(e).getAttribute("data-rating"),i=t.item(e).getAttribute("data-rater-readonly");i=o(i);let s=i,u=t.item(e).getAttribute("data-rater-postid"),d=t.item(e).id,l=d.replace("yasr-visitor-votes-rater-",""),m=parseInt(t.item(e).getAttribute("data-rater-starsize")),c=t.item(e).getAttribute("data-rater-nonce"),y=t.item(e).getAttribute("data-issingular"),f="yasr-vv-votes-number-container-"+l,v="yasr-vv-average-container-"+l,g="yasr-visitor-votes-container-after-stars-"+l,p=!1;if("yes"===yasrCommonData.ajaxEnabled){let o=t.item(e).getAttribute("data-cpt");""===o&&(o="posts");let _="wp/v2/"+o+"/"+u+"?_fields=yasr_visitor_votes&_wpnonce="+yasrCommonData.nonce;jQuery.get(yasrCommonData.restEndpoint+_).done((function(t){let e;if(e=!0===i||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),n(m,a,u,e,d,l,c,y,g),!0!==i&&(document.getElementById(f).innerHTML=t.yasr_visitor_votes.number_of_votes,document.getElementById(v).innerHTML=a,!1!==t.yasr_visitor_votes.stars_attributes.span_bottom)){p=t.yasr_visitor_votes.stars_attributes.span_bottom,document.getElementById(g).insertAdjacentHTML("beforeend",p)}})).fail((function(t,e,o,i){console.info(r("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),n(m,a,u,s,d,l,c,y,g)}))}else n(m,a,u,s,d,l,c,y,g)}(e)}(i);var s=document.getElementsByClassName("yasr-multiset-visitors-rater");if(s.length>0&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){var n=t.item(a).id,i=t.item(a).getAttribute("data-rater-readonly");i=o(i);var s=document.querySelector("#"+n);raterJs({starSize:16,step:1,showToolTip:!1,readOnly:i,element:s,rateCallback:function(t,a){var n=s.getAttribute("data-rater-postid"),o=s.getAttribute("data-rater-setid"),i=s.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var u=parseInt(t);this.setRating(u),e={postid:n,setid:o,field:i,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)}))}))}(s),i&&"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/shortcodes/yasr-shortcode-ajax.php CHANGED
@@ -329,7 +329,7 @@ function yasr_stats_visitors_votes_callback() {
329
  $votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
330
  $votes_number = $votes_array['number_of_votes'];
331
 
332
- if ($votes_number != 0) {
333
  $medium_rating = ($votes_array['sum_votes'] / $votes_number);
334
  } else {
335
  $medium_rating = 0;
329
  $votes_array = YasrDatabaseRatings::getVisitorVotes($post_id);
330
  $votes_number = $votes_array['number_of_votes'];
331
 
332
+ if ($votes_number !== 0) {
333
  $medium_rating = ($votes_array['sum_votes'] / $votes_number);
334
  } else {
335
  $medium_rating = 0;
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','wp-i18n'),
82
  YASR_VERSION_NUM,
83
  true);
84
 
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
 
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.8
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
@@ -142,6 +142,11 @@ If doesn't, you should work on your seo reputation.
142
 
143
  The full changelog can be found in the plugin's directory. Recent entries:
144
 
 
 
 
 
 
145
  = 2.3.8 =
146
  * TWEAKED: Using GET instead of POST when getting rest response
147
 
@@ -174,7 +179,7 @@ You may need to save again "Publisher name" and "Image Url"
174
  = 2.3.2 =
175
  * FIXED: Uncaught TypeError randomly shows up in the browser console
176
  * TWEAKED: removed deprecated multisite function
177
- * TWEAKED: in tht settings page, the "custom css" textarea is now a text editor
178
  * TWEAKED: CSS improvement in settings page
179
  * TWEAKED: minor code cleanup
180
 
5
  Contributors: Dudo
6
  Tested up to: 5.5
7
  Requires PHP: 5.3
8
+ Stable tag: 2.3.9
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
142
 
143
  The full changelog can be found in the plugin's directory. Recent entries:
144
 
145
+ = 2.3.9 =
146
+ * FIXED: yasr_visitor_votes readonly didn't show up if load results with ajax is enabled
147
+ * FIXED: missing fragment error if gutenber used
148
+ * FIXED: empty tooltip on yasr_visitor_votes
149
+
150
  = 2.3.8 =
151
  * TWEAKED: Using GET instead of POST when getting rest response
152
 
179
  = 2.3.2 =
180
  * FIXED: Uncaught TypeError randomly shows up in the browser console
181
  * TWEAKED: removed deprecated multisite function
182
+ * TWEAKED: in the settings page, the "custom css" textarea is now a text editor
183
  * TWEAKED: CSS improvement in settings page
184
  * TWEAKED: minor code cleanup
185
 
yet-another-stars-rating.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
- * Version: 2.3.8
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
@@ -76,7 +76,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
- define( 'YASR_VERSION_NUM', '2.3.8' );
80
  //Plugin absolute path
81
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
82
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
+ * Version: 2.3.9
8
  * Author: Dario Curvino
9
  * Author URI: https://dariocurvino.it/
10
  * Text Domain: yet-another-stars-rating
76
  yasr_fs();
77
  // Signal that SDK was initiated.
78
  do_action( 'yasr_fs_loaded' );
79
+ define( 'YASR_VERSION_NUM', '2.3.9' );
80
  //Plugin absolute path
81
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
82
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );