Yasr – Yet Another Stars Rating - Version 2.0.6

Version Description

  • NEW FEATURE: in Gutenberg, is now possible to rate "overall Rating" in both blocks and sidebar
  • IMPORTANT CHANGES ON RICH SNIPPETS: due to this google announcement BlogPosting data type doesn't have ratings anymore. These types have been added: Book, Movie, Game. Many other support types will comes.
Download this release

Release Info

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

Code changes from version 2.0.5 to 2.0.6

js/src/yasr-guten-panel.js CHANGED
@@ -6,11 +6,77 @@ const {BlockControls,InspectorControls} = wp.editor;
6
const yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
7
const yasrSelectSnippetTitle = __('This review is about a... ', 'yet-another-stars-rating');
8
const yasrSetItemTypeProduct = __('Product', 'yet-another-stars-rating');
9
- const yasrSetItemTypePlace = __('Place', 'yet-another-stars-rating');
10
const yasrSetItemTypeRecipe = __('Recipe', 'yet-another-stars-rating');
11
- const yasrSetItemTypeOther = __('Other', 'yet-another-stars-rating');
12
13
14
class YasrSideBarAutoInsert extends React.Component {
15
16
constructor(props) {
@@ -84,8 +150,14 @@ class YasrSideBarSelectSnippets extends React.Component {
84
let postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
85
86
//if post meta value is one of this overwrite snippetType
87
- if (postMetaItemType === 'Product' || postMetaItemType === 'Place' || postMetaItemType === 'Recipe'
88
- || postMetaItemType === 'Other') {
89
snippetType = postMetaItemType;
90
}
91
@@ -109,9 +181,12 @@ class YasrSideBarSelectSnippets extends React.Component {
109
<form>
110
<select value={this.state.snippet} onChange={this.yasrSetItemType}>
111
<option value="Product">{yasrSetItemTypeProduct}</option>
112
<option value="Place">{yasrSetItemTypePlace}</option>
113
<option value="Recipe">{yasrSetItemTypeRecipe}</option>
114
- <option value="Other">{yasrSetItemTypeOther}</option>
115
</select>
116
</form>
117
</div>
@@ -138,13 +213,16 @@ class yasrSidebar extends React.Component {
138
render() {
139
return (
140
<Fragment>
141
- <PluginSidebarMoreMenuItem name="my-plugin-sidebar" type="sidebar" target="yasr-guten-sidebar" >
142
{ __( 'YASR post settings', 'yet-another-stars-rating' ) }
143
</PluginSidebarMoreMenuItem>
144
<PluginSidebar name="yasr-guten-sidebar" title="YASR Settings">
145
<PanelBody>
146
- {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert/>}
147
- <YasrSideBarSelectSnippets/>
148
</PanelBody>
149
</PluginSidebar>
150
</Fragment>
@@ -153,7 +231,7 @@ class yasrSidebar extends React.Component {
153
}
154
155
156
- // Our custom sidebar
157
registerPlugin( 'yasr-sidebar', {
158
icon: 'star-half',
159
title: __( 'Yasr: Page Settings', 'yet-another-stars-rating' ),
6
const yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
7
const yasrSelectSnippetTitle = __('This review is about a... ', 'yet-another-stars-rating');
8
const yasrSetItemTypeProduct = __('Product', 'yet-another-stars-rating');
9
+ const yasrSetItemTypeBook = __('Book', 'yet-another-stars-rating');
10
+ const yasrSetItemTypeMovie = __('Movie', 'yet-another-stars-rating');
11
+ const yasrSetItemTypeGame = __('Game', 'yet-another-stars-rating');
12
+ const yasrSetItemTypePlace = __('LocalBusiness', 'yet-another-stars-rating');
13
const yasrSetItemTypeRecipe = __('Recipe', 'yet-another-stars-rating');
14
+ const yasrSetItemBlogPosting = __('BlogPosting', 'yet-another-stars-rating');
15
16
17
+ class YasrDivRatingOverall extends React.Component {
18
+
19
+ shouldComponentUpdate(nextProps, nextState) {
20
+ return false;
21
+ }
22
+
23
+ constructor(props) {
24
+ super(props);
25
+ this.yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
26
+ this.yasrOverallMoreInfo =
27
+ __("This is the same value that you find the \"Yasr: Overall Rating\" block.",
28
+ 'yet-another-stars-rating');
29
+ }
30
+
31
+ printDivOverallRater() {
32
+ return(
33
+ <div>
34
+ <div id="overall-rater-panel" ref={()=>
35
+ raterJs({
36
+ starSize: 32,
37
+ step: 0.1,
38
+ showToolTip: false,
39
+ rating: wp.data.select('core/editor').getCurrentPost().meta.yasr_overall_rating,
40
+ readOnly: false,
41
+ element: document.querySelector("#overall-rater-panel"),
42
+ rateCallback: function(rating, done){
43
+
44
+ rating = rating.toFixed(1);
45
+ rating = parseFloat(rating);
46
+
47
+ wp.data.dispatch('core/editor').editPost(
48
+ { meta: { yasr_overall_rating: rating } }
49
+ );
50
+
51
+ this.setRating(rating);
52
+
53
+ done();
54
+ }
55
+ })
56
+ }
57
+ />
58
+ <br />
59
+ {this.yasrOverallMoreInfo}
60
+ <hr />
61
+ </div>
62
+ )
63
+ }
64
+
65
+
66
+ render () {
67
+ return (
68
+ <div>
69
+ {this.yasrOverallRateThis}
70
+ <div>
71
+ {this.printDivOverallRater()}
72
+ </div>
73
+ </div>
74
+
75
+ );
76
+ }
77
+
78
+ }
79
+
80
class YasrSideBarAutoInsert extends React.Component {
81
82
constructor(props) {
150
let postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
151
152
//if post meta value is one of this overwrite snippetType
153
+ if (postMetaItemType === 'Product'
154
+ || postMetaItemType === 'Book'
155
+ || postMetaItemType === 'Movie'
156
+ || postMetaItemType === 'Game'
157
+ || postMetaItemType === 'Place'
158
+ || postMetaItemType === 'Recipe'
159
+ || postMetaItemType === 'Other'
160
+ ) {
161
snippetType = postMetaItemType;
162
}
163
181
<form>
182
<select value={this.state.snippet} onChange={this.yasrSetItemType}>
183
<option value="Product">{yasrSetItemTypeProduct}</option>
184
+ <option value="Book">{yasrSetItemTypeBook}</option>
185
+ <option value="Movie">{yasrSetItemTypeMovie}</option>
186
+ <option value="Game">{yasrSetItemTypeGame}</option>
187
<option value="Place">{yasrSetItemTypePlace}</option>
188
<option value="Recipe">{yasrSetItemTypeRecipe}</option>
189
+ <option value="Other">{yasrSetItemBlogPosting}</option>
190
</select>
191
</form>
192
</div>
213
render() {
214
return (
215
<Fragment>
216
+ <PluginSidebarMoreMenuItem name="yasr-sidebar" type="sidebar" target="yasr-guten-sidebar" >
217
{ __( 'YASR post settings', 'yet-another-stars-rating' ) }
218
</PluginSidebarMoreMenuItem>
219
<PluginSidebar name="yasr-guten-sidebar" title="YASR Settings">
220
<PanelBody>
221
+ <div className="yasr-guten-block-panel yasr-guten-block-panel-center">
222
+ <YasrDivRatingOverall />
223
+ {this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert/>}
224
+ <YasrSideBarSelectSnippets/>
225
+ </div>
226
</PanelBody>
227
</PluginSidebar>
228
</Fragment>
231
}
232
233
234
+ //Custom sidebar
235
registerPlugin( 'yasr-sidebar', {
236
icon: 'star-half',
237
title: __( 'Yasr: Page Settings', 'yet-another-stars-rating' ),
js/yasr-admin.js CHANGED
@@ -251,64 +251,11 @@ function YasrSettingsPage(activeTab, nMultiSet, autoInsertEnabled, textBeforeSta
251
252
});
253
254
-
255
- /*if (jQuery('#yasr_text_before_star_off').is(':checked')) {
256
- jQuery('.yasr-general-options-text-before').prop('disabled', true);
257
- }
258
-
259
- jQuery('#yasr_text_before_star_on').on('click', function(){
260
-
261
- jQuery('.yasr-general-options-text-before').prop('disabled', false);
262
- jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');
263
- jQuery('#yasr-general-options-custom-text-before-visitor').val('Our Reader Score');
264
- jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');
265
- jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted for this article');
266
-
267
- });*/
268
-
269
jQuery('#yasr-doc-custom-text-link').on('click', function () {
270
jQuery('#yasr-doc-custom-text-div').toggle('slow');
271
return false;
272
});
273
274
- jQuery('#yasr-snippet-explained-link').on('click', function () {
275
- jQuery('#yasr-snippet-explained').toggle('slow');
276
- return false; // prevent default click action from happening!
277
- });
278
-
279
- jQuery('#yasr-stats-explained-link').on('click', function () {
280
- jQuery('#yasr-stats-explained').toggle('slow');
281
- return false; // prevent default click action from happening!
282
- });
283
-
284
-
285
- /*//If on document ready "BlogPosting" is checked show the additional fields
286
- if (jQuery('#yasr_choose_snippet_blogposting').is(':checked')) {
287
- jQuery('#yasr-blogPosting-additional-info').show();
288
- jQuery('.yasr-blogPosting-additional-info-inputs').prop('disabled', false);
289
- }
290
-
291
- //On change show or hide the additional fields
292
- jQuery('#yasr-choose-snippet-type input[type=radio]').change(function(){
293
- var snippet_type = jQuery(this).val();
294
-
295
- if (snippet_type === 'Other') {
296
-
297
- jQuery('#yasr-blogPosting-additional-info').show();
298
- jQuery('.yasr-blogPosting-additional-info-inputs').prop('disabled', false);
299
-
300
- }
301
-
302
- else {
303
- jQuery('.yasr-blogPosting-additional-info-inputs').prop('disabled', true);
304
- jQuery('#yasr-blogPosting-additional-info').hide();
305
-
306
- }
307
-
308
- return false;
309
-
310
- });*/
311
-
312
} //End if general settings
313
314
//--------------Multi Sets Page ------------------
251
252
});
253
254
jQuery('#yasr-doc-custom-text-link').on('click', function () {
255
jQuery('#yasr-doc-custom-text-div').toggle('slow');
256
return false;
257
});
258
259
} //End if general settings
260
261
//--------------Multi Sets Page ------------------
js/yasr-guten-panel.js CHANGED
@@ -22,17 +22,92 @@ var _wp$editor = wp.editor,
22
var yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
23
var yasrSelectSnippetTitle = __('This review is about a... ', 'yet-another-stars-rating');
24
var yasrSetItemTypeProduct = __('Product', 'yet-another-stars-rating');
25
- var yasrSetItemTypePlace = __('Place', 'yet-another-stars-rating');
26
var yasrSetItemTypeRecipe = __('Recipe', 'yet-another-stars-rating');
27
- var yasrSetItemTypeOther = __('Other', 'yet-another-stars-rating');
28
29
- var YasrSideBarAutoInsert = function (_React$Component) {
30
- _inherits(YasrSideBarAutoInsert, _React$Component);
31
32
function YasrSideBarAutoInsert(props) {
33
_classCallCheck(this, YasrSideBarAutoInsert);
34
35
- var _this = _possibleConstructorReturn(this, (YasrSideBarAutoInsert.__proto__ || Object.getPrototypeOf(YasrSideBarAutoInsert)).call(this, props));
36
37
var isThisPostExluded = wp.data.select('core/editor').getCurrentPost().meta.yasr_auto_insert_disabled;
38
var isThisPostExludedCheckbox = false;
@@ -41,10 +116,10 @@ var YasrSideBarAutoInsert = function (_React$Component) {
41
isThisPostExludedCheckbox = true;
42
}
43
44
- _this.state = { postExcluded: isThisPostExludedCheckbox };
45
46
- _this.yasrUpdatePostMetaAutoInsert = _this.yasrUpdatePostMetaAutoInsert.bind(_this);
47
- return _this;
48
}
49
50
_createClass(YasrSideBarAutoInsert, [{
@@ -103,14 +178,14 @@ var YasrSideBarAutoInsert = function (_React$Component) {
103
return YasrSideBarAutoInsert;
104
}(React.Component);
105
106
- var YasrSideBarSelectSnippets = function (_React$Component2) {
107
- _inherits(YasrSideBarSelectSnippets, _React$Component2);
108
109
function YasrSideBarSelectSnippets(props) {
110
_classCallCheck(this, YasrSideBarSelectSnippets);
111
112
//at the begin, get the default type
113
- var _this2 = _possibleConstructorReturn(this, (YasrSideBarSelectSnippets.__proto__ || Object.getPrototypeOf(YasrSideBarSelectSnippets)).call(this, props));
114
115
var snippetType = yasrConstantGutenberg.defaultItemType;
116
@@ -118,14 +193,14 @@ var YasrSideBarSelectSnippets = function (_React$Component2) {
118
var postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
119
120
//if post meta value is one of this overwrite snippetType
121
- if (postMetaItemType === 'Product' || postMetaItemType === 'Place' || postMetaItemType === 'Recipe' || postMetaItemType === 'Other') {
122
snippetType = postMetaItemType;
123
}
124
125
- _this2.state = { snippet: snippetType };
126
127
- _this2.yasrSetItemType = _this2.yasrSetItemType.bind(_this2);
128
- return _this2;
129
}
130
131
_createClass(YasrSideBarSelectSnippets, [{
@@ -161,6 +236,21 @@ var YasrSideBarSelectSnippets = function (_React$Component2) {
161
{ value: 'Product' },
162
yasrSetItemTypeProduct
163
),
164
React.createElement(
165
'option',
166
{ value: 'Place' },
@@ -174,7 +264,7 @@ var YasrSideBarSelectSnippets = function (_React$Component2) {
174
React.createElement(
175
'option',
176
{ value: 'Other' },
177
- yasrSetItemTypeOther
178
)
179
)
180
)
@@ -185,13 +275,13 @@ var YasrSideBarSelectSnippets = function (_React$Component2) {
185
return YasrSideBarSelectSnippets;
186
}(React.Component);
187
188
- var yasrSidebar = function (_React$Component3) {
189
- _inherits(yasrSidebar, _React$Component3);
190
191
function yasrSidebar(props) {
192
_classCallCheck(this, yasrSidebar);
193
194
- var _this3 = _possibleConstructorReturn(this, (yasrSidebar.__proto__ || Object.getPrototypeOf(yasrSidebar)).call(this, props));
195
196
var yasrAutoInsertEnabled = false;
197
@@ -200,9 +290,9 @@ var yasrSidebar = function (_React$Component3) {
200
yasrAutoInsertEnabled = true;
201
}
202
203
- _this3.state = { yasrAutoInsertEnabled: yasrAutoInsertEnabled };
204
205
- return _this3;
206
}
207
208
_createClass(yasrSidebar, [{
@@ -213,7 +303,7 @@ var yasrSidebar = function (_React$Component3) {
213
null,
214
React.createElement(
215
PluginSidebarMoreMenuItem,
216
- { name: 'my-plugin-sidebar', type: 'sidebar', target: 'yasr-guten-sidebar' },
217
__('YASR post settings', 'yet-another-stars-rating')
218
),
219
React.createElement(
@@ -222,8 +312,13 @@ var yasrSidebar = function (_React$Component3) {
222
React.createElement(
223
PanelBody,
224
null,
225
- this.state.yasrAutoInsertEnabled && React.createElement(YasrSideBarAutoInsert, null),
226
- React.createElement(YasrSideBarSelectSnippets, null)
227
)
228
)
229
);
@@ -233,7 +328,7 @@ var yasrSidebar = function (_React$Component3) {
233
return yasrSidebar;
234
}(React.Component);
235
236
- // Our custom sidebar
237
238
239
registerPlugin('yasr-sidebar', {
22
var yasrDisableAutoInsert = __('Disable auto insert for this post or page?', 'yet-another-stars-rating');
23
var yasrSelectSnippetTitle = __('This review is about a... ', 'yet-another-stars-rating');
24
var yasrSetItemTypeProduct = __('Product', 'yet-another-stars-rating');
25
+ var yasrSetItemTypeBook = __('Book', 'yet-another-stars-rating');
26
+ var yasrSetItemTypeMovie = __('Movie', 'yet-another-stars-rating');
27
+ var yasrSetItemTypeGame = __('Game', 'yet-another-stars-rating');
28
+ var yasrSetItemTypePlace = __('LocalBusiness', 'yet-another-stars-rating');
29
var yasrSetItemTypeRecipe = __('Recipe', 'yet-another-stars-rating');
30
+ var yasrSetItemBlogPosting = __('BlogPosting', 'yet-another-stars-rating');
31
32
+ var YasrDivRatingOverall = function (_React$Component) {
33
+ _inherits(YasrDivRatingOverall, _React$Component);
34
+
35
+ _createClass(YasrDivRatingOverall, [{
36
+ key: 'shouldComponentUpdate',
37
+ value: function shouldComponentUpdate(nextProps, nextState) {
38
+ return false;
39
+ }
40
+ }]);
41
+
42
+ function YasrDivRatingOverall(props) {
43
+ _classCallCheck(this, YasrDivRatingOverall);
44
+
45
+ var _this = _possibleConstructorReturn(this, (YasrDivRatingOverall.__proto__ || Object.getPrototypeOf(YasrDivRatingOverall)).call(this, props));
46
+
47
+ _this.yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
48
+ _this.yasrOverallMoreInfo = __("This is the same value that you find the \"Yasr: Overall Rating\" block.", 'yet-another-stars-rating');
49
+ return _this;
50
+ }
51
+
52
+ _createClass(YasrDivRatingOverall, [{
53
+ key: 'printDivOverallRater',
54
+ value: function printDivOverallRater() {
55
+ return React.createElement(
56
+ 'div',
57
+ null,
58
+ React.createElement('div', { id: 'overall-rater-panel', ref: function ref() {
59
+ return raterJs({
60
+ starSize: 32,
61
+ step: 0.1,
62
+ showToolTip: false,
63
+ rating: wp.data.select('core/editor').getCurrentPost().meta.yasr_overall_rating,
64
+ readOnly: false,
65
+ element: document.querySelector("#overall-rater-panel"),
66
+ rateCallback: function rateCallback(rating, done) {
67
+
68
+ rating = rating.toFixed(1);
69
+ rating = parseFloat(rating);
70
+
71
+ wp.data.dispatch('core/editor').editPost({ meta: { yasr_overall_rating: rating } });
72
+
73
+ this.setRating(rating);
74
+
75
+ done();
76
+ }
77
+ });
78
+ }
79
+ }),
80
+ React.createElement('br', null),
81
+ this.yasrOverallMoreInfo,
82
+ React.createElement('hr', null)
83
+ );
84
+ }
85
+ }, {
86
+ key: 'render',
87
+ value: function render() {
88
+ return React.createElement(
89
+ 'div',
90
+ null,
91
+ this.yasrOverallRateThis,
92
+ React.createElement(
93
+ 'div',
94
+ null,
95
+ this.printDivOverallRater()
96
+ )
97
+ );
98
+ }
99
+ }]);
100
+
101
+ return YasrDivRatingOverall;
102
+ }(React.Component);
103
+
104
+ var YasrSideBarAutoInsert = function (_React$Component2) {
105
+ _inherits(YasrSideBarAutoInsert, _React$Component2);
106
107
function YasrSideBarAutoInsert(props) {
108
_classCallCheck(this, YasrSideBarAutoInsert);
109
110
+ var _this2 = _possibleConstructorReturn(this, (YasrSideBarAutoInsert.__proto__ || Object.getPrototypeOf(YasrSideBarAutoInsert)).call(this, props));
111
112
var isThisPostExluded = wp.data.select('core/editor').getCurrentPost().meta.yasr_auto_insert_disabled;
113
var isThisPostExludedCheckbox = false;
116
isThisPostExludedCheckbox = true;
117
}
118
119
+ _this2.state = { postExcluded: isThisPostExludedCheckbox };
120
121
+ _this2.yasrUpdatePostMetaAutoInsert = _this2.yasrUpdatePostMetaAutoInsert.bind(_this2);
122
+ return _this2;
123
}
124
125
_createClass(YasrSideBarAutoInsert, [{
178
return YasrSideBarAutoInsert;
179
}(React.Component);
180
181
+ var YasrSideBarSelectSnippets = function (_React$Component3) {
182
+ _inherits(YasrSideBarSelectSnippets, _React$Component3);
183
184
function YasrSideBarSelectSnippets(props) {
185
_classCallCheck(this, YasrSideBarSelectSnippets);
186
187
//at the begin, get the default type
188
+ var _this3 = _possibleConstructorReturn(this, (YasrSideBarSelectSnippets.__proto__ || Object.getPrototypeOf(YasrSideBarSelectSnippets)).call(this, props));
189
190
var snippetType = yasrConstantGutenberg.defaultItemType;
191
193
var postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
194
195
//if post meta value is one of this overwrite snippetType
196
+ if (postMetaItemType === 'Product' || postMetaItemType === 'Book' || postMetaItemType === 'Movie' || postMetaItemType === 'Game' || postMetaItemType === 'Place' || postMetaItemType === 'Recipe' || postMetaItemType === 'Other') {
197
snippetType = postMetaItemType;
198
}
199
200
+ _this3.state = { snippet: snippetType };
201
202
+ _this3.yasrSetItemType = _this3.yasrSetItemType.bind(_this3);
203
+ return _this3;
204
}
205
206
_createClass(YasrSideBarSelectSnippets, [{
236
{ value: 'Product' },
237
yasrSetItemTypeProduct
238
),
239
+ React.createElement(
240
+ 'option',
241
+ { value: 'Book' },
242
+ yasrSetItemTypeBook
243
+ ),
244
+ React.createElement(
245
+ 'option',
246
+ { value: 'Movie' },
247
+ yasrSetItemTypeMovie
248
+ ),
249
+ React.createElement(
250
+ 'option',
251
+ { value: 'Game' },
252
+ yasrSetItemTypeGame
253
+ ),
254
React.createElement(
255
'option',
256
{ value: 'Place' },
264
React.createElement(
265
'option',
266
{ value: 'Other' },
267
+ yasrSetItemBlogPosting
268
)
269
)
270
)
275
return YasrSideBarSelectSnippets;
276
}(React.Component);
277
278
+ var yasrSidebar = function (_React$Component4) {
279
+ _inherits(yasrSidebar, _React$Component4);
280
281
function yasrSidebar(props) {
282
_classCallCheck(this, yasrSidebar);
283
284
+ var _this4 = _possibleConstructorReturn(this, (yasrSidebar.__proto__ || Object.getPrototypeOf(yasrSidebar)).call(this, props));
285
286
var yasrAutoInsertEnabled = false;
287
290
yasrAutoInsertEnabled = true;
291
}
292
293
+ _this4.state = { yasrAutoInsertEnabled: yasrAutoInsertEnabled };
294
295
+ return _this4;
296
}
297
298
_createClass(yasrSidebar, [{
303
null,
304
React.createElement(
305
PluginSidebarMoreMenuItem,
306
+ { name: 'yasr-sidebar', type: 'sidebar', target: 'yasr-guten-sidebar' },
307
__('YASR post settings', 'yet-another-stars-rating')
308
),
309
React.createElement(
312
React.createElement(
313
PanelBody,
314
null,
315
+ React.createElement(
316
+ 'div',
317
+ { className: 'yasr-guten-block-panel yasr-guten-block-panel-center' },
318
+ React.createElement(YasrDivRatingOverall, null),
319
+ this.state.yasrAutoInsertEnabled && React.createElement(YasrSideBarAutoInsert, null),
320
+ React.createElement(YasrSideBarSelectSnippets, null)
321
+ )
322
)
323
)
324
);
328
return yasrSidebar;
329
}(React.Component);
330
331
+ //Custom sidebar
332
333
334
registerPlugin('yasr-sidebar', {
lib/admin/settings/yasr-settings-functions.php CHANGED
@@ -297,7 +297,7 @@ function yasr_auto_insert_callback($option) {
297
?>
298
299
<?php
300
- submit_button(SAVE_All_SETTINGS_TEXT);
301
?>
302
303
</div>
@@ -399,7 +399,7 @@ function yasr_custom_text_callback($option) {
399
<p>&nbsp;</p>
400
401
<?php
402
- submit_button(SAVE_All_SETTINGS_TEXT);
403
echo '<hr />';
404
405
}
@@ -451,7 +451,7 @@ function yasr_show_visitor_votes_in_loop_callback($option) {
451
<p>&nbsp;</p>
452
453
<?php
454
- submit_button(SAVE_All_SETTINGS_TEXT);
455
?>
456
457
<br/>
@@ -578,7 +578,7 @@ function yasr_enable_ip_callback($option) {
578
<br/><p>&nbsp;</p>
579
580
<?php
581
- submit_button(SAVE_All_SETTINGS_TEXT);
582
?>
583
584
<hr>
@@ -594,87 +594,42 @@ function yasr_choose_snippet_callback($option) {
594
595
?>
596
597
- <strong><?php _e('Which rich snippet do you want to use?', 'yet-another-stars-rating'); ?></strong>
598
-
599
- <div class="yasr-indented-answer">
600
-
601
- <input type="radio" name="yasr_general_options[snippet]" value="visitor_rating"
602
- class="yasr_choose_snippet" <?php if ($option['snippet'] === 'visitor_rating') {
603
- echo " checked=\"checked\" ";
604
- } ?> >
605
- <?php _e('Aggregate Rating', 'yet-another-stars-rating') ?>
606
- <br/>
607
-
608
- <input type="radio" name="yasr_general_options[snippet]" value="overall_rating"
609
- class="yasr_choose_snippet" <?php if ($option['snippet'] === 'overall_rating') {
610
- echo " checked=\"checked\" ";
611
- } ?> >
612
- <?php _e('Review Rating', 'yet-another-stars-rating') ?>
613
- <br/>
614
-
615
- <p>&nbsp;</p>
616
-
617
- <a href="#" id="yasr-snippet-explained-link"><?php _e("What is this?", 'yet-another-stars-rating') ?></a>
618
-
619
- <div id="yasr-snippet-explained" class="yasr-help-box-settings">
620
- <?php
621
-
622
- _e('If you select "Review Rating", rating average is get from yasr_overall_rating shortcode.
623
- Your site will be indexed from search engines like this: ', 'yet-another-stars-rating');
624
- echo "<hr /><img src=" . YASR_IMG_DIR . "yasr_review.png>";
625
-
626
- echo "<br /> <br />";
627
-
628
- $string_aggregate=sprintf(__(
629
- '%sIf, instead,%s you choose "Aggregate Rating", your site will be indexed like this, getting the data from your visitors ratings',
630
- 'yet-another-stars-rating'
631
- ),'<strong>', '</strong>');
632
- echo "$string_aggregate<hr /><img src=" . YASR_IMG_DIR . "yasr_aggregate.jpg>";
633
- ?>
634
- </div>
635
-
636
- </div>
637
-
638
- <br/>
639
-
640
- <br/>
641
-
642
<strong><?php _e('Select default item type for all post or pages', 'yet-another-stars-rating'); ?></strong>
643
644
<div class="yasr-indented-answer" id="yasr-choose-snippet-type">
645
646
- <input type="radio" name="yasr_general_options[snippet_itemtype]" value="Product"
647
- class="yasr_choose_snippet" <?php if ($option['snippet_itemtype'] === 'Product') {
648
- echo " checked=\"checked\" ";
649
- } ?> >
650
- <?php _e('Product', 'yet-another-stars-rating') ?>
651
- <br/>
652
653
- <input type="radio" name="yasr_general_options[snippet_itemtype]" value="Place"
654
- class="yasr_choose_snippet" <?php if ($option['snippet_itemtype'] === 'Place') {
655
- echo " checked=\"checked\" ";
656
- } ?> >
657
- <?php _e('Place', 'yet-another-stars-rating') ?>
658
- <br/>
659
660
- <input type="radio" name="yasr_general_options[snippet_itemtype]" value="Recipe"
661
- class="yasr_choose_snippet" <?php if ($option['snippet_itemtype'] === 'Recipe') {
662
- echo " checked=\"checked\" ";
663
- } ?> >
664
- <?php _e('Recipe', 'yet-another-stars-rating') ?>
665
- <br/>
666
667
- <input type="radio" name="yasr_general_options[snippet_itemtype]" value="Other" class="yasr_choose_snippet"
668
- id="yasr_choose_snippet_blogposting" <?php if ($option['snippet_itemtype'] === 'Other') {
669
- echo " checked=\"checked\" ";
670
- } ?> >
671
- <?php _e('BlogPosting') ?>
672
- <br/>
673
674
675
<div class="yasr-help-box-settings" id="yasr-blogPosting-additional-info" style="display:block">
676
677
- <?php _e("If you need to use BlogPosting as item type, even for just one post or page, please fill these forms", "yet-another-stars-rating"); ?>
678
679
<br/> <br/>
680
@@ -702,6 +657,13 @@ function yasr_choose_snippet_callback($option) {
702
<?php _e(
703
'This will affect only the post/page where you didn\'t change manually the itemtype yet.',
704
'yet-another-stars-rating'); ?>
705
706
<p>&nbsp;</p>
707
297
?>
298
299
<?php
300
+ submit_button(YASR_SAVE_All_SETTINGS_TEXT);
301
?>
302
303
</div>
399
<p>&nbsp;</p>
400
401
<?php
402
+ submit_button(YASR_SAVE_All_SETTINGS_TEXT);
403
echo '<hr />';
404
405
}
451
<p>&nbsp;</p>
452
453
<?php
454
+ submit_button(YASR_SAVE_All_SETTINGS_TEXT);
455
?>
456
457
<br/>
578
<br/><p>&nbsp;</p>
579
580
<?php
581
+ submit_button(YASR_SAVE_All_SETTINGS_TEXT);
582
?>
583
584
<hr>
594
595
?>
596
597
<strong><?php _e('Select default item type for all post or pages', 'yet-another-stars-rating'); ?></strong>
598
599
<div class="yasr-indented-answer" id="yasr-choose-snippet-type">
600
601
+ <?php
602
603
+ foreach (YASR_SUPPORTED_SCHEMA_TYPES as $type) {
604
605
+ $type = trim($type);
606
+ $type_visualized = $type;
607
+ if($type === 'Place') {
608
+ $type_visualized = 'LocalBuisness';
609
+ }
610
+ if($type === 'Other') {
611
+ $type_visualized='BlogPosting';
612
+ }
613
614
+ ?>
615
+ <input type="radio" name="yasr_general_options[snippet_itemtype]" value="<?php echo $type ?>"
616
+ class="yasr_choose_snippet" <?php if ($option['snippet_itemtype'] === $type) {
617
+ echo " checked=\"checked\" ";
618
+ } ?> >
619
+ <?php
620
+ echo(
621
+ sprintf(
622
+ __('%s', 'yet-another-stars-rating'),
623
+ $type_visualized) .
624
+ '<br />'
625
+ );
626
+ }
627
628
+ ?>
629
630
<div class="yasr-help-box-settings" id="yasr-blogPosting-additional-info" style="display:block">
631
632
+ <?php _e("Add more info to your rich snippets filling these forms", "yet-another-stars-rating"); ?>
633
634
<br/> <br/>
635
657
<?php _e(
658
'This will affect only the post/page where you didn\'t change manually the itemtype yet.',
659
'yet-another-stars-rating'); ?>
660
+ <br />
661
+ <?php echo(sprintf(__('Please keep in mind that since since September, 16, 2019 blog posting item type will
662
+ no show stars in SERP anymore. %sHere%s the announcment by Google.',
663
+ 'yet-another-stars-rating'),
664
+ '<a href="https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html">',
665
+ '</a>'));
666
+ ?>
667
668
<p>&nbsp;</p>
669
lib/yasr-db-functions.php CHANGED
@@ -63,7 +63,6 @@ function yasr_on_activation_install($network_wide) {
63
$option['custom_text_user_voted'] = __('You must sign in to vote', 'yet-another-stars-rating');
64
$option['custom_text_must_sign_in'] = __('You have already voted for this article', 'yet-another-stars-rating');
65
$option['enable_ip'] = 'no';
66
- $option['snippet'] = 'overall_rating';
67
$option['snippet_itemtype'] = 'Product';
68
$option['blogposting_organization_name'] = get_bloginfo('name');
69
$option['blogposting_organization_logo'] = get_site_icon_url();
@@ -232,6 +231,7 @@ function yasr_get_overall_rating($post_id = false, $create_transient = true) {
232
/****** Return the snippet choosen for a post or page ******/
233
function yasr_get_snippet_type() {
234
235
$post_id = get_the_ID();
236
237
if (!$post_id) {
@@ -242,16 +242,14 @@ function yasr_get_snippet_type() {
242
if ($result) {
243
$snippet_type = trim($result);
244
245
- if ($snippet_type != 'Product' && $snippet_type != 'Place' && $snippet_type != 'Recipe' && $snippet_type != 'Other') {
246
$snippet_type = YASR_ITEMTYPE;
247
}
248
249
} else {
250
$snippet_type = YASR_ITEMTYPE;
251
}
252
-
253
return $snippet_type;
254
-
255
}
256
257
}
@@ -934,19 +932,18 @@ function yasr_insert_review_type_callback($post_id) {
934
935
$post_id = (int) $post_id;
936
937
- if ($reviewtype === "1") {
938
- $reviewtype = 'Product';
939
- } elseif ($reviewtype === "2") {
940
- $reviewtype = 'Place';
941
- } elseif ($reviewtype === "3") {
942
- $reviewtype = "Recipe";
943
- } elseif ($reviewtype === "4") {
944
- $reviewtype = 'Other';
945
- } else {
946
return;
947
}
948
949
- $review_type = update_post_meta($post_id, 'yasr_review_type', $reviewtype);
950
951
}
952
63
$option['custom_text_user_voted'] = __('You must sign in to vote', 'yet-another-stars-rating');
64
$option['custom_text_must_sign_in'] = __('You have already voted for this article', 'yet-another-stars-rating');
65
$option['enable_ip'] = 'no';
66
$option['snippet_itemtype'] = 'Product';
67
$option['blogposting_organization_name'] = get_bloginfo('name');
68
$option['blogposting_organization_logo'] = get_site_icon_url();
231
/****** Return the snippet choosen for a post or page ******/
232
function yasr_get_snippet_type() {
233
234
+ $review_types = YASR_SUPPORTED_SCHEMA_TYPES;
235
$post_id = get_the_ID();
236
237
if (!$post_id) {
242
if ($result) {
243
$snippet_type = trim($result);
244
245
+ if (!in_array($snippet_type, $review_types)) {
246
$snippet_type = YASR_ITEMTYPE;
247
}
248
249
} else {
250
$snippet_type = YASR_ITEMTYPE;
251
}
252
return $snippet_type;
253
}
254
255
}
932
933
$post_id = (int) $post_id;
934
935
+ if ($snippet_type != 'Product'
936
+ && $snippet_type != 'Place'
937
+ && $snippet_type != 'Recipe'
938
+ && $snippet_type != 'Book'
939
+ && $snippet_type != 'Movie'
940
+ && $snippet_type != 'Other') {
941
+ $review_type = update_post_meta($post_id, 'yasr_review_type', $reviewtype);
942
+ }
943
+ else {
944
return;
945
}
946
947
948
}
949
lib/yasr-functions.php CHANGED
@@ -360,7 +360,6 @@ if (YASR_AUTO_INSERT_ENABLED == 1) {
360
361
} //End if (YASR_AUTO_INSERT_ENABLED
362
363
-
364
/****** Add review schema data at the end of the post *******/
365
366
@@ -382,6 +381,20 @@ function yasr_add_schema($content) {
382
return $content;
383
}
384
385
$script_type = '<script type="application/ld+json">';
386
$end_script_type = '</script>';
387
@@ -429,26 +442,24 @@ function yasr_add_schema($content) {
429
$post_image_size = @getimagesize($post_image_url_absolute); //the @ should be useless, just to be safe
430
}
431
432
- $rich_snippet["author"] = array(
433
- "@type" => "Person",
434
- "name" => "$author"
435
- );
436
-
437
if ($review_choosen === "Product") {
438
$rich_snippet["@type"] = "Product";
439
}
440
- elseif ($review_choosen === "Recipe") {
441
- $rich_snippet["@type"] = "Recipe";
442
- $rich_snippet["image"] = array(
443
- "@type" => "ImageObject",
444
- "url" => $post_image_url,
445
- "width" => $post_image_size[0],
446
- "height" => $post_image_size[1]
447
- );
448
}
449
elseif ($review_choosen == "Place") {
450
$rich_snippet["@type"] = "LocalBusiness";
451
}
452
elseif ($review_choosen == "Other") {
453
$rich_snippet["@type"] = "BlogPosting";
454
$rich_snippet["datePublished"] = $date;
@@ -457,7 +468,10 @@ function yasr_add_schema($content) {
457
"@type" => "WebPage",
458
"@id" => get_permalink()
459
);
460
-
461
$rich_snippet["publisher"] = array(
462
"@type" => "Organization",
463
"name" => wp_strip_all_tags(YASR_BLOGPOSTING_ORGANIZATION_NAME), //already sanitized in the settings, just to be safe
@@ -466,7 +480,7 @@ function yasr_add_schema($content) {
466
"url" => $logo_image_url,
467
"width" => $logo_image_size[0],
468
"height" => $logo_image_size[1]
469
- )
470
);
471
472
$rich_snippet["dateModified"] = $date_modified;
@@ -480,76 +494,61 @@ function yasr_add_schema($content) {
480
481
}
482
483
- if (YASR_SNIPPET == 'overall_rating') {
484
-
485
- $overall_rating = yasr_get_overall_rating(false, false);
486
487
- if ($overall_rating && $overall_rating != '-1' && $overall_rating != '0.0') {
488
-
489
- global $post;
490
-
491
- //name
492
- $rich_snippet["name"] = $review_name;
493
-
494
- $rich_snippet["Review"] = array(
495
- "@type" => "Review",
496
- "name" => "$review_name",
497
- "author" => array(
498
- "@type" => "Person",
499
- "name" => "$author"
500
- ),
501
- "datePublished" => "$date",
502
- "reviewRating" => array(
503
- "@type" => "Rating",
504
- "ratingValue" => "$overall_rating",
505
- ),
506
- );
507
508
- } //END id if $overall_rating != '-1'
509
510
- else {
511
- return $content;
512
}
513
514
- } //end if ($choosen_snippet['snippet'] == 'overall_rating')
515
-
516
- if (YASR_SNIPPET == 'visitor_rating') {
517
-
518
- $visitor_votes = yasr_get_visitor_votes(false, false);
519
-
520
if ($visitor_votes) {
521
- foreach ($visitor_votes as $rating) {
522
- $visitor_rating['votes_number'] = $rating->number_of_votes;
523
- $visitor_rating['sum'] = $rating->sum_votes;
524
}
525
- } else {
526
- return $content;
527
- }
528
-
529
- if ($visitor_rating['sum'] != 0 && $visitor_rating['votes_number'] != 0) {
530
-
531
- $average_rating = $visitor_rating['sum'] / $visitor_rating['votes_number'];
532
- $average_rating = round($average_rating, 1);
533
-
534
- //name
535
- $rich_snippet["name"] = $review_name;
536
- $rich_snippet["aggregateRating"] = array(
537
- "@type" => "AggregateRating",
538
- "ratingValue" => "$average_rating",
539
- "ratingCount" => $visitor_rating['votes_number'],
540
- );
541
-
542
- } else {
543
- return $content;
544
}
545
546
}
547
548
- //if doesn't exists a filter for yasr_filter_existing_schema, false is assigned to $more_rich_snippet
549
- $more_rich_snippet = apply_filters('yasr_filter_existing_schema', false);
550
551
- if ($more_rich_snippet !== false) {
552
- $rich_snippet = array_merge($rich_snippet, $more_rich_snippet);
553
}
554
555
if (is_singular() && is_main_query() && !is_404()) {
@@ -561,52 +560,38 @@ function yasr_add_schema($content) {
561
562
} //End function
563
564
-
565
/****** Create a select menu to choose the rich snippet itemtype ******/
566
567
function yasr_select_itemtype() {
568
569
- $i18n_array_review = __('Product, Place, Recipe, BlogPosting', 'yet-another-stars-rating');
570
- $array_review_type = explode(',', $i18n_array_review);
571
- $review_type = array_map('trim', $array_review_type);
572
$review_type_choosen = yasr_get_snippet_type();
573
574
- switch ( $review_type_choosen ) {
575
- case 'Product':
576
- $review_type_choosen = 1;
577
- break;
578
- case 'Place':
579
- $review_type_choosen = 2;
580
- break;
581
- case 'Recipe':
582
- $review_type_choosen = 3;
583
- break;
584
- case 'Other':
585
- $review_type_choosen = 4;
586
- break;
587
- }
588
-
589
?>
590
591
<select name="yasr-review-type" id="yasr-choose-reviews-types-list">
592
593
<?php
594
595
- $i = 1;
596
597
- foreach ($review_type as $type) {
598
599
- if ($i === $review_type_choosen) {
600
- echo "<option value=\"$i\" selected>$type</option>";
601
} else {
602
- echo "<option value=\"$i\">$type</option>";
603
}
604
605
- $i = $i + 1;
606
-
607
}
608
609
-
610
?>
611
612
</select>
360
361
} //End if (YASR_AUTO_INSERT_ENABLED
362
363
/****** Add review schema data at the end of the post *******/
364
365
381
return $content;
382
}
383
384
+ $overall_rating = yasr_get_overall_rating(false, false);
385
+ $visitor_votes = yasr_get_visitor_votes(false, false);
386
+
387
+ $visitor_rating = false; //avoid undefine
388
+
389
+ foreach ($visitor_votes as $rating) {
390
+ $visitor_rating['votes_number'] = $rating->number_of_votes;
391
+ $visitor_rating['sum'] = $rating->sum_votes;
392
+ }
393
+
394
+ if (!$overall_rating && !$visitor_rating['votes_number'] && !$visitor_rating['sum']) {
395
+ return $content;
396
+ }
397
+
398
$script_type = '<script type="application/ld+json">';
399
$end_script_type = '</script>';
400
442
$post_image_size = @getimagesize($post_image_url_absolute); //the @ should be useless, just to be safe
443
}
444
445
if ($review_choosen === "Product") {
446
$rich_snippet["@type"] = "Product";
447
}
448
+ elseif($review_choosen === 'Book') {
449
+ $rich_snippet["@type"] = "Book";
450
+ }
451
+ elseif($review_choosen === 'Movie') {
452
+ $rich_snippet["@type"] = "Movie";
453
+ }
454
+ elseif($review_choosen === 'Game') {
455
+ $rich_snippet["@type"] = "Game";
456
}
457
elseif ($review_choosen == "Place") {
458
$rich_snippet["@type"] = "LocalBusiness";
459
}
460
+ elseif ($review_choosen === "Recipe") {
461
+ $rich_snippet["@type"] = "Recipe";
462
+ }
463
elseif ($review_choosen == "Other") {
464
$rich_snippet["@type"] = "BlogPosting";
465
$rich_snippet["datePublished"] = $date;
468
"@type" => "WebPage",
469
"@id" => get_permalink()
470
);
471
+ $rich_snippet["author"] = array(
472
+ "@type" => "Person",
473
+ "name" => "$author"
474
+ );
475
$rich_snippet["publisher"] = array(
476
"@type" => "Organization",
477
"name" => wp_strip_all_tags(YASR_BLOGPOSTING_ORGANIZATION_NAME), //already sanitized in the settings, just to be safe
480
"url" => $logo_image_url,
481
"width" => $logo_image_size[0],
482
"height" => $logo_image_size[1]
483
+ ),
484
);
485
486
$rich_snippet["dateModified"] = $date_modified;
494
495
}
496
497
498
+ $rich_snippet["name"] = $review_name;
499
+ $rich_snippet["image"] = array(
500
+ "@type" => "ImageObject",
501
+ "url" => $post_image_url,
502
+ "width" => $post_image_size[0],
503
+ "height" => $post_image_size[1]
504
+ );
505
506
+ //Do not add rating if blogposting
507
+ if ($review_choosen !== 'Other') {
508
+
509
+ //Add Critic review only if is these types:
510
+ //More info here https://developers.google.com/search/docs/data-types/critic-review
511
+ if ($review_choosen === 'Book' || $review_choosen === 'Movie' || $review_choosen === 'Place') {
512
+
513
+ if ($overall_rating && $overall_rating != '-1' && $overall_rating != '0.0') {
514
+ $rich_snippet["Review"] = array(
515
+ "@type" => "Review",
516
+ "name" => "$review_name",
517
+ "author" => array(
518
+ "@type" => "Person",
519
+ "name" => "$author"
520
+ ),
521
+ "datePublished" => "$date",
522
+ "dateModified" => $date_modified,
523
+ "reviewRating" => array(
524
+ "@type" => "Rating",
525
+ "ratingValue" => "$overall_rating",
526
+ ),
527
+ );
528
+ }
529
530
}
531
532
if ($visitor_votes) {
533
+ if ($visitor_rating['sum'] != 0 && $visitor_rating['votes_number'] != 0) {
534
+ $average_rating = $visitor_rating['sum'] / $visitor_rating['votes_number'];
535
+ $average_rating = round($average_rating, 1);
536
+
537
+ $rich_snippet["aggregateRating"] = array(
538
+ "@type" => "AggregateRating",
539
+ "ratingValue" => "$average_rating",
540
+ "ratingCount" => $visitor_rating['votes_number'],
541
+ );
542
}
543
}
544
545
}
546
547
+ //if doesn't exists a filter for yasr_filter_existing_schema, $rich_snippet to $more_rich_snippet
548
+ $more_rich_snippet = apply_filters('yasr_filter_existing_schema', $rich_snippet);
549
550
+ if ($more_rich_snippet !== $rich_snippet && is_array($more_rich_snippet)) {
551
+ $rich_snippet = $more_rich_snippet;
552
}
553
554
if (is_singular() && is_main_query() && !is_404()) {
560
561
} //End function
562
563
/****** Create a select menu to choose the rich snippet itemtype ******/
564
565
function yasr_select_itemtype() {
566
567
+ $review_types = YASR_SUPPORTED_SCHEMA_TYPES;
568
$review_type_choosen = yasr_get_snippet_type();
569
570
?>
571
572
<select name="yasr-review-type" id="yasr-choose-reviews-types-list">
573
574
<?php
575
576
+ foreach ($review_types as $type) {
577
578
+ $type = trim($type);
579
+ $type_option = $type;
580
+ if($type === 'Place') {
581
+ $type_option='LocalBusiness';
582
+ }
583
+ if($type === 'Other') {
584
+ $type_option='BlogPosting';
585
+ }
586
587
+ if ($type === $review_type_choosen) {
588
+ echo "<option value=\"$type\" selected>$type_option</option>";
589
} else {
590
+ echo "<option value=\"$type\">$type_option</option>";
591
}
592
593
}
594
595
?>
596
597
</select>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.3.0
5
Contributors: Dudo
6
Tested up to: 5.2.3
7
Requires PHP: 5.3
8
- Stable tag: 2.0.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!
@@ -54,14 +54,6 @@ In this video I'll show you the "Auto Insert" feature and manual placement of YA
54
* [Demo page for Multi Sets](https://yetanotherstarsrating.com/yasr-multi-sets/)
55
* [Demo page for Rankings](https://yetanotherstarsrating.com/yasr-rankings/)
56
57
- = Press =
58
- * [TIDYREPO](https://tidyrepo.com/yasr-yet-another-stars-rating/)
59
- * [WPMUDEV](http://premium.wpmudev.org/blog/free-wordpress-ratings-testimonials-subscriber-count-plugins/)
60
- * [BRIANLI.COM](http://brianli.com/yet-another-stars-rating-wordpress-plugin-review/)
61
- * [WPEXPLORER](http://www.wpexplorer.com/google-rich-snippets-wordpress/)
62
- * [SOURCEWP](http://www.sourcewp.com/best-post-voting-plugins-wordpress/)
63
- * [HOWSHOST](https://howshost.com/add-post-rating-system-in-wordpress/)
64
-
65
Do you want more feature? [Check out Yasr Pro!](https://yetanotherstarsrating.com/#yasr-pro)
66
67
== Installation ==
@@ -133,6 +125,12 @@ If doesn't, it's suggested to ask in a SEO oriented forum.
133
134
The full changelog can be found in the plugin's directory. Recent entries:
135
136
= 2.0.5 =
137
* FIXED: Warning: array_merge(): on line 552 in yasr-functions.php
138
5
Contributors: Dudo
6
Tested up to: 5.2.3
7
Requires PHP: 5.3
8
+ Stable tag: 2.0.6
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!
54
* [Demo page for Multi Sets](https://yetanotherstarsrating.com/yasr-multi-sets/)
55
* [Demo page for Rankings](https://yetanotherstarsrating.com/yasr-rankings/)
56
57
Do you want more feature? [Check out Yasr Pro!](https://yetanotherstarsrating.com/#yasr-pro)
58
59
== Installation ==
125
126
The full changelog can be found in the plugin's directory. Recent entries:
127
128
+ = 2.0.6 =
129
+ * NEW FEATURE: in Gutenberg, is now possible to rate "overall Rating" in both blocks and sidebar
130
+ * IMPORTANT CHANGES ON RICH SNIPPETS: due to [this google announcement] (https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html)
131
+ BlogPosting data type doesn't have ratings anymore. These types have been added: Book, Movie, Game.
132
+ Many other support types will comes.
133
+
134
= 2.0.5 =
135
* FIXED: Warning: array_merge(): on line 552 in yasr-functions.php
136
yasr-settings-page.php CHANGED
@@ -53,7 +53,7 @@ $n_multi_set = null; //Evoid undefined variable when printed outside multiset ta
53
<?php
54
settings_fields('yasr_general_options_group');
55
do_settings_sections('yasr_general_settings_tab');
56
- submit_button(SAVE_All_SETTINGS_TEXT);
57
?>
58
</form>
59
</div>
@@ -85,7 +85,7 @@ $n_multi_set = null; //Evoid undefined variable when printed outside multiset ta
85
<?php
86
settings_fields('yasr_style_options_group');
87
do_settings_sections('yasr_style_tab');
88
- submit_button(SAVE_All_SETTINGS_TEXT);
89
?>
90
</form>
91
</div>
53
<?php
54
settings_fields('yasr_general_options_group');
55
do_settings_sections('yasr_general_settings_tab');
56
+ submit_button(YASR_SAVE_All_SETTINGS_TEXT);
57
?>
58
</form>
59
</div>
85
<?php
86
settings_fields('yasr_style_options_group');
87
do_settings_sections('yasr_style_tab');
88
+ submit_button(YASR_SAVE_All_SETTINGS_TEXT);
89
?>
90
</form>
91
</div>
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: 2.0.5
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.0.5' );
80
//Plugin relative path
81
define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
82
//Plugin RELATIVE PATH without slashes (just the directory's name)
@@ -127,7 +127,6 @@ if ( !function_exists( 'yasr_fs' ) ) {
127
define( "YASR_VISITORS_STATS", $yasr_stored_options['visitors_stats'] );
128
define( "YASR_ALLOWED_USER", $yasr_stored_options['allowed_user'] );
129
define( "YASR_ENABLE_IP", $yasr_stored_options['enable_ip'] );
130
- define( "YASR_SNIPPET", $yasr_stored_options['snippet'] );
131
define( "YASR_ITEMTYPE", $yasr_stored_options['snippet_itemtype'] );
132
133
if ( isset( $yasr_stored_options['blogposting_organization_name'] ) ) {
@@ -209,7 +208,17 @@ if ( !function_exists( 'yasr_fs' ) ) {
209
define( "YASR_LOADER_IMAGE", YASR_IMG_DIR . "/loader.gif" );
210
//Text for button in settings pages
211
$save_settings_text = __( 'Save All Settings', 'yet-another-stars-rating' );
212
- define( "SAVE_All_SETTINGS_TEXT", $save_settings_text );
213
$yasr_version_installed = get_option( 'yasr-version' );
214
global $yasr_version_installed ;
215
$yasr_plugin_imported = get_option( 'yasr_plugin_imported' );
@@ -244,27 +253,59 @@ if ( !function_exists( 'yasr_fs' ) ) {
244
global $wpdb ;
245
global $yasr_version_installed ;
246
global $yasr_stored_options ;
247
248
- if ( $yasr_version_installed && $yasr_version_installed < '2.0.4' ) {
249
- $yasr_stored_options['auto_insert_align'] = 'left';
250
- update_option( 'yasr_general_options', $yasr_stored_options );
251
}
252
253
- if ( $yasr_version_installed && $yasr_version_installed < '1.7.3' ) {
254
- $wpdb->query( "ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " CHANGE field_name field_name varchar(40) \n COLLATE 'utf8_unicode_ci' NOT NULL \n AFTER parent_set_id;\n " );
255
- }
256
257
- if ( $yasr_version_installed && $yasr_version_installed < '1.6.5' ) {
258
- $yasr_stored_options['disable_jquery'] = 'no';
259
- update_option( 'yasr_general_options', $yasr_stored_options );
260
}
261
262
263
- if ( $yasr_version_installed && $yasr_version_installed < '1.6.1' ) {
264
- $yasr_stored_options['enable_ip'] = 'no';
265
update_option( 'yasr_general_options', $yasr_stored_options );
266
}
267
268
/****** End backward compatibility functions ******/
269
if ( $yasr_version_installed != YASR_VERSION_NUM ) {
270
update_option( 'yasr-version', YASR_VERSION_NUM );
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: 2.0.6
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.0.6' );
80
//Plugin relative path
81
define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
82
//Plugin RELATIVE PATH without slashes (just the directory's name)
127
define( "YASR_VISITORS_STATS", $yasr_stored_options['visitors_stats'] );
128
define( "YASR_ALLOWED_USER", $yasr_stored_options['allowed_user'] );
129
define( "YASR_ENABLE_IP", $yasr_stored_options['enable_ip'] );
130
define( "YASR_ITEMTYPE", $yasr_stored_options['snippet_itemtype'] );
131
132
if ( isset( $yasr_stored_options['blogposting_organization_name'] ) ) {
208
define( "YASR_LOADER_IMAGE", YASR_IMG_DIR . "/loader.gif" );
209
//Text for button in settings pages
210
$save_settings_text = __( 'Save All Settings', 'yet-another-stars-rating' );
211
+ define( "YASR_SAVE_All_SETTINGS_TEXT", $save_settings_text );
212
+ $supported_schema_types = array(
213
+ 'Product',
214
+ 'Book',
215
+ 'Movie',
216
+ 'Game',
217
+ 'Place',
218
+ 'Recipe',
219
+ 'Other'
220
+ );
221
+ define( "YASR_SUPPORTED_SCHEMA_TYPES", $supported_schema_types );
222
$yasr_version_installed = get_option( 'yasr-version' );
223
global $yasr_version_installed ;
224
$yasr_plugin_imported = get_option( 'yasr_plugin_imported' );
253
global $wpdb ;
254
global $yasr_version_installed ;
255
global $yasr_stored_options ;
256
+ //announce for version 2.0.6, remove end 2020
257
+ $yasr_206_dismissed = false;
258
259
+ if ( isset( $_GET['yasr-206-dismissed'] ) ) {
260
+ $yasr_206_dismissed = true;
261
+ set_transient( 'yasr_206_announce', 'yes', 2 * YEAR_IN_SECONDS );
262
}
263
264
265
+ if ( $yasr_version_installed && $yasr_206_dismissed === false ) {
266
+ $yasr_206_dismissed_transient = get_transient( 'yasr_206_announce' );
267
+
268
+ if ( $yasr_206_dismissed_transient !== 'yes' ) {
269
+ add_action( 'admin_notices', 'yasr_announce_206' );
270
+ function yasr_announce_206()
271
+ {
272
+ $settings_url = admin_url( 'options-general.php?page=yasr_settings_page' );
273
+ echo '<div class="notice notice-success is-dismissible">
274
+ <p>' . sprintf(
275
+ __( '%sYASR 2.0.6 UPDATE:%s
276
+ %s
277
+ Google has implemented a new algorithm that doesn\'t show anymore stars in SERP
278
+ for generic post type such BlogPosting, CreativeWork and Article: %s the announcement.
279
+ %s
280
+ BlogPosting is still supported by YASR, but will not show any ratings.
281
+ Take a look at all new item types in the %s! Support for more types is coming soon.
282
+ %s
283
+ %s', 'yet-another-stars-rating' ),
284
+ '<h4>',
285
+ '</h4>',
286
+ '<br />',
287
+ '<a href="https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html">here</a>',
288
+ '<br />',
289
+ "<a href=\"{$settings_url}\">settings page</a>",
290
+ '<br /><br />',
291
+ '<a href="?yasr-206-dismissed">Dismiss</a>'
292
+ ) . '</p>
293
+ </div>' ;
294
+ }
295
+
296
+ }
297
+
298
}
299
300
301
+ if ( $yasr_version_installed && $yasr_version_installed < '2.0.4' ) {
302
+ $yasr_stored_options['auto_insert_align'] = 'left';
303
update_option( 'yasr_general_options', $yasr_stored_options );
304
}
305
306
+ if ( $yasr_version_installed && $yasr_version_installed < '1.7.3' ) {
307
+ $wpdb->query( "ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " CHANGE field_name field_name varchar(40) \n COLLATE 'utf8_unicode_ci' NOT NULL \n AFTER parent_set_id;\n " );
308
+ }
309
/****** End backward compatibility functions ******/
310
if ( $yasr_version_installed != YASR_VERSION_NUM ) {
311
update_option( 'yasr-version', YASR_VERSION_NUM );