Yasr – Yet Another Stars Rating - Version 0.5.1

Version Description

  • Added support for wordpress 4.0
  • Huge code cleanup in [yasr_visitor_votes]
Download this release

Release Info

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

Code changes from version 0.5.0 to 0.5.1

lib/yasr-settings-functions.php CHANGED
@@ -201,23 +201,9 @@
201
  <?php _e('Yes', 'yasr') ?>
202
  &nbsp;&nbsp;&nbsp;
203
 
204
- <input type='radio' name='yasr_general_options[text_before_stars]' value='0' id='yasr_text_before_star_off'
205
- <?php if ($option['text_before_stars']==0) {
206
- echo " checked='checked' />";
207
- echo ("<script>
208
- jQuery( document ).ready(function() {
209
- jQuery('.yasr-general-options-text-before').prop('disabled', true);
210
- });
211
- </script>") ;
212
- }
213
-
214
- else {
215
- echo "/>";
216
- }
217
-
218
- _e('No', 'yasr');
219
 
220
- ?>
221
 
222
  <br /> <br />
223
 
201
  <?php _e('Yes', 'yasr') ?>
202
  &nbsp;&nbsp;&nbsp;
203
 
204
+ <input type='radio' name='yasr_general_options[text_before_stars]' value='0' id='yasr_text_before_star_off' <?php if ($option['text_before_stars']==0) echo " checked='checked' "; ?> />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
 
206
+ <?php _e('No', 'yasr'); ?>
207
 
208
  <br /> <br />
209
 
lib/yasr-shortcode-functions.php CHANGED
@@ -59,7 +59,7 @@ function shortcode_overall_rating_callback ($atts) {
59
  if ( YASR_SHOW_OVERALL_IN_LOOP === 'disabled' ) {
60
 
61
  //If pages are not excluted
62
- if ( YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no' ) {
63
 
64
  if( is_singular() && is_main_query() ) {
65
 
@@ -70,7 +70,7 @@ function shortcode_overall_rating_callback ($atts) {
70
  }
71
 
72
  //If page are excluted
73
- else {
74
 
75
  if( is_singular() && is_main_query() && !is_page() )
76
 
@@ -84,14 +84,14 @@ function shortcode_overall_rating_callback ($atts) {
84
  elseif ( YASR_SHOW_OVERALL_IN_LOOP === 'enabled' ) {
85
 
86
  //If pages are not excluted return always
87
- if ( YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no' ) {
88
 
89
  return $shortcode_html;
90
 
91
  }
92
 
93
  //Else if page are excluted return only if is not a page
94
- else {
95
 
96
  if ( !is_page() ) {
97
 
@@ -160,352 +160,133 @@ function shortcode_visitor_votes_callback ($atts) {
160
  );
161
  }
162
 
163
- if ($size == 'small') {
164
-
165
- //if anonymous are allowed to vote
166
- if (YASR_ALLOWED_USER === 'allow_anonymous') {
167
-
168
- //I've to block a logged in user that has already rated
169
- if ( is_user_logged_in() ) {
170
-
171
- //Chek if a logged in user has already rated for this post
172
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
173
-
174
- //If user has already rated show readonly stars
175
- if ($vote_if_user_already_rated) {
176
 
177
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr-rateit-visitor-votes-logged-rated\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
178
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
179
- <strong>" . __("You've already voted this article with", "yasr") . " $vote_if_user_already_rated </strong></div>";
 
180
 
181
- }
 
 
 
 
182
 
183
- //else logged user can vote
184
- else {
185
 
186
- $vote_if_user_already_rated = 0;
 
187
 
188
- if ($votes_number>0) {
189
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
190
- <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
191
- }
192
 
193
- else {
194
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
195
- <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
196
- }
197
 
198
- } //End else
 
199
 
200
- } //End if user is logged
 
 
201
 
 
202
 
203
- //else if is not logged can vote
204
  else {
205
 
 
 
206
  if ($votes_number>0) {
207
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
208
  <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
209
  }
210
 
211
  else {
212
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
213
  <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
214
  }
215
 
216
- } //end else
217
-
218
- } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
219
-
220
-
221
- //If only logged in users can vote
222
- elseif (YASR_ALLOWED_USER === 'logged_only') {
223
 
224
- //If user is logged in and can vote
225
- if ( is_user_logged_in() ) {
226
 
227
- //Chek if a logged in user has already rated for this post
228
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
229
 
230
- if ($vote_if_user_already_rated) {
231
-
232
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr-rateit-visitor-votes-logged-rated\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
233
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
234
- <strong>" . __("You've already voted this article with", "yasr") . " $vote_if_user_already_rated </strong></div>";
235
-
236
- }
237
-
238
- else {
239
-
240
- if ($votes_number>0) {
241
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
242
- <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
243
- </div>";
244
- }
245
-
246
- else {
247
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
248
- <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
249
- </div>";
250
- }
251
-
252
- }
253
-
254
- } //End if user is logged in
255
-
256
- //Else mean user is not logged in
257
- else {
258
-
259
-
260
- if ($votes_number>0) {
261
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
262
- <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
263
- " . __("You must sign to vote", "yasr") . "</div>";
264
- }
265
-
266
- else {
267
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"16\" data-rateit-starheight=\"16\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
268
- <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>"
269
- . __("You must sign to vote", "yasr") . "</div>";
270
- }
271
 
 
 
 
272
  }
273
-
274
- }
275
-
276
- } //End if $size == 'small'
277
-
278
- elseif ($size == 'medium') {
279
-
280
- //if anonymous are allowed to vote
281
- if (YASR_ALLOWED_USER === 'allow_anonymous') {
282
-
283
- //I've to block a logged in user that has already rated
284
- if ( is_user_logged_in() ) {
285
-
286
- //Chek if a logged in user has already rated for this post
287
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
288
-
289
- //If user has already rated show readonly stars
290
- if ($vote_if_user_already_rated) {
291
-
292
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr-rateit-visitor-votes-logged-rated\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
293
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
294
- <strong>" . __("You've already voted this article with", "yasr") . " $vote_if_user_already_rated </strong></div>";
295
-
296
- }
297
-
298
- //else logged user can vote
299
- else {
300
 
301
- $vote_if_user_already_rated = 0;
302
-
303
- if ($votes_number>0) {
304
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
305
- <span class=\"yasr-total-average-text-medium\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
306
- }
307
-
308
- else {
309
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
310
- <span class=\"yasr-total-average-text-medium\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
311
- }
312
-
313
- } //End else
314
-
315
- } //End if user is logged
316
-
317
-
318
- //else if is not logged can vote
319
  else {
320
-
321
- if ($votes_number>0) {
322
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
323
- <span class=\"yasr-total-average-text-medium\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
324
- }
325
-
326
- else {
327
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
328
- <span class=\"yasr-total-average-text-medium\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
329
- }
330
-
331
- } //end else
332
-
333
- } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
334
-
335
-
336
-
337
- //If only logged in users can vote
338
- elseif (YASR_ALLOWED_USER === 'logged_only') {
339
-
340
- //If user is logged in and can vote
341
- if ( is_user_logged_in() ) {
342
-
343
- //Chek if a logged in user has already rated for this post
344
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
345
-
346
- if ($vote_if_user_already_rated) {
347
-
348
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr-rateit-visitor-votes-logged-rated\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
349
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
350
- <strong>" . __("You've already voted this article with", "yasr") . " $vote_if_user_already_rated </strong></div>";
351
-
352
- }
353
-
354
- else {
355
-
356
- if ($votes_number>0) {
357
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
358
- <span class=\"yasr-total-average-text-medium\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
359
- </div>";
360
- }
361
-
362
- else {
363
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
364
- <span class=\"yasr-total-average-text-medium\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
365
- </div>";
366
- }
367
-
368
- }
369
-
370
- } //End if user is logged in
371
-
372
- //Else mean user is not logged in
373
- else {
374
-
375
-
376
- if ($votes_number>0) {
377
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
378
- <span class=\"yasr-total-average-text-medium\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
379
- " . __("You must sign to vote", "yasr") . "</div>";
380
- }
381
-
382
- else {
383
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
384
- <span class=\"yasr-total-average-text-medium\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
385
- " . __("You must sign to vote", "yasr") . "</div>";
386
- }
387
-
388
  }
389
-
390
- }
391
-
392
- } //End if $size == 'medium'
393
-
394
- elseif ($size == 'large') {
395
-
396
- //if anonymous are allowed to vote
397
- if (YASR_ALLOWED_USER === 'allow_anonymous') {
398
-
399
- //I've to block a logged in user that has already rated
400
- if ( is_user_logged_in() ) {
401
-
402
- //Chek if a logged in user has already rated for this post
403
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
404
-
405
- //If user has already rated show readonly stars
406
- if ($vote_if_user_already_rated) {
407
-
408
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr-rateit-visitor-votes-logged-rated\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
409
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
410
- <strong>" . __("You've already voted this article with", "yasr") . " $vote_if_user_already_rated </strong></div>";
411
 
412
- }
 
 
413
 
414
- //else logged user can vote
415
- else {
416
 
417
- $vote_if_user_already_rated = 0;
 
418
 
419
- if ($votes_number>0) {
420
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
421
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
422
- }
423
 
424
- else {
425
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
426
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
427
- }
428
 
429
- } //End else
430
 
431
- } //End if user is logged
 
 
432
 
 
433
 
434
- //else if is not logged can vote
435
  else {
436
 
437
  if ($votes_number>0) {
438
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
439
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
 
440
  }
441
 
442
  else {
443
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
444
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
445
- }
446
-
447
- } //end else
448
-
449
- } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
450
-
451
-
452
-
453
- //If only logged in users can vote
454
- elseif (YASR_ALLOWED_USER === 'logged_only') {
455
-
456
- //If user is logged in and can vote
457
- if ( is_user_logged_in() ) {
458
-
459
- //Chek if a logged in user has already rated for this post
460
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
461
-
462
- if ($vote_if_user_already_rated) {
463
-
464
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr-rateit-visitor-votes-logged-rated\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
465
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
466
- <strong>" . __("You've already voted this article with", "yasr") . " $vote_if_user_already_rated </strong></div>";
467
-
468
  }
469
 
470
- else {
471
 
472
- if ($votes_number>0) {
473
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
474
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
475
- </div>";
476
- }
477
 
478
- else {
479
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
480
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
481
- </div>";
482
- }
483
 
484
- }
485
 
486
- } //End if user is logged in
 
 
 
 
487
 
488
- //Else mean user is not logged in
489
  else {
490
-
491
-
492
- if ($votes_number>0) {
493
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
494
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
495
- " . __("You must sign to vote", "yasr") . "</div>";
496
- }
497
-
498
- else {
499
- $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
500
- <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
501
- " . __("You must sign to vote", "yasr") . "</div>";
502
- }
503
-
504
  }
505
-
506
- }
507
 
508
- } //End if $size == 'large'
 
 
509
 
510
  if(YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_VISITOR_RATING != '') {
511
 
59
  if ( YASR_SHOW_OVERALL_IN_LOOP === 'disabled' ) {
60
 
61
  //If pages are not excluted
62
+ if ( YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no' ) {
63
 
64
  if( is_singular() && is_main_query() ) {
65
 
70
  }
71
 
72
  //If page are excluted
73
+ elseif ( YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_EXCLUDE_PAGES === 'yes' ) {
74
 
75
  if( is_singular() && is_main_query() && !is_page() )
76
 
84
  elseif ( YASR_SHOW_OVERALL_IN_LOOP === 'enabled' ) {
85
 
86
  //If pages are not excluted return always
87
+ if (YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no' ) {
88
 
89
  return $shortcode_html;
90
 
91
  }
92
 
93
  //Else if page are excluted return only if is not a page
94
+ elseif ( YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_EXCLUDE_PAGES === 'yes' ) {
95
 
96
  if ( !is_page() ) {
97
 
160
  );
161
  }
162
 
163
+ if ($size === 'small') {
164
+ $rateit_class='rateit';
165
+ $px_size = '16';
166
+ }
 
 
 
 
 
 
 
 
 
167
 
168
+ elseif ($size === 'medium') {
169
+ $rateit_class = 'rateit medium';
170
+ $px_size = '24';
171
+ }
172
 
173
+ //default values
174
+ else {
175
+ $rateit_class = 'rateit bigstars';
176
+ $px_size = '32';
177
+ }
178
 
 
 
179
 
180
+ //if anonymous are allowed to vote
181
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
182
 
183
+ //I've to block a logged in user that has already rated
184
+ if ( is_user_logged_in() ) {
 
 
185
 
186
+ //Chek if a logged in user has already rated for this post
187
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
 
 
188
 
189
+ //If user has already rated show readonly stars
190
+ if ($vote_if_user_already_rated) {
191
 
192
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr-rateit-visitor-votes-logged-rated\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
193
+ <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
194
+ <strong>" . __("You've already voted this article with", "yasr") . " $vote_if_user_already_rated </strong></div>";
195
 
196
+ }
197
 
198
+ //else logged user can vote
199
  else {
200
 
201
+ $vote_if_user_already_rated = 0;
202
+
203
  if ($votes_number>0) {
204
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
205
  <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
206
  }
207
 
208
  else {
209
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
210
  <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
211
  }
212
 
213
+ } //End else
 
 
 
 
 
 
214
 
215
+ } //End if user is logged
 
216
 
 
 
217
 
218
+ //else if is not logged can vote
219
+ else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
+ if ($votes_number>0) {
222
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
223
+ <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
224
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  else {
227
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
228
+ <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span></div>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
 
231
+ } //end else
232
+
233
+ } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
234
 
 
 
235
 
236
+ //If only logged in users can vote
237
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
238
 
239
+ //If user is logged in and can vote
240
+ if ( is_user_logged_in() ) {
 
 
241
 
242
+ //Chek if a logged in user has already rated for this post
243
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
 
 
244
 
245
+ if ($vote_if_user_already_rated) {
246
 
247
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr-rateit-visitor-votes-logged-rated\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
248
+ <span class=\"yasr-total-average-text\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
249
+ <strong>" . __("You've already voted this article with", "yasr") . " $vote_if_user_already_rated </strong></div>";
250
 
251
+ }
252
 
 
253
  else {
254
 
255
  if ($votes_number>0) {
256
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
257
+ <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
258
+ </div>";
259
  }
260
 
261
  else {
262
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
263
+ <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
264
+ </div>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  }
266
 
267
+ }
268
 
269
+ } //End if user is logged in
 
 
 
 
270
 
271
+ //Else mean user is not logged in
272
+ else {
 
 
 
273
 
 
274
 
275
+ if ($votes_number>0) {
276
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
277
+ <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>
278
+ " . __("You must sign to vote", "yasr") . "</div>";
279
+ }
280
 
 
281
  else {
282
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"$rateit_class\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
283
+ <span class=\"yasr-total-average-text-small\"> [" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average: ","yasr") . "$medium_rating/5]</span>"
284
+ . __("You must sign to vote", "yasr") . "</div>";
 
 
 
 
 
 
 
 
 
 
 
285
  }
 
 
286
 
287
+ }
288
+
289
+ }
290
 
291
  if(YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_VISITOR_RATING != '') {
292
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
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: 3.5
5
- Tested up to: 3.9.1
6
- Stable tag: 0.5.0
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -83,6 +83,10 @@ Of course not: you can easily add it on the visual editor just by clicking on th
83
 
84
  == Changelog ==
85
 
 
 
 
 
86
  = 0.5.0 =
87
  * New feature: added auto insert for custom post types only (you will see this only if you use custom post types)
88
  * Various bugfixes
2
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
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: 3.5
5
+ Tested up to: 4.0
6
+ Stable tag: 0.5.1
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
83
 
84
  == Changelog ==
85
 
86
+ = 0.5.1 =
87
+ * Added support for wordpress 4.0
88
+ * Huge code cleanup in [yasr_visitor_votes]
89
+
90
  = 0.5.0 =
91
  * New feature: added auto insert for custom post types only (you will see this only if you use custom post types)
92
  * Various bugfixes
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: Rating system with rich snippets
6
- * Version: 0.5.0
7
  * Author: Dario Curvino
8
  * Author URI: http://profiles.wordpress.org/dudo/
9
  * License: GPL2
@@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
28
  */
29
 
30
 
31
- define('YASR_VERSION_NUM', '0.5.0');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Rating system with rich snippets
6
+ * Version: 0.5.1
7
  * Author: Dario Curvino
8
  * Author URI: http://profiles.wordpress.org/dudo/
9
  * License: GPL2
28
  */
29
 
30
 
31
+ define('YASR_VERSION_NUM', '0.5.1');
32
 
33
  //Plugin absolute path
34
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );