Yasr – Yet Another Stars Rating - Version 2.2.3

Version Description

  • NEW FEATURE: Added support for the following structured datas:
  • Course
  • CreativeWorkSeason,
  • CreativeWorkSeries,
  • Episode,
  • Event
  • MediaObject,
  • Movie,
  • MusicPlaylist,
  • MusicRecording.

  • TWEAKED: Removed transient: since version 2.2.0 are useless.

Download this release

Release Info

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

Code changes from version 2.2.2 to 2.2.3

css/yasr-admin.css CHANGED
@@ -65,16 +65,6 @@
65
line-height: 0.5em;
66
}
67
68
- #yasr-switcher-disable-auto-insert {
69
- margin: 0 auto;
70
- text-align: left;
71
- }
72
-
73
- #yasr-switcher-post-is-review {
74
- margin: 0 auto;
75
- text-align: left;
76
- }
77
-
78
.rich-snippet-title {
79
font-weight: bold;
80
margin-bottom: 5px;
@@ -148,6 +138,11 @@
148
-ms-user-select: none;
149
}
150
151
.yasr-onoffswitch-checkbox {
152
display: none !important;
153
}
65
line-height: 0.5em;
66
}
67
68
.rich-snippet-title {
69
font-weight: bold;
70
margin-bottom: 5px;
138
-ms-user-select: none;
139
}
140
141
+ .yasr-onoffswitch-big-center{
142
+ margin: 0 auto;
143
+ text-align: left;
144
+ }
145
+
146
.yasr-onoffswitch-checkbox {
147
display: none !important;
148
}
js/src/yasr-guten-panel.js CHANGED
@@ -6,14 +6,11 @@ const {BlockControls,InspectorControls} = wp.editor;
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');
8
const yasrPostExcluded = __('Is this a review?', 'yet-another-stars-rating');
9
- const yasrSelectSnippetTitle = __('This review is about a... ', 'yet-another-stars-rating');
10
- const yasrSetItemTypeProduct = __('Product', 'yet-another-stars-rating');
11
- const yasrSetItemTypeBook = __('Book', 'yet-another-stars-rating');
12
- const yasrSetItemTypeMovie = __('Movie', 'yet-another-stars-rating');
13
- const yasrSetItemTypeGame = __('Game', 'yet-another-stars-rating');
14
- const yasrSetItemTypePlace = __('LocalBusiness', 'yet-another-stars-rating');
15
- const yasrSetItemTypeRecipe = __('Recipe', 'yet-another-stars-rating');
16
- const yasrSetItemBlogPosting = __('BlogPosting', 'yet-another-stars-rating');
17
18
19
class YasrDivRatingOverall extends React.Component {
@@ -96,7 +93,6 @@ class YasrSideBarAutoInsert extends React.Component {
96
}
97
98
yasrUpdatePostMetaAutoInsert(event) {
99
-
100
const target = event.target;
101
const postExcluded = target.type === 'checkbox' ? target.checked : target.value;
102
@@ -111,14 +107,13 @@ class YasrSideBarAutoInsert extends React.Component {
111
{ meta: { yasr_auto_insert_disabled: 'no' } }
112
);
113
}
114
-
115
}
116
117
render () {
118
return (
119
<div className="yasr-guten-block-panel-center">
120
<label><span>{yasrDisableAutoInsert}</span></label>
121
- <div className="yasr-onoffswitch-big" id="yasr-switcher-disable-auto-insert">
122
<input type="checkbox"
123
name="yasr_auto_insert_disabled"
124
className="yasr-onoffswitch-checkbox"
@@ -180,7 +175,7 @@ class YasrDivIsReview extends React.Component {
180
<div className="yasr-guten-block-panel-center">
181
<div className="rich-snippet-title">{yasrRichSnippetOptions}</div>
182
<label><span>{yasrPostExcluded}</span></label>
183
- <div className="yasr-onoffswitch-big" id="yasr-switcher-post-is-review">
184
<input type="checkbox"
185
name="yasr_post_is_review"
186
className="yasr-onoffswitch-checkbox"
@@ -201,27 +196,24 @@ class YasrDivIsReview extends React.Component {
201
202
}
203
204
-
205
class YasrSideBarSelectSnippets extends React.Component {
206
207
constructor(props) {
208
super(props);
209
210
//at the begin, get the default type
211
let snippetType = yasrConstantGutenberg.defaultItemType;
212
213
- //postmeta itemtype
214
let postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
215
216
- //if post meta value is one of this overwrite snippetType
217
- if (postMetaItemType === 'Product'
218
- || postMetaItemType === 'Book'
219
- || postMetaItemType === 'Movie'
220
- || postMetaItemType === 'Game'
221
- || postMetaItemType === 'Place'
222
- || postMetaItemType === 'Recipe'
223
- || postMetaItemType === 'Other'
224
- ) {
225
snippetType = postMetaItemType;
226
}
227
@@ -242,17 +234,11 @@ class YasrSideBarSelectSnippets extends React.Component {
242
return (
243
<div className="yasr-guten-block-panel-center">
244
<label><span>{yasrSelectSnippetTitle}</span></label>
245
- <form>
246
- <select value={this.state.snippet} onChange={this.yasrSetItemType}>
247
- <option value="Product">{yasrSetItemTypeProduct}</option>
248
- <option value="Book">{yasrSetItemTypeBook}</option>
249
- <option value="Movie">{yasrSetItemTypeMovie}</option>
250
- <option value="Game">{yasrSetItemTypeGame}</option>
251
- <option value="Place">{yasrSetItemTypePlace}</option>
252
- <option value="Recipe">{yasrSetItemTypeRecipe}</option>
253
- <option value="Other">{yasrSetItemBlogPosting}</option>
254
- </select>
255
- </form>
256
</div>
257
);
258
}
@@ -287,6 +273,7 @@ class yasrSidebar extends React.Component {
287
{this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert/>}
288
<YasrDivIsReview />
289
<YasrSideBarSelectSnippets/>
290
</div>
291
</PanelBody>
292
</PluginSidebar>
@@ -296,6 +283,7 @@ class yasrSidebar extends React.Component {
296
}
297
298
299
//Custom sidebar
300
registerPlugin( 'yasr-sidebar', {
301
icon: 'star-half',
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');
8
const yasrPostExcluded = __('Is this a review?', 'yet-another-stars-rating');
9
+ const yasrSelectSnippetTitle = __('Select ItemType ', 'yet-another-stars-rating');
10
+
11
+ const ContentBelowSidebar = () => {
12
+ return <div></div>;
13
+ };
14
15
16
class YasrDivRatingOverall extends React.Component {
93
}
94
95
yasrUpdatePostMetaAutoInsert(event) {
96
const target = event.target;
97
const postExcluded = target.type === 'checkbox' ? target.checked : target.value;
98
107
{ meta: { yasr_auto_insert_disabled: 'no' } }
108
);
109
}
110
}
111
112
render () {
113
return (
114
<div className="yasr-guten-block-panel-center">
115
<label><span>{yasrDisableAutoInsert}</span></label>
116
+ <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
117
<input type="checkbox"
118
name="yasr_auto_insert_disabled"
119
className="yasr-onoffswitch-checkbox"
175
<div className="yasr-guten-block-panel-center">
176
<div className="rich-snippet-title">{yasrRichSnippetOptions}</div>
177
<label><span>{yasrPostExcluded}</span></label>
178
+ <div className="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-post-is-review">
179
<input type="checkbox"
180
name="yasr_post_is_review"
181
className="yasr-onoffswitch-checkbox"
196
197
}
198
199
class YasrSideBarSelectSnippets extends React.Component {
200
201
+ supportedItemtype;
202
+
203
constructor(props) {
204
super(props);
205
206
//at the begin, get the default type
207
let snippetType = yasrConstantGutenberg.defaultItemType;
208
209
+ //get array with all supported itemtypes
210
+ this.supportedItemtype = wp.data.select('core/editor').getCurrentPost().yasr_all_itemtypes;
211
+
212
+ //get postmeta itemtype
213
let postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
214
215
+ //if the postmeta is in the array of all item, set in the select the postmeta_itemtype
216
+ if(this.supportedItemtype.includes(postMetaItemType)) {
217
snippetType = postMetaItemType;
218
}
219
234
return (
235
<div className="yasr-guten-block-panel-center">
236
<label><span>{yasrSelectSnippetTitle}</span></label>
237
+ <select value={this.state.snippet} onChange={this.yasrSetItemType}>
238
+ {this.supportedItemtype.map((snippet) => {
239
+ return <option value={snippet}>{snippet}</option>;
240
+ })}
241
+ </select>
242
</div>
243
);
244
}
273
{this.state.yasrAutoInsertEnabled && <YasrSideBarAutoInsert/>}
274
<YasrDivIsReview />
275
<YasrSideBarSelectSnippets/>
276
+ {wp.hooks.applyFilters( 'yasr_add_content_bottom_sidebar', <ContentBelowSidebar /> )}
277
</div>
278
</PanelBody>
279
</PluginSidebar>
283
}
284
285
286
+
287
//Custom sidebar
288
registerPlugin( 'yasr-sidebar', {
289
icon: 'star-half',
js/yasr-guten-panel.js CHANGED
@@ -22,14 +22,11 @@ var _wp$editor = wp.editor,
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 = __('This review is about a... ', 'yet-another-stars-rating');
26
- var yasrSetItemTypeProduct = __('Product', 'yet-another-stars-rating');
27
- var yasrSetItemTypeBook = __('Book', 'yet-another-stars-rating');
28
- var yasrSetItemTypeMovie = __('Movie', 'yet-another-stars-rating');
29
- var yasrSetItemTypeGame = __('Game', 'yet-another-stars-rating');
30
- var yasrSetItemTypePlace = __('LocalBusiness', 'yet-another-stars-rating');
31
- var yasrSetItemTypeRecipe = __('Recipe', 'yet-another-stars-rating');
32
- var yasrSetItemBlogPosting = __('BlogPosting', 'yet-another-stars-rating');
33
34
var YasrDivRatingOverall = function (_React$Component) {
35
_inherits(YasrDivRatingOverall, _React$Component);
@@ -127,7 +124,6 @@ var YasrSideBarAutoInsert = function (_React$Component2) {
127
_createClass(YasrSideBarAutoInsert, [{
128
key: 'yasrUpdatePostMetaAutoInsert',
129
value: function yasrUpdatePostMetaAutoInsert(event) {
130
-
131
var target = event.target;
132
var postExcluded = target.type === 'checkbox' ? target.checked : target.value;
133
@@ -156,7 +152,7 @@ var YasrSideBarAutoInsert = function (_React$Component2) {
156
),
157
React.createElement(
158
'div',
159
- { className: 'yasr-onoffswitch-big', id: 'yasr-switcher-disable-auto-insert' },
160
React.createElement('input', { type: 'checkbox',
161
name: 'yasr_auto_insert_disabled',
162
className: 'yasr-onoffswitch-checkbox',
@@ -238,7 +234,7 @@ var YasrDivIsReview = function (_React$Component3) {
238
),
239
React.createElement(
240
'div',
241
- { className: 'yasr-onoffswitch-big', id: 'yasr-switcher-post-is-review' },
242
React.createElement('input', { type: 'checkbox',
243
name: 'yasr_post_is_review',
244
className: 'yasr-onoffswitch-checkbox',
@@ -273,11 +269,14 @@ var YasrSideBarSelectSnippets = function (_React$Component4) {
273
274
var snippetType = yasrConstantGutenberg.defaultItemType;
275
276
- //postmeta itemtype
277
var postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
278
279
- //if post meta value is one of this overwrite snippetType
280
- if (postMetaItemType === 'Product' || postMetaItemType === 'Book' || postMetaItemType === 'Movie' || postMetaItemType === 'Game' || postMetaItemType === 'Place' || postMetaItemType === 'Recipe' || postMetaItemType === 'Other') {
281
snippetType = postMetaItemType;
282
}
283
@@ -310,47 +309,15 @@ var YasrSideBarSelectSnippets = function (_React$Component4) {
310
)
311
),
312
React.createElement(
313
- 'form',
314
- null,
315
- React.createElement(
316
- 'select',
317
- { value: this.state.snippet, onChange: this.yasrSetItemType },
318
- React.createElement(
319
- 'option',
320
- { value: 'Product' },
321
- yasrSetItemTypeProduct
322
- ),
323
- React.createElement(
324
- 'option',
325
- { value: 'Book' },
326
- yasrSetItemTypeBook
327
- ),
328
- React.createElement(
329
'option',
330
- { value: 'Movie' },
331
- yasrSetItemTypeMovie
332
- ),
333
- React.createElement(
334
- 'option',
335
- { value: 'Game' },
336
- yasrSetItemTypeGame
337
- ),
338
- React.createElement(
339
- 'option',
340
- { value: 'Place' },
341
- yasrSetItemTypePlace
342
- ),
343
- React.createElement(
344
- 'option',
345
- { value: 'Recipe' },
346
- yasrSetItemTypeRecipe
347
- ),
348
- React.createElement(
349
- 'option',
350
- { value: 'Other' },
351
- yasrSetItemBlogPosting
352
- )
353
- )
354
)
355
);
356
}
@@ -402,7 +369,8 @@ var yasrSidebar = function (_React$Component5) {
402
React.createElement(YasrDivRatingOverall, null),
403
this.state.yasrAutoInsertEnabled && React.createElement(YasrSideBarAutoInsert, null),
404
React.createElement(YasrDivIsReview, null),
405
- React.createElement(YasrSideBarSelectSnippets, null)
406
)
407
)
408
)
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);
124
_createClass(YasrSideBarAutoInsert, [{
125
key: 'yasrUpdatePostMetaAutoInsert',
126
value: function yasrUpdatePostMetaAutoInsert(event) {
127
var target = event.target;
128
var postExcluded = target.type === 'checkbox' ? target.checked : target.value;
129
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',
234
),
235
React.createElement(
236
'div',
237
+ { className: 'yasr-onoffswitch-big yasr-onoffswitch-big-center', id: 'yasr-switcher-post-is-review' },
238
React.createElement('input', { type: 'checkbox',
239
name: 'yasr_post_is_review',
240
className: 'yasr-onoffswitch-checkbox',
269
270
var snippetType = yasrConstantGutenberg.defaultItemType;
271
272
+ //get array with all supported itemtypes
273
+ _this4.supportedItemtype = wp.data.select('core/editor').getCurrentPost().yasr_all_itemtypes;
274
+
275
+ //get postmeta itemtype
276
var postMetaItemType = wp.data.select('core/editor').getCurrentPost().meta.yasr_review_type;
277
278
+ //if the postmeta is in the array of all item, set in the select the postmeta_itemtype
279
+ if (_this4.supportedItemtype.includes(postMetaItemType)) {
280
snippetType = postMetaItemType;
281
}
282
309
)
310
),
311
React.createElement(
312
+ 'select',
313
+ { value: this.state.snippet, onChange: this.yasrSetItemType },
314
+ this.supportedItemtype.map(function (snippet) {
315
+ return React.createElement(
316
'option',
317
+ { value: snippet },
318
+ snippet
319
+ );
320
+ })
321
)
322
);
323
}
369
React.createElement(YasrDivRatingOverall, null),
370
this.state.yasrAutoInsertEnabled && React.createElement(YasrSideBarAutoInsert, null),
371
React.createElement(YasrDivIsReview, null),
372
+ React.createElement(YasrSideBarSelectSnippets, null),
373
+ wp.hooks.applyFilters('yasr_add_content_bottom_sidebar', React.createElement(ContentBelowSidebar, null))
374
)
375
)
376
)
lib/admin/editor/yasr-editor-functions.php CHANGED
@@ -36,7 +36,7 @@ function yasr_gutenberg_scripts() {
36
'wp-blocks',
37
'wp-components',
38
'wp-element',
39
- 'wp-editor'
40
)
41
);
42
@@ -84,8 +84,8 @@ function yasr_add_js_constant_gutenberg($hook) {
84
'yasradmin',
85
'yasrConstantGutenberg',
86
array(
87
- 'autoInsert' => $auto_insert,
88
- 'defaultItemType' => YASR_ITEMTYPE
89
)
90
);
91
36
'wp-blocks',
37
'wp-components',
38
'wp-element',
39
+ 'wp-editor',
40
)
41
);
42
84
'yasradmin',
85
'yasrConstantGutenberg',
86
array(
87
+ 'autoInsert' => $auto_insert,
88
+ 'defaultItemType' => YASR_ITEMTYPE,
89
)
90
);
91
lib/admin/editor/yasr-metabox-top-right.php CHANGED
@@ -80,7 +80,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
80
81
<br />
82
83
- <div class="yasr-onoffswitch-big" id="yasr-switcher-disable-auto-insert">
84
<input type="checkbox" name="yasr_auto_insert_disabled" class="yasr-onoffswitch-checkbox" value="yes"
85
id="yasr-auto-insert-disabled-switch" <?php if ($is_this_post_exluded === 'yes') echo " checked='checked' "; ?> >
86
<label class="yasr-onoffswitch-label" for="yasr-auto-insert-disabled-switch">
@@ -109,7 +109,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
109
110
<br />
111
112
- <div class="yasr-onoffswitch-big" id="yasr-switcher-post-is-review">
113
<input type="checkbox" name="yasr_is_post_review" class="yasr-onoffswitch-checkbox" value="yes"
114
id="yasr-post-is-review-switch" <?php if ($post_a_review === 'yes') echo " checked='checked' "; ?> >
115
<label class="yasr-onoffswitch-label" for="yasr-post-is-review-switch">
80
81
<br />
82
83
+ <div class="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-disable-auto-insert">
84
<input type="checkbox" name="yasr_auto_insert_disabled" class="yasr-onoffswitch-checkbox" value="yes"
85
id="yasr-auto-insert-disabled-switch" <?php if ($is_this_post_exluded === 'yes') echo " checked='checked' "; ?> >
86
<label class="yasr-onoffswitch-label" for="yasr-auto-insert-disabled-switch">
109
110
<br />
111
112
+ <div class="yasr-onoffswitch-big yasr-onoffswitch-big-center" id="yasr-switcher-post-is-review">
113
<input type="checkbox" name="yasr_is_post_review" class="yasr-onoffswitch-checkbox" value="yes"
114
id="yasr-post-is-review-switch" <?php if ($post_a_review === 'yes') echo " checked='checked' "; ?> >
115
<label class="yasr-onoffswitch-label" for="yasr-post-is-review-switch">
lib/admin/settings/yasr-settings-functions-multiset-page.php CHANGED
@@ -49,15 +49,6 @@ if ($error_edit_multi_set) {
49
50
global $wpdb;
51
52
- //delete all transient that use multiset
53
- $sql_delete_transient = "
54
- DELETE FROM {$wpdb->options}
55
- WHERE option_name LIKE '_transient_yasr_visitor_multi_set_%'
56
- OR option_name LIKE '_transient_timeout_yasr_visitor_multi_set_%'
57
- ";
58
-
59
- $wpdb->query($sql_delete_transient);
60
-
61
$multi_set = YasrMultiSetData::returnMultiSetNames();
62
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
63
49
50
global $wpdb;
51
52
$multi_set = YasrMultiSetData::returnMultiSetNames();
53
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
54
lib/admin/settings/yasr-settings-functions.php CHANGED
@@ -597,37 +597,32 @@ function yasr_choose_snippet_callback($option) {
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
- $supported_schema_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
604
-
605
- foreach ($supported_schema_types as $type) {
606
-
607
- $type = trim($type);
608
- $type_visualized = $type;
609
- if($type === 'Place') {
610
- $type_visualized = 'LocalBuisness';
611
- }
612
- if($type === 'Other') {
613
- $type_visualized='BlogPosting';
614
- }
615
-
616
- ?>
617
- <input type="radio" name="yasr_general_options[snippet_itemtype]" value="<?php echo $type ?>"
618
- class="yasr_choose_snippet" <?php if ($option['snippet_itemtype'] === $type) {
619
- echo " checked=\"checked\" ";
620
- } ?> >
621
- <?php
622
- echo(
623
- sprintf(
624
- __('%s', 'yet-another-stars-rating'),
625
- $type_visualized) .
626
- '<br />'
627
- );
628
- }
629
-
630
?>
631
632
<div class="yasr-help-box-settings" id="yasr-blogPosting-additional-info" style="display:block">
633
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
<?php
601
+ $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
602
+ sort($review_types);
603
?>
604
+ <select name="yasr_general_options[snippet_itemtype]" id="yasr-choose-reviews-types-list">
605
+ <?php
606
+ foreach ($review_types as $type) {
607
+ $type = trim($type);
608
+ $type_option = $type;
609
+ //to keep compatibility with version <2.2.3
610
+ if($type === 'Place') {
611
+ $type_option='LocalBusiness';
612
+ }
613
+ //to keep compatibility with version <2.2.3
614
+ if($type === 'Other') {
615
+ $type_option='BlogPosting';
616
+ }
617
+
618
+ if ($option['snippet_itemtype'] === $type) {
619
+ echo "<option value=\"$type\" selected>$type_option</option>";
620
+ } else {
621
+ echo "<option value=\"$type\">$type_option</option>";
622
+ }
623
+ }
624
+ ?>
625
+ </select>
626
627
<div class="yasr-help-box-settings" id="yasr-blogPosting-additional-info" style="display:block">
628
lib/admin/settings/yasr-settings-migration-functions.php CHANGED
@@ -503,17 +503,6 @@ function yasr_import_mr_callback() {
503
504
function yasr_save_option_imported_plugin($plugin) {
505
506
- global $wpdb;
507
-
508
- //delete all transient related to yasr_visitor_votes
509
- $sql_delete_transient = "
510
- DELETE FROM {$wpdb->options}
511
- WHERE option_name LIKE '_transient_yasr_visitor_votes_%'
512
- OR option_name LIKE '_transient_timeout_yasr_visitor_votes_%'
513
- ";
514
-
515
- $wpdb->query($sql_delete_transient);
516
-
517
//get actual data
518
$plugin_imported = get_option('yasr_plugin_imported');
519
//Add plugin just imported as a key
503
504
function yasr_save_option_imported_plugin($plugin) {
505
506
//get actual data
507
$plugin_imported = get_option('yasr_plugin_imported');
508
//Add plugin just imported as a key
lib/admin/settings/yasr-stats-functions.php CHANGED
@@ -307,19 +307,15 @@ class YASR_Stats_Log_List_Table extends YASR_WP_List_Table {
307
308
//process bulk action
309
protected function process_bulk_action() {
310
-
311
if ($this->current_action() === 'delete') {
312
check_admin_referer( 'yasr-delete-stats-logs', 'yasr-nonce-delete-stats-logs' );
313
314
global $wpdb;
315
316
$table = YASR_LOG_TABLE;
317
- $transient_name = 'yasr_visitor_votes_';
318
- $query_set_id = false;
319
320
if($this->active_tab === 'logs_multi') {
321
$table = YASR_LOG_MULTI_SET;
322
- $transient_name = 'yasr_visitor_multi_set_';
323
}
324
325
foreach ($_POST['yasr_logs_votes_to_delete'] as $log_id) {
@@ -355,14 +351,6 @@ class YASR_Stats_Log_List_Table extends YASR_WP_List_Table {
355
array( '%d' )
356
);
357
358
- //delete transient
359
- $transient_name = $transient_name . $post_id;
360
-
361
- if($this->active_tab === 'logs_multi') {
362
- $transient_name .= "_$set_id";
363
- }
364
-
365
- delete_transient($transient_name);
366
}
367
}
368
307
308
//process bulk action
309
protected function process_bulk_action() {
310
if ($this->current_action() === 'delete') {
311
check_admin_referer( 'yasr-delete-stats-logs', 'yasr-nonce-delete-stats-logs' );
312
313
global $wpdb;
314
315
$table = YASR_LOG_TABLE;
316
317
if($this->active_tab === 'logs_multi') {
318
$table = YASR_LOG_MULTI_SET;
319
}
320
321
foreach ($_POST['yasr_logs_votes_to_delete'] as $log_id) {
351
array( '%d' )
352
);
353
354
}
355
}
356
lib/admin/yasr-update-functions.php CHANGED
@@ -16,73 +16,6 @@ function yasr_update_version() {
16
global $wpdb;
17
global $yasr_stored_options;
18
19
- function import_multiset_author () {
20
-
21
- global $wpdb;
22
-
23
- $old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
24
-
25
- $sql_import_author_multiset = $wpdb->get_results(
26
- "SELECT post_id, set_type AS set_id,
27
- CONCAT(
28
- '[',
29
- GROUP_CONCAT(
30
- CONCAT(
31
- '{\"field\":', field_id,', \"rating\":',votes,'}'
32
- )
33
- ),
34
- ']'
35
- ) AS fields_and_ratings
36
- FROM $old_yasr_table
37
- WHERE post_id IN (
38
- SELECT post_id
39
- FROM $old_yasr_table
40
- GROUP BY post_id
41
- HAVING SUM(votes)>0
42
- )
43
- GROUP BY post_id, set_type
44
- ORDER BY post_id, set_type", ARRAY_A
45
- );
46
-
47
- if(!empty($sql_import_author_multiset)) {
48
- //just the same code used in yasr_save_multiset_editor
49
- $i = 0;
50
- foreach ($sql_import_author_multiset as $multiset_ratings) {
51
-
52
- $post_id = $multiset_ratings['post_id'];
53
- $set_id = (int)$multiset_ratings['set_id'];
54
- $field_and_vote_array = json_decode($multiset_ratings['fields_and_ratings']);
55
-
56
- //convert in a object with json_decode
57
- $data_to_save[$i] = array(
58
- 'set_id' => $set_id,
59
- 'fields_and_ratings' => $field_and_vote_array
60
- );
61
-
62
- $set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes',true);
63
-
64
- if ($set_post_meta_values) {
65
- //first, loop saved fields and ratings
66
- foreach ($set_post_meta_values as $saved_set) {
67
- //if the saved set is different from the one that we're trying to save,
68
- //append data to save to the post meta
69
- if ($saved_set['set_id'] !== $set_id) {
70
- //increment i
71
- $i++;
72
- $data_to_save[$i]['set_id'] = $saved_set['set_id'];
73
- $data_to_save[$i]['fields_and_ratings'] = $saved_set['fields_and_ratings'];
74
-
75
- }
76
- }
77
- }
78
- update_post_meta($multiset_ratings['post_id'], 'yasr_multiset_author_votes', $data_to_save);
79
- //empty array
80
- $data_to_save = array();
81
- }
82
-
83
- }
84
- }
85
-
86
if ($yasr_version_installed !== false) {
87
88
if (version_compare($yasr_version_installed, '1.7.3') === -1) {
@@ -138,14 +71,6 @@ function yasr_update_version() {
138
139
$old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
140
141
- //delete all transient that use multiset
142
- $sql_delete_transient = "
143
- DELETE FROM {$wpdb->options}
144
- WHERE option_name LIKE '_transient_yasr_visitor_multi_set_%'
145
- OR option_name LIKE '_transient_timeout_yasr_visitor_multi_set_%' ";
146
-
147
- $wpdb->query($sql_delete_transient);
148
-
149
$sql_import_multiset = $wpdb->get_results(
150
"SELECT
151
post_id,
@@ -268,24 +193,72 @@ function yasr_update_version() {
268
269
} //Endif yasr_version_installed !== false
270
271
- if (version_compare($yasr_version_installed, '2.2.0') === -1) {
272
- //delete all transient that uses multiset
273
- $sql_delete_transient_multiset = "
274
- DELETE FROM {$wpdb->options}
275
- WHERE option_name LIKE '_transient_yasr_visitor_multi_set_%'
276
- OR option_name LIKE '_transient_timeout_yasr_visitor_multi_set_%'
277
- ";
278
- $wpdb->query($sql_delete_transient_multiset);
279
- }
280
281
- if (version_compare($yasr_version_installed, '2.2.2') === -1) {
282
- //delete all transient that uses multiset
283
- $sql_delete_transient_visitor_votes = "
284
- DELETE FROM {$wpdb->options}
285
- WHERE option_name LIKE '_transient_yasr_visitor_votes_%'
286
- OR option_name LIKE '_transient_timeout_yasr_visitor_votes_%'
287
- ";
288
- $wpdb->query($sql_delete_transient_visitor_votes);
289
}
290
291
/****** End backward compatibility functions ******/
16
global $wpdb;
17
global $yasr_stored_options;
18
19
if ($yasr_version_installed !== false) {
20
21
if (version_compare($yasr_version_installed, '1.7.3') === -1) {
71
72
$old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
73
74
$sql_import_multiset = $wpdb->get_results(
75
"SELECT
76
post_id,
193
194
} //Endif yasr_version_installed !== false
195
196
197
+ function import_multiset_author () {
198
+
199
+ global $wpdb;
200
+
201
+ $old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
202
+
203
+ $sql_import_author_multiset = $wpdb->get_results(
204
+ "SELECT post_id, set_type AS set_id,
205
+ CONCAT(
206
+ '[',
207
+ GROUP_CONCAT(
208
+ CONCAT(
209
+ '{\"field\":', field_id,', \"rating\":',votes,'}'
210
+ )
211
+ ),
212
+ ']'
213
+ ) AS fields_and_ratings
214
+ FROM $old_yasr_table
215
+ WHERE post_id IN (
216
+ SELECT post_id
217
+ FROM $old_yasr_table
218
+ GROUP BY post_id
219
+ HAVING SUM(votes)>0
220
+ )
221
+ GROUP BY post_id, set_type
222
+ ORDER BY post_id, set_type", ARRAY_A
223
+ );
224
+
225
+ if(!empty($sql_import_author_multiset)) {
226
+ //just the same code used in yasr_save_multiset_editor
227
+ $i = 0;
228
+ foreach ($sql_import_author_multiset as $multiset_ratings) {
229
+
230
+ $post_id = $multiset_ratings['post_id'];
231
+ $set_id = (int)$multiset_ratings['set_id'];
232
+ $field_and_vote_array = json_decode($multiset_ratings['fields_and_ratings']);
233
+
234
+ //convert in a object with json_decode
235
+ $data_to_save[$i] = array(
236
+ 'set_id' => $set_id,
237
+ 'fields_and_ratings' => $field_and_vote_array
238
+ );
239
+
240
+ $set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes',true);
241
+
242
+ if ($set_post_meta_values) {
243
+ //first, loop saved fields and ratings
244
+ foreach ($set_post_meta_values as $saved_set) {
245
+ //if the saved set is different from the one that we're trying to save,
246
+ //append data to save to the post meta
247
+ if ($saved_set['set_id'] !== $set_id) {
248
+ //increment i
249
+ $i++;
250
+ $data_to_save[$i]['set_id'] = $saved_set['set_id'];
251
+ $data_to_save[$i]['fields_and_ratings'] = $saved_set['fields_and_ratings'];
252
+
253
+ }
254
+ }
255
+ }
256
+ update_post_meta($multiset_ratings['post_id'], 'yasr_multiset_author_votes', $data_to_save);
257
+ //empty array
258
+ $data_to_save = array();
259
+ }
260
+
261
+ }
262
}
263
264
/****** End backward compatibility functions ******/
lib/rest/YasrCustomFields.php CHANGED
@@ -25,6 +25,7 @@ class YasrCustomFields extends WP_REST_Controller {
25
* YOURSITE.COM/wp-json/wp/v2/posts
26
*/
27
$this->visitorVotes();
28
}
29
30
/**
@@ -50,7 +51,7 @@ class YasrCustomFields extends WP_REST_Controller {
50
//Register Visitor Votes
51
register_rest_field(
52
$post_types,
53
- 'yasr-visitor-votes',
54
array(
55
'get_callback' => function() {return YasrDatabaseRatings::getVisitorVotes(); },
56
'update_callback' => null,
@@ -59,4 +60,27 @@ class YasrCustomFields extends WP_REST_Controller {
59
);
60
61
}
62
}
25
* YOURSITE.COM/wp-json/wp/v2/posts
26
*/
27
$this->visitorVotes();
28
+ $this->allItemTypes();
29
}
30
31
/**
51
//Register Visitor Votes
52
register_rest_field(
53
$post_types,
54
+ 'yasr_visitor_votes',
55
array(
56
'get_callback' => function() {return YasrDatabaseRatings::getVisitorVotes(); },
57
'update_callback' => null,
60
);
61
62
}
63
+
64
+ /**
65
+ * Helper function to return supported itemtype
66
+ */
67
+ private function allItemTypes() {
68
+ $post_types = yasr_return_all_post_types();
69
+ $yasr_itemtype_schema = array(
70
+ 'description' => 'Yasr Supported Item Types',
71
+ 'type' => 'object',
72
+ 'context' => array('edit'),
73
+ );
74
+
75
+ //Register Visitor Votes
76
+ register_rest_field(
77
+ $post_types,
78
+ 'yasr_all_itemtypes',
79
+ array(
80
+ 'get_callback' => function() {return json_decode(YASR_SUPPORTED_SCHEMA_TYPES); },
81
+ 'update_callback' => null,
82
+ 'schema' => $yasr_itemtype_schema
83
+ )
84
+ );
85
+ }
86
}
lib/yasr-ajax-functions.php CHANGED
@@ -332,10 +332,6 @@ function yasr_insert_visitor_votes_callback() {
332
$rating = 5;
333
}
334
335
- $transient_name = 'yasr_visitor_votes_' . $post_id;
336
-
337
- delete_transient($transient_name);
338
-
339
global $wpdb;
340
341
$current_user = wp_get_current_user();
@@ -403,7 +399,7 @@ function yasr_insert_visitor_votes_callback() {
403
}
404
405
if ($result_update_log || $result_insert_log) {
406
- $row_exists = YasrDatabaseRatings::getVisitorVotes($post_id, false);
407
408
$user_votes_sum = $row_exists['sum_votes'];
409
$number_of_votes = $row_exists['number_of_votes'];
@@ -470,8 +466,6 @@ function yasr_visitor_multiset_field_vote_callback() {
470
$current_user = wp_get_current_user();
471
$ip_adress = yasr_get_ip();
472
473
- delete_transient('yasr_visitor_multi_set_' . $post_id . '_' . $set_type);
474
-
475
$array_action_visitor_multiset_vote = array('post_id' => $post_id);
476
477
do_action('yasr_action_on_visitor_multiset_vote', $array_action_visitor_multiset_vote);
332
$rating = 5;
333
}
334
335
global $wpdb;
336
337
$current_user = wp_get_current_user();
399
}
400
401
if ($result_update_log || $result_insert_log) {
402
+ $row_exists = YasrDatabaseRatings::getVisitorVotes($post_id);
403
404
$user_votes_sum = $row_exists['sum_votes'];
405
$number_of_votes = $row_exists['number_of_votes'];
466
$current_user = wp_get_current_user();
467
$ip_adress = yasr_get_ip();
468
469
$array_action_visitor_multiset_vote = array('post_id' => $post_id);
470
471
do_action('yasr_action_on_visitor_multiset_vote', $array_action_visitor_multiset_vote);
lib/yasr-db-classes.php CHANGED
@@ -49,11 +49,10 @@ class YasrDatabaseRatings {
49
50
/**
51
* @param bool|integer $post_id
52
- * @param bool $create_transient
53
*
54
* @return array|bool|mixed|object|null
55
*/
56
- public static function getVisitorVotes ($post_id = false, $create_transient = true) {
57
global $wpdb;
58
59
//if values it's not passed get the post id, most of cases and default one
@@ -61,38 +60,24 @@ class YasrDatabaseRatings {
61
$post_id = get_the_ID();
62
}
63
64
- if (!is_int($post_id)) {
65
- return false;
66
- }
67
-
68
- $transient_name = 'yasr_visitor_votes_' . $post_id;
69
- $transient_visitor_votes = get_transient($transient_name);
70
-
71
- if ($transient_visitor_votes) {
72
- return $transient_visitor_votes;
73
- } else {
74
- $result = $wpdb->get_results(
75
- $wpdb->prepare(
76
- "SELECT SUM(vote) as sum_votes,
77
- COUNT(vote) as number_of_votes FROM "
78
- . YASR_LOG_TABLE .
79
- " WHERE post_id=%d",
80
- $post_id
81
- )
82
- );
83
-
84
- $array_to_return = array();
85
- foreach ($result as $user_votes) {
86
- $array_to_return['number_of_votes'] = (int)$user_votes->number_of_votes;
87
- $array_to_return['sum_votes'] = (int)$user_votes->sum_votes;
88
- }
89
90
- if ($create_transient === true) {
91
- set_transient($transient_name, $array_to_return, WEEK_IN_SECONDS);
92
- }
93
- return $array_to_return;
94
}
95
96
}
97
98
/**
@@ -295,12 +280,6 @@ class YasrMultiSetData {
295
$post_id = (int)$post_id;
296
$set_type = (int)$set_type;
297
298
- $result = get_transient('yasr_visitor_multi_set_' . $post_id . '_' . $set_type);
299
-
300
- if ($result !== false) {
301
- return $result;
302
- }
303
-
304
global $wpdb;
305
306
$result = $wpdb->get_results($wpdb->prepare("SELECT f.field_name AS name,
@@ -315,12 +294,10 @@ class YasrMultiSetData {
315
ORDER BY f.field_id", $post_id, $set_type), ARRAY_A);
316
317
if (!empty($result)) {
318
- set_transient('yasr_visitor_multi_set_' . $post_id . '_' . $set_type, $result, WEEK_IN_SECONDS);
319
return $result;
320
} else {
321
return false;
322
}
323
-
324
}
325
326
49
50
/**
51
* @param bool|integer $post_id
52
*
53
* @return array|bool|mixed|object|null
54
*/
55
+ public static function getVisitorVotes ($post_id = false) {
56
global $wpdb;
57
58
//if values it's not passed get the post id, most of cases and default one
60
$post_id = get_the_ID();
61
}
62
63
+ $result = $wpdb->get_results(
64
+ $wpdb->prepare(
65
+ "SELECT SUM(vote) as sum_votes,
66
+ COUNT(vote) as number_of_votes FROM "
67
+ . YASR_LOG_TABLE .
68
+ " WHERE post_id=%d",
69
+ $post_id
70
+ )
71
+ );
72
73
+ $array_to_return = array();
74
+ foreach ($result as $user_votes) {
75
+ $array_to_return['number_of_votes'] = (int)$user_votes->number_of_votes;
76
+ $array_to_return['sum_votes'] = (int)$user_votes->sum_votes;
77
}
78
79
+ return $array_to_return;
80
+
81
}
82
83
/**
280
$post_id = (int)$post_id;
281
$set_type = (int)$set_type;
282
283
global $wpdb;
284
285
$result = $wpdb->get_results($wpdb->prepare("SELECT f.field_name AS name,
294
ORDER BY f.field_id", $post_id, $set_type), ARRAY_A);
295
296
if (!empty($result)) {
297
return $result;
298
} else {
299
return false;
300
}
301
}
302
303
lib/yasr-db-functions.php CHANGED
@@ -204,6 +204,15 @@ function yasr_get_snippet_type() {
204
if ($result) {
205
$snippet_type = trim($result);
206
207
if (!in_array($snippet_type, $review_types)) {
208
$snippet_type = YASR_ITEMTYPE;
209
}
@@ -230,8 +239,7 @@ function yasr_return_multi_set_values_admin($post_id, $set_id) {
230
$set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
231
232
//set meta values
233
- $set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes', true);
234
- $array_to_return = YasrMultiSetData::returnArrayFieldsRatings($set_id, $set_fields, $set_post_meta_values);
235
236
echo json_encode($array_to_return);
237
@@ -395,18 +403,6 @@ function yasr_insert_overall_rating_callback($post_id) {
395
add_post_meta($post_id, 'yasr_review_type', YASR_ITEMTYPE);
396
}
397
398
- //this will not work on error or
399
- //if the value is the same in the db
400
- //comment out from version 1.9.6
401
- //Have to find a way to save transient with gutenberg without save_post or ajax action
402
- /*if ($update_result) {
403
-
404
- $transient_name = 'yasr_overall_rating_' . $post_id;
405
-
406
- set_transient($transient_name, $rating, WEEK_IN_SECONDS);
407
-
408
- }*/
409
-
410
}
411
412
add_action('save_post', 'yasr_insert_review_type_callback');
@@ -567,4 +563,4 @@ if (YASR_AUTO_INSERT_ENABLED == 1) {
567
568
}
569
570
- }
204
if ($result) {
205
$snippet_type = trim($result);
206
207
+ //to keep compatibility with version <2.2.3
208
+ if($snippet_type === 'Place') {
209
+ $snippet_type = 'LocalBusiness';
210
+ }
211
+ //to keep compatibility with version <2.2.3
212
+ if($snippet_type === 'Other') {
213
+ $snippet_type = 'BlogPosting';
214
+ }
215
+
216
if (!in_array($snippet_type, $review_types)) {
217
$snippet_type = YASR_ITEMTYPE;
218
}
239
$set_fields = YasrMultiSetData::multisetFieldsAndID($set_id);
240
241
//set meta values
242
+ $array_to_return = YasrMultiSetData::returnArrayFieldsRatings($set_id, $set_fields, $post_id);
243
244
echo json_encode($array_to_return);
245
403
add_post_meta($post_id, 'yasr_review_type', YASR_ITEMTYPE);
404
}
405
406
}
407
408
add_action('save_post', 'yasr_insert_review_type_callback');
563
564
}
565
566
+ }
lib/yasr-functions.php CHANGED
@@ -36,7 +36,7 @@ function yasr_add_scripts() {
36
//Run after default css are loaded
37
do_action('yasr_add_front_script_css');
38
39
- $yasr_multiset_theme_handle= 'yasrcsslightscheme';
40
$yasr_multiset_theme = 'yasr-table-light.css';
41
42
//default css is the light one
@@ -387,7 +387,7 @@ function yasr_add_schema($content) {
387
}
388
389
$overall_rating = YasrDatabaseRatings::getOverallRating();
390
- $visitor_votes = YasrDatabaseRatings::getVisitorVotes(false, false);
391
392
$is_post_a_review = get_post_meta(get_the_ID(), 'yasr_post_is_review', true);
393
@@ -441,26 +441,14 @@ function yasr_add_schema($content) {
441
$post_image_size = @getimagesize($post_image_url_absolute); //the @ should be useless, just to be safe
442
}
443
444
- if ($review_choosen === "Product") {
445
- $rich_snippet["@type"] = "Product";
446
- }
447
- elseif($review_choosen === 'Book') {
448
- $rich_snippet["@type"] = "Book";
449
- }
450
- elseif($review_choosen === 'Movie') {
451
- $rich_snippet["@type"] = "Movie";
452
- }
453
- elseif($review_choosen === 'Game') {
454
- $rich_snippet["@type"] = "Game";
455
- }
456
- elseif ($review_choosen == "Place") {
457
- $rich_snippet["@type"] = "LocalBusiness";
458
- }
459
- elseif ($review_choosen === "Recipe") {
460
- $rich_snippet["@type"] = "Recipe";
461
}
462
- elseif ($review_choosen == "Other") {
463
- $rich_snippet["@type"] = "BlogPosting";
464
$rich_snippet["datePublished"] = $date;
465
$rich_snippet["headline"] = $review_name;
466
$rich_snippet["mainEntityOfPage"] = array(
@@ -493,7 +481,8 @@ function yasr_add_schema($content) {
493
494
}
495
496
- $rich_snippet["name"] = $review_name;
497
$rich_snippet["image"] = array(
498
"@type" => "ImageObject",
499
"url" => $post_image_url,
@@ -502,21 +491,22 @@ function yasr_add_schema($content) {
502
);
503
504
//Do not add rating if blogposting
505
- if ($review_choosen !== 'Other') {
506
507
if ($overall_rating && $overall_rating != '-1' && $overall_rating != '0.0') {
508
$rich_snippet["Review"] = array(
509
- "@type" => "Review",
510
- "name" => "$review_name",
511
- "author" => array(
512
- "@type" => "Person",
513
- "name" => "$author"
514
),
515
- "datePublished" => "$date",
516
- "dateModified" => $date_modified,
517
- "reviewRating" => array(
518
- "@type" => "Rating",
519
- "ratingValue" => "$overall_rating",
520
),
521
);
522
}
@@ -529,10 +519,11 @@ function yasr_add_schema($content) {
529
$average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
530
$average_rating = round($average_rating, 1);
531
532
- $rich_snippet["aggregateRating"] = array(
533
- "@type" => "AggregateRating",
534
- "ratingValue" => "$average_rating",
535
- "ratingCount" => $visitor_votes['number_of_votes'],
536
);
537
}
538
}
@@ -559,7 +550,9 @@ function yasr_add_schema($content) {
559
560
function yasr_select_itemtype() {
561
562
- $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
563
$review_type_choosen = yasr_get_snippet_type();
564
565
?>
@@ -572,12 +565,6 @@ function yasr_select_itemtype() {
572
573
$type = trim($type);
574
$type_option = $type;
575
- if($type === 'Place') {
576
- $type_option='LocalBusiness';
577
- }
578
- if($type === 'Other') {
579
- $type_option='BlogPosting';
580
- }
581
582
if ($type === $review_type_choosen) {
583
echo "<option value=\"$type\" selected>$type_option</option>";
36
//Run after default css are loaded
37
do_action('yasr_add_front_script_css');
38
39
+ $yasr_multiset_theme_handle = 'yasrcsslightscheme';
40
$yasr_multiset_theme = 'yasr-table-light.css';
41
42
//default css is the light one
387
}
388
389
$overall_rating = YasrDatabaseRatings::getOverallRating();
390
+ $visitor_votes = YasrDatabaseRatings::getVisitorVotes(false);
391
392
$is_post_a_review = get_post_meta(get_the_ID(), 'yasr_post_is_review', true);
393
441
$post_image_size = @getimagesize($post_image_url_absolute); //the @ should be useless, just to be safe
442
}
443
444
+ $rich_snippet["@type"] = $review_choosen;
445
+
446
+ if ($review_choosen === 'Place') {
447
+ $rich_snippet["@type"] = 'LocalBusiness';
448
}
449
+
450
+ elseif ($review_choosen === 'Other' || $review_choosen === 'BlogPosting') {
451
+ $rich_snippet["@type"] = 'BlogPosting';
452
$rich_snippet["datePublished"] = $date;
453
$rich_snippet["headline"] = $review_name;
454
$rich_snippet["mainEntityOfPage"] = array(
481
482
}
483
484
+ $rich_snippet["name"] = $review_name;
485
+ $rich_snippet['description'] = $review_name;
486
$rich_snippet["image"] = array(
487
"@type" => "ImageObject",
488
"url" => $post_image_url,
491
);
492
493
//Do not add rating if blogposting
494
+ if ($review_choosen !== 'Other' && $review_choosen !== 'BlogPosting') {
495
496
if ($overall_rating && $overall_rating != '-1' && $overall_rating != '0.0') {
497
$rich_snippet["Review"] = array(
498
+ '@type' => 'Review',
499
+ 'name' => $review_name,
500
+ 'author' => array(
501
+ '@type' => 'Person',
502
+ 'name' => $author
503
),
504
+ 'datePublished' => $date,
505
+ 'dateModified' => $date_modified,
506
+ 'reviewRating' => array(
507
+ '@type' => 'Rating',
508
+ 'ratingValue' => $overall_rating,
509
+ 'bestRating' => 5
510
),
511
);
512
}
519
$average_rating = $visitor_votes['sum_votes'] / $visitor_votes['number_of_votes'];
520
$average_rating = round($average_rating, 1);
521
522
+ $rich_snippet['aggregateRating'] = array(
523
+ '@type' => 'AggregateRating',
524
+ 'ratingValue' => $average_rating,
525
+ 'ratingCount' => $visitor_votes['number_of_votes'],
526
+ 'bestRating' => 5
527
);
528
}
529
}
550
551
function yasr_select_itemtype() {
552
553
+ $review_types = json_decode(YASR_SUPPORTED_SCHEMA_TYPES);
554
+
555
+ sort($review_types);
556
$review_type_choosen = yasr_get_snippet_type();
557
558
?>
565
566
$type = trim($type);
567
$type_option = $type;
568
569
if ($type === $review_type_choosen) {
570
echo "<option value=\"$type\" selected>$type_option</option>";
lib/yasr-shortcode-functions.php CHANGED
@@ -22,6 +22,10 @@ if (!defined('ABSPATH')) {
22
exit('You\'re not allowed to see this page');
23
} // Exit if accessed directly
24
25
require YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-classes.php';
26
27
/****** Add shortcode for overall rating ******/
22
exit('You\'re not allowed to see this page');
23
} // Exit if accessed directly
24
25
+ if(is_admin()) {
26
+ return;
27
+ }
28
+
29
require YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-classes.php';
30
31
/****** Add shortcode for overall rating ******/
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.9.0
5
Contributors: Dudo
6
Tested up to: 5.4
7
Requires PHP: 5.3
8
- Stable tag: 2.2.2
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
@@ -125,6 +125,21 @@ If doesn't, it's suggested to ask in a SEO oriented forum.
125
126
The full changelog can be found in the plugin's directory. Recent entries:
127
128
= 2.2.2 =
129
* FIXED: links in Recent Ratings dashboard widget (thanks to Fernando Tellado)
130
* Enhancement: Added REST responses. More info in the official site
5
Contributors: Dudo
6
Tested up to: 5.4
7
Requires PHP: 5.3
8
+ Stable tag: 2.2.3
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
125
126
The full changelog can be found in the plugin's directory. Recent entries:
127
128
+ = 2.2.3 =
129
+ * NEW FEATURE: Added support for the following structured datas:
130
+ - Course
131
+ - CreativeWorkSeason,
132
+ - CreativeWorkSeries,
133
+ - Episode,
134
+ - Event
135
+ - MediaObject,
136
+ - Movie,
137
+ - MusicPlaylist,
138
+ - MusicRecording.
139
+
140
+ * TWEAKED: Removed transient: since version 2.2.0 are useless.
141
+
142
+
143
= 2.2.2 =
144
* FIXED: links in Recent Ratings dashboard widget (thanks to Fernando Tellado)
145
* Enhancement: Added REST responses. More info in the official site
yet-another-stars-rating.php CHANGED
@@ -5,7 +5,7 @@
5
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
* Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
* testimonials to your website posts, pages and CPT, without affecting its speed.
8
- * Version: 2.2.2
9
* Author: Dario Curvino
10
* Author URI: https://dariocurvino.it/
11
* Text Domain: yet-another-stars-rating
@@ -77,7 +77,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
77
yasr_fs();
78
// Signal that SDK was initiated.
79
do_action( 'yasr_fs_loaded' );
80
- define( 'YASR_VERSION_NUM', '2.2.2' );
81
//Plugin relative path
82
define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
83
//Plugin RELATIVE PATH without slashes (just the directory's name)
@@ -196,7 +196,6 @@ if ( !function_exists( 'yasr_fs' ) ) {
196
require YASR_ABSOLUTE_PATH . '/lib/rest/YasrCustomEndpoint.php';
197
require YASR_ABSOLUTE_PATH . '/lib/rest/yasr-rest.php';
198
require YASR_ABSOLUTE_PATH . '/lib/yasr-widgets.php';
199
- require YASR_ABSOLUTE_PATH . '/lib/yasr-deprecated.php';
200
201
if ( is_admin() ) {
202
require YASR_ABSOLUTE_PATH . '/lib/admin/yasr-admin-classes.php';
@@ -219,13 +218,21 @@ if ( !function_exists( 'yasr_fs' ) ) {
219
//use json_decode for compatibility with php <7
220
//https://wordpress.org/support/topic/error-after-update-to-version-2-0-6/
221
$supported_schema_types = json_encode( array(
222
- 'Product',
223
'Book',
224
- 'Movie',
225
'Game',
226
- 'Place',
227
- 'Recipe',
228
- 'Other'
229
) );
230
define( "YASR_SUPPORTED_SCHEMA_TYPES", $supported_schema_types );
231
//role to save overall_rating and multi set
5
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
* Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
* testimonials to your website posts, pages and CPT, without affecting its speed.
8
+ * Version: 2.2.3
9
* Author: Dario Curvino
10
* Author URI: https://dariocurvino.it/
11
* Text Domain: yet-another-stars-rating
77
yasr_fs();
78
// Signal that SDK was initiated.
79
do_action( 'yasr_fs_loaded' );
80
+ define( 'YASR_VERSION_NUM', '2.2.3' );
81
//Plugin relative path
82
define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
83
//Plugin RELATIVE PATH without slashes (just the directory's name)
196
require YASR_ABSOLUTE_PATH . '/lib/rest/YasrCustomEndpoint.php';
197
require YASR_ABSOLUTE_PATH . '/lib/rest/yasr-rest.php';
198
require YASR_ABSOLUTE_PATH . '/lib/yasr-widgets.php';
199
200
if ( is_admin() ) {
201
require YASR_ABSOLUTE_PATH . '/lib/admin/yasr-admin-classes.php';
218
//use json_decode for compatibility with php <7
219
//https://wordpress.org/support/topic/error-after-update-to-version-2-0-6/
220
$supported_schema_types = json_encode( array(
221
+ 'BlogPosting',
222
'Book',
223
+ 'Course',
224
+ 'CreativeWorkSeason',
225
+ 'CreativeWorkSeries',
226
+ 'Episode',
227
+ 'Event',
228
'Game',
229
+ 'LocalBusiness',
230
+ 'MediaObject',
231
+ 'Movie',
232
+ 'MusicPlaylist',
233
+ 'MusicRecording',
234
+ 'Product',
235
+ 'Recipe'
236
) );
237
define( "YASR_SUPPORTED_SCHEMA_TYPES", $supported_schema_types );
238
//role to save overall_rating and multi set