Yasr – Yet Another Stars Rating - Version 1.3.0

Version Description

  • NEW FEATURE: Widget support for yasr_overall_rating and yasr_visitor_votes shortcodes
  • TWEAKED: Yasr shortcode creatore will appear only in backend
Download this release

Release Info

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

Code changes from version 1.2.9 to 1.3.0

changelog.txt CHANGED
@@ -1,3 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 1.2.1 =
2
  * FIXED: wrong css class on ajax response if yasr_visitor_votes is used with a different size then default
3
 
1
+ = 1.2.5 =
2
+ * NEW FEATURE: in settings -> Multi Set tab is now possible to choose if show or hide by default the average for multi set
3
+ * FIXED: logo image for rich snippet
4
+ * TWEAKED: changed globals names
5
+ * FIXED: minor changes
6
+
7
+ = 1.2.4 =
8
+ * FIXED: Settings lost on update
9
+ * FIXED: error if logo image are not set
10
+ * FIXED: it was passible to rate twice a same field in a yasr_visitor_mutliset
11
+ * Minor changes
12
+
13
+ = 1.2.3 =
14
+ * TWEAKED: image is avaible for recipe tipe too
15
+ * FIXED: inverted width and height on rich snippets
16
+ * FIXED: removed rich snippets on page without ratings
17
+ * FIXED: minor bugfixes
18
+
19
+ = 1.2.2 =
20
+ * NEW FEATURE: by default Multi Set show now a newline with average rating: it's possible to hide this simply adding the attriute show_average='no' in the shortcode
21
+ * TWEAKED: google support now json-ld for reviews: so microdata have been removed from yasr, that now use only json-ld. Further this, all blogposting error have been fixed
22
+ * FIXED: Multi Set cache didn't get when it was edited
23
+ * TWEAK: code cleanup and bugfix
24
+
25
  = 1.2.1 =
26
  * FIXED: wrong css class on ajax response if yasr_visitor_votes is used with a different size then default
27
 
lib/yasr-ajax-functions.php CHANGED
@@ -1356,7 +1356,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1356
  }
1357
 
1358
  //create an hook
1359
- do_action('yasr_action_on_update_visitor_vote', $post_id, $rating);
1360
 
1361
  //Check nonce
1362
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1356
  }
1357
 
1358
  //create an hook
1359
+ do_action('yasr_action_on_update_visitor_vote', $post_id, $new_rating);
1360
 
1361
  //Check nonce
1362
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
lib/yasr-functions.php CHANGED
@@ -697,9 +697,13 @@ add_action('media_buttons', 'yasr_shortcode_button_media', 99);
697
 
698
  function yasr_shortcode_button_media() {
699
 
700
- add_thickbox();
701
 
702
- echo '<a href="#TB_inline?width=530&height=600&inlineId=yasr-tinypopup-form" id="yasr-shortcode-creator" class="button thickbox"><span class="dashicons dashicons-star-half" style="vertical-align: text-top;"></span> Yasr Shortcode</a>';
 
 
 
 
703
 
704
  }
705
 
697
 
698
  function yasr_shortcode_button_media() {
699
 
700
+ if (is_admin()) {
701
 
702
+ add_thickbox();
703
+
704
+ echo '<a href="#TB_inline?width=530&height=600&inlineId=yasr-tinypopup-form" id="yasr-shortcode-creator" class="button thickbox"><span class="dashicons dashicons-star-half" style="vertical-align: text-top;"></span> Yasr Shortcode</a>';
705
+
706
+ }
707
 
708
  }
709
 
lib/yasr-widgets.php ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 2 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>
19
+ */
20
+
21
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
22
+
23
+ add_action( 'widgets_init', 'yasr_overall_rating_widget' );
24
+
25
+
26
+ // register Yasr Overall Rating widget
27
+ function yasr_overall_rating_widget() {
28
+ register_widget( 'Yasr_Overall_Rating_Widget' );
29
+ }
30
+
31
+ /**
32
+ * Adds Yasr_Overall_Rating_Widget widget.
33
+ */
34
+ class Yasr_Overall_Rating_Widget extends WP_Widget {
35
+
36
+ /**
37
+ * Register widget with WordPress.
38
+ */
39
+ function __construct() {
40
+
41
+ parent::__construct(
42
+ 'yasr_overall_rating_widget', // Base ID
43
+ __( 'Yasr Overall Rating', 'yet-another-stars-rating' ), // Name
44
+ array(
45
+ 'description' => __( 'Display Overall Rating', 'yet-another-stars-rating' ),
46
+ 'size' => 'large'
47
+ ) // Args
48
+ );
49
+
50
+ }
51
+
52
+ /**
53
+ * Front-end display of widget.
54
+ *
55
+ * @see WP_Widget::widget()
56
+ *
57
+ * @param array $args Widget arguments.
58
+ * @param array $instance Saved values from database.
59
+ */
60
+
61
+ public function widget( $args, $instance ) {
62
+
63
+ if( is_singular() && is_main_query() ) {
64
+
65
+ echo $args['before_widget'];
66
+
67
+ if ( ! empty( $instance['title'] ) ) {
68
+ echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
69
+ }
70
+
71
+ $size = array();
72
+
73
+ $size['size'] = $instance['size'];
74
+
75
+ $widget_overall_rating = shortcode_overall_rating_callback($size);
76
+
77
+ echo $widget_overall_rating;
78
+
79
+ echo $args['after_widget'];
80
+
81
+ }
82
+
83
+ }
84
+
85
+
86
+ /**
87
+ * Back-end widget form.
88
+ *
89
+ * @see WP_Widget::form()
90
+ *
91
+ * @param array $instance Previously saved values from database.
92
+ */
93
+
94
+ public function form( $instance ) {
95
+
96
+ if (!empty($instance['title'])) {
97
+
98
+ $title = $instance['title'];
99
+
100
+ }
101
+
102
+ else {
103
+
104
+ $title = __( 'Our Rating:', 'yet-another-stars-rating' );
105
+
106
+ }
107
+
108
+ if(empty($instance['size'])) {
109
+
110
+ $size = 'large';
111
+
112
+ }
113
+
114
+ else {
115
+
116
+ $size = $instance['size'];
117
+
118
+ }
119
+
120
+ ?>
121
+
122
+ <p>
123
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
124
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
125
+ </p>
126
+ <p>
127
+ <legend><?php _e('Size:', 'yet-another-stars-rating'); ?></legend>
128
+ <input type="radio" name="<?php echo $this->get_field_name( 'size' ); ?>" value="small" <?php if ($size === 'small' ) echo 'checked'; ?> >Small
129
+ <br />
130
+ <input type="radio" name="<?php echo $this->get_field_name( 'size' ); ?>" value="medium" <?php if ($size === 'medium' ) echo 'checked'; ?> >Medium
131
+ <br />
132
+ <input type="radio" name="<?php echo $this->get_field_name( 'size' ); ?>" value="large" <?php if ($size === 'large' ) echo 'checked'; ?> >Large
133
+ </p>
134
+
135
+ <?php
136
+
137
+ }
138
+
139
+ /**
140
+ * Sanitize widget form values as they are saved.
141
+ *
142
+ * @see WP_Widget::update()
143
+ *
144
+ * @param array $new_instance Values just sent to be saved.
145
+ * @param array $old_instance Previously saved values from database.
146
+ *
147
+ * @return array Updated safe values to be saved.
148
+ */
149
+ public function update( $new_instance, $old_instance ) {
150
+
151
+ $instance = $old_instance;
152
+
153
+ if (!$instance) {
154
+
155
+ $instance = array();
156
+
157
+ }
158
+
159
+ if (!empty($new_instance['title'])) {
160
+
161
+ $instance['title'] = strip_tags($new_instance['title']);
162
+
163
+ }
164
+
165
+ else {
166
+
167
+ $instance['title'] = '';
168
+
169
+ }
170
+
171
+ if (!empty($new_instance['size'])) {
172
+
173
+ $instance['size'] = strip_tags($new_instance['size']);
174
+
175
+ }
176
+
177
+ else {
178
+
179
+ $instance['size'] = 'large';
180
+
181
+ }
182
+
183
+ return $instance;
184
+ }
185
+
186
+ } // class Yasr Overall Rating widget
187
+
188
+
189
+
190
+ add_action( 'widgets_init', 'yasr_visitor_votes_widget' );
191
+
192
+ // register Yasr Overall Rating widget
193
+ function yasr_visitor_votes_widget() {
194
+ register_widget( 'Yasr_Visitor_Votes_Widget' );
195
+ }
196
+
197
+
198
+ class Yasr_Visitor_Votes_Widget extends WP_Widget {
199
+
200
+ /**
201
+ * Register widget with WordPress.
202
+ */
203
+ function __construct() {
204
+
205
+ parent::__construct(
206
+ 'yasr_visitor_votes_widget', // Base ID
207
+ __( 'Yasr Visitor Votes', 'yet-another-stars-rating' ), // Name
208
+ array(
209
+ 'description' => __( 'Show Yasr Visitor Votes', 'yet-another-stars-rating' ),
210
+ 'readonly' => 'no',
211
+ 'size' => 'large'
212
+ ) // Args
213
+ );
214
+
215
+ }
216
+
217
+ /**
218
+ * Front-end display of widget.
219
+ *
220
+ * @see WP_Widget::widget()
221
+ *
222
+ * @param array $args Widget arguments.
223
+ * @param array $instance Saved values from database.
224
+ */
225
+
226
+ public function widget( $args, $instance ) {
227
+
228
+ if( is_singular() && is_main_query() ) {
229
+
230
+ echo $args['before_widget'];
231
+
232
+ if ( ! empty( $instance['title'] ) ) {
233
+ echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
234
+ }
235
+
236
+ $size = array();
237
+
238
+ $size['size'] = $instance['size'];
239
+
240
+ if ($instance['readonly'] === 'yes') {
241
+
242
+ $widget_visitor_votes = yasr_visitor_votes_readonly_callback($size);
243
+
244
+ }
245
+
246
+ else {
247
+
248
+ $widget_visitor_votes = shortcode_visitor_votes_callback($size);
249
+
250
+ }
251
+
252
+
253
+ echo $widget_visitor_votes;
254
+
255
+ echo $args['after_widget'];
256
+
257
+ }
258
+
259
+ }
260
+
261
+
262
+ /**
263
+ * Back-end widget form.
264
+ *
265
+ * @see WP_Widget::form()
266
+ *
267
+ * @param array $instance Previously saved values from database.
268
+ */
269
+
270
+ public function form( $instance ) {
271
+
272
+ if (!empty($instance['title'])) {
273
+
274
+ $title = $instance['title'];
275
+
276
+ }
277
+
278
+ else {
279
+
280
+ $title = __( 'Rate This:', 'yet-another-stars-rating' );
281
+
282
+ }
283
+
284
+ if(empty($instance['readonly'])) {
285
+
286
+ $readonly = 'no';
287
+
288
+ }
289
+
290
+ else {
291
+
292
+ $readonly = 'yes';
293
+
294
+ }
295
+
296
+ if(empty($instance['size'])) {
297
+
298
+ $size = 'large';
299
+
300
+ }
301
+
302
+ else {
303
+
304
+ $size = $instance['size'];
305
+
306
+ }
307
+
308
+ ?>
309
+
310
+ <p>
311
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
312
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
313
+ </p>
314
+ <p>
315
+ <input type="checkbox" id="<?php echo $this->get_field_id( 'readonly' ); ?>" name="<?php echo $this->get_field_name( 'readonly' ); ?>" value="yes" <?php if ($readonly === 'yes') echo " checked='checked' "; ?>>
316
+ <label for="<?php echo $this->get_field_id( 'readonly' ); ?>">Readonly?</label>
317
+ </p>
318
+ <p>
319
+ <legend><?php _e('Size:', 'yet-another-stars-rating'); ?></legend>
320
+ <input type="radio" name="<?php echo $this->get_field_name( 'size' ); ?>" value="small" <?php if ($size === 'small' ) echo 'checked'; ?> >Small
321
+ <br />
322
+ <input type="radio" name="<?php echo $this->get_field_name( 'size' ); ?>" value="medium" <?php if ($size === 'medium' ) echo 'checked'; ?> >Medium
323
+ <br />
324
+ <input type="radio" name="<?php echo $this->get_field_name( 'size' ); ?>" value="large" <?php if ($size === 'large' ) echo 'checked'; ?> >Large
325
+ </p>
326
+
327
+ <?php
328
+
329
+ }
330
+
331
+ /**
332
+ * Sanitize widget form values as they are saved.
333
+ *
334
+ * @see WP_Widget::update()
335
+ *
336
+ * @param array $new_instance Values just sent to be saved.
337
+ * @param array $old_instance Previously saved values from database.
338
+ *
339
+ * @return array Updated safe values to be saved.
340
+ */
341
+ public function update( $new_instance, $old_instance ) {
342
+
343
+ $instance = $old_instance;
344
+
345
+ if (!$instance) {
346
+
347
+ $instance = array();
348
+
349
+ }
350
+
351
+ if (!empty($new_instance['title'])) {
352
+
353
+ $instance['title'] = strip_tags($new_instance['title']);
354
+
355
+ }
356
+
357
+ else {
358
+
359
+ $instance['title'] = '';
360
+
361
+ }
362
+
363
+ $instance['readonly'] = strip_tags($new_instance['readonly']);
364
+
365
+ if (!empty($new_instance['size'])) {
366
+
367
+ $instance['size'] = strip_tags($new_instance['size']);
368
+
369
+ }
370
+
371
+ else {
372
+
373
+ $instance['size'] = 'large';
374
+
375
+ }
376
+
377
+
378
+ return $instance;
379
+ }
380
+
381
+ } // class Yasr Overall Rating widget
382
+
383
+
384
+ ?>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
3
  Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post rating, posts, rate, rating, rating platform, rating system, ratings, review, reviews, rich snippets, seo, star, star rating, stars, vote, Votes, voting, voting contest, schema, serp
4
  Requires at least: 4.3.0
5
  Contributors: Dudo
6
- Tested up to: 4.5.1
7
- Stable tag: 1.2.9
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
@@ -113,6 +113,10 @@ Of course not: you can easily add it on the visual editor just by clicking the "
113
 
114
  The full changelog can be found in the plugin's directory. Recent entries:
115
 
 
 
 
 
116
  = 1.2.9 =
117
  * NEW FEATURE: If auto insert is enabled, it's now possible to exclude the single post or page
118
  * TWEAKED: Restyling for settings panel
@@ -133,27 +137,3 @@ The full changelog can be found in the plugin's directory. Recent entries:
133
  * TWEAKED: removed unused div on yasr_most_or_highest_rated shortcode
134
  * TWEAKED: minor changes on rankings shortcodes
135
  * TWEAKED: added $rating on action yasr_action_on_visitor_vote, yasr_action_on_update_visitor_vote and yasr_action_on_overall_rating
136
-
137
- = 1.2.5 =
138
- * NEW FEATURE: in settings -> Multi Set tab is now possible to choose if show or hide by default the average for multi set
139
- * FIXED: logo image for rich snippet
140
- * TWEAKED: changed globals names
141
- * FIXED: minor changes
142
-
143
- = 1.2.4 =
144
- * FIXED: Settings lost on update
145
- * FIXED: error if logo image are not set
146
- * FIXED: it was passible to rate twice a same field in a yasr_visitor_mutliset
147
- * Minor changes
148
-
149
- = 1.2.3 =
150
- * TWEAKED: image is avaible for recipe tipe too
151
- * FIXED: inverted width and height on rich snippets
152
- * FIXED: removed rich snippets on page without ratings
153
- * FIXED: minor bugfixes
154
-
155
- = 1.2.2 =
156
- * NEW FEATURE: by default Multi Set show now a newline with average rating: it's possible to hide this simply adding the attriute show_average='no' in the shortcode
157
- * TWEAKED: google support now json-ld for reviews: so microdata have been removed from yasr, that now use only json-ld. Further this, all blogposting error have been fixed
158
- * FIXED: Multi Set cache didn't get when it was edited
159
- * TWEAK: code cleanup and bugfix
3
  Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post rating, posts, rate, rating, rating platform, rating system, ratings, review, reviews, rich snippets, seo, star, star rating, stars, vote, Votes, voting, voting contest, schema, serp
4
  Requires at least: 4.3.0
5
  Contributors: Dudo
6
+ Tested up to: 4.5.2
7
+ Stable tag: 1.3.0
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
113
 
114
  The full changelog can be found in the plugin's directory. Recent entries:
115
 
116
+ = 1.3.0 =
117
+ * NEW FEATURE: Widget support for yasr_overall_rating and yasr_visitor_votes shortcodes
118
+ * TWEAKED: Yasr shortcode creatore will appear only in backend
119
+
120
  = 1.2.9 =
121
  * NEW FEATURE: If auto insert is enabled, it's now possible to exclude the single post or page
122
  * TWEAKED: Restyling for settings panel
137
  * TWEAKED: removed unused div on yasr_most_or_highest_rated shortcode
138
  * TWEAKED: minor changes on rankings shortcodes
139
  * TWEAKED: added $rating on action yasr_action_on_visitor_vote, yasr_action_on_update_visitor_vote and yasr_action_on_overall_rating
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
yet-another-stars-rating.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Yet Another Stars Rating turn your WordPress into a complete review website.
6
- * Version: 1.2.9
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
@@ -31,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
31
 
32
  if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
 
34
- define('YASR_VERSION_NUM', '1.2.9');
35
 
36
  //Plugin relative path
37
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -223,6 +223,9 @@ require (YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php');
223
 
224
  require (YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php');
225
 
 
 
 
226
  global $wpdb;
227
 
228
  define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Yet Another Stars Rating turn your WordPress into a complete review website.
6
+ * Version: 1.3.0
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
31
 
32
  if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
 
34
+ define('YASR_VERSION_NUM', '1.3.0');
35
 
36
  //Plugin relative path
37
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
223
 
224
  require (YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php');
225
 
226
+ require (YASR_ABSOLUTE_PATH . '/lib/yasr-widgets.php');
227
+
228
+
229
  global $wpdb;
230
 
231
  define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');