Yasr – Yet Another Stars Rating - Version 0.4.1

Version Description

  • Added 2 sizes for "overall_rating" and "visitor_votes" stars sets, now you can choose between 16px, 24px and 32px (default)
  • MANY code changes: it should be a little faster
  • Fixed typo errors
Download this release

Release Info

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

Code changes from version 0.4.0 to 0.4.1

css/bigstars.css CHANGED
@@ -13,11 +13,13 @@ div.bigstars div.rateit-range
13
div.bigstars div.rateit-hover
14
{
15
background: url('../img/star-gold32.png');
16
}
17
18
div.bigstars div.rateit-selected
19
{
20
background: url('../img/star-red32.png');
21
}
22
23
div.bigstars div.rateit-reset
@@ -31,6 +33,7 @@ div.bigstars div.rateit-reset
31
div.bigstars div.rateit-reset:hover
32
{
33
background: url('../img/star-white32.png');
34
}
35
36
@@ -38,24 +41,24 @@ div.bigstars div.rateit-reset:hover
38
39
/* Creating set 24px image with yellow color read only. Used in charts */
40
41
- div.charts div.rateit-range
42
{
43
44
background: url('../img/star-white24.png');
45
height: 24px;
46
}
47
48
- div.charts div.rateit-hover
49
{
50
background: url('../img/star-gold24.png');
51
}
52
53
- div.charts div.rateit-selected
54
{
55
background: url('../img/star-gold24.png');
56
}
57
58
- div.charts div.rateit-reset
59
{
60
background: url('../img/star-black24.png');
61
width: 24px;
@@ -63,7 +66,7 @@ div.charts div.rateit-reset
63
64
}
65
66
- div.charts div.rateit-reset:hover
67
{
68
background: url('../img/star-white24.png');
69
- }
13
div.bigstars div.rateit-hover
14
{
15
background: url('../img/star-gold32.png');
16
+ height: 32px;
17
}
18
19
div.bigstars div.rateit-selected
20
{
21
background: url('../img/star-red32.png');
22
+ height: 32px;
23
}
24
25
div.bigstars div.rateit-reset
33
div.bigstars div.rateit-reset:hover
34
{
35
background: url('../img/star-white32.png');
36
+ height: 32px;
37
}
38
39
41
42
/* Creating set 24px image with yellow color read only. Used in charts */
43
44
+ div.medium div.rateit-range
45
{
46
47
background: url('../img/star-white24.png');
48
height: 24px;
49
}
50
51
+ div.medium div.rateit-hover
52
{
53
background: url('../img/star-gold24.png');
54
}
55
56
+ div.medium div.rateit-selected
57
{
58
background: url('../img/star-gold24.png');
59
}
60
61
+ div.medium div.rateit-reset
62
{
63
background: url('../img/star-black24.png');
64
width: 24px;
66
67
}
68
69
+ div.medium div.rateit-reset:hover
70
{
71
background: url('../img/star-white24.png');
72
+ }
css/yasr.css CHANGED
@@ -81,6 +81,23 @@
81
}
82
}
83
84
#yasr-color-scheme-preview {
85
border: 2px dashed #CCC;
86
padding: 15px;
@@ -241,8 +258,31 @@
241
242
/*** Popup in tinymce ***/
243
244
245
246
247
248
#yasr-log-container {
@@ -252,7 +292,6 @@
252
.yasr-log-div-child {
253
padding-top: 5px;
254
border-bottom: 1px solid #BBD8E7;
255
- padding-bottom: 20px;
256
}
257
258
#yasr-log-image {
@@ -324,3 +363,15 @@
324
display: inline-block;
325
vertical-align: top;
326
}
81
}
82
}
83
84
+ .yasr-option-size {
85
+ vertical-align: bottom;
86
+ display: block;
87
+ margin-bottom: 15px;
88
+ }
89
+
90
+ .yasr-img-option-size {
91
+ height: 30px;
92
+ vertical-align: middle;
93
+ }
94
+
95
+ .yasr-text-options-size {
96
+ height: 30px;
97
+ vertical-align: middle;
98
+ padding-left: 8px;
99
+ }
100
+
101
#yasr-color-scheme-preview {
102
border: 2px dashed #CCC;
103
padding: 15px;
258
259
/*** Popup in tinymce ***/
260
261
+ #yasr-overall-choose-size {
262
+ display: none;
263
+ margin-top: 20px;
264
+ border: 2px dashed #CCC;
265
+ padding-bottom: 10px;
266
+ margin-left: 8px;
267
+ padding-left: 8px;
268
+ }
269
+
270
+ .yasr-tinymce-button-size {
271
+ padding-top: 5px;
272
+ }
273
+
274
+ #yasr-visitor-choose-size {
275
+ display: none;
276
+ margin-top: 20px;
277
+ border: 2px dashed #CCC;
278
+ padding-bottom: 10px;
279
+ margin-left: 8px;
280
+ padding-left: 8px;
281
+ }
282
283
284
+ /*** End popup tinymce***/
285
+
286
287
288
#yasr-log-container {
292
.yasr-log-div-child {
293
padding-top: 5px;
294
border-bottom: 1px solid #BBD8E7;
295
}
296
297
#yasr-log-image {
363
display: inline-block;
364
vertical-align: top;
365
}
366
+
367
+ .yasr-total-average-text {
368
+ display: block;
369
+ }
370
+
371
+ .yasr-total-average-text-medium {
372
+ display: block;
373
+ }
374
+
375
+ .yasr-visitor-shortcode-small-already-voted-text{
376
+ display: block;
377
+ }
img/yasr-stars-large.png ADDED
Binary file
img/yasr-stars-medium.png ADDED
Binary file
img/yasr-stars-small.png ADDED
Binary file
lib/yasr-ajax-functions.php CHANGED
@@ -332,15 +332,41 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
332
<div id="yasr-content-tab-main">
333
334
<table id="yasr-table-tiny-popup-main" class="form-table">
335
<tr>
336
<th><label for="yasr-overall"><?php _e("Overall Rating / Review"); ?></label></th>
337
- <td><input type="button" class="button-primary" id="yasr-overall" name="yasr-overall" value="Insert Overall Rating" /><br />
338
- <small><?php _e("Insert Overall Rating / Review for this post"); ?></small></td>
339
</tr>
340
<tr>
341
<th><label for="yasr-id"><?php _e("Visitor Votes"); ?></label></th>
342
- <td><input type="button" class="button-primary" name="yasr-visitor-votes" id="yasr-visitor-votes" value="Insert Visitor Votes"/><br />
343
- <small><?php _e("Insert the ability for your visitor to vote"); ?></small></td>
344
</tr>
345
346
<?php if ($n_multi_set>1) { //If multiple Set are found ?>
@@ -432,24 +458,64 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
432
433
});
434
435
- // Add shortcode for overall rating
436
jQuery('#yasr-overall').on("click", function(){
437
- var shortcode = '[yasr_overall_rating]';
438
- // inserts the shortcode into the active editor
439
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
440
- // closes jqueryui
441
- jQuery('#yasr-tinypopup-form').dialog('close');
442
});
443
444
//Add shortcode for visitors rating
445
jQuery('#yasr-visitor-votes').on("click", function(){
446
- var shortcode = '[yasr_visitor_votes]';
447
- // inserts the shortcode into the active editor
448
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
449
- // closes Thickbox
450
- jQuery('#yasr-tinypopup-form').dialog('close');
451
});
452
453
<?php if ($n_multi_set>1) { ?>
454
455
//Add shortcode for multiple set
@@ -916,14 +982,16 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
916
917
if($row_exists_result) {
918
$total_rating = ($user_votes_sum / $number_of_votes);
919
- $total_rating=round ($total_rating, 1);
920
echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$total_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
921
- <br /><strong>" . __("Vote Saved" , "yasr") . "</strong><br />" . __("Average Rating", "yasr") . " $total_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")";
922
}
923
924
elseif ($new_row_result) {
925
echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
926
- <br /><strong>". __("Vote Saved" , "yasr") . "</strong><br />Rating $rating / 5 (1 " . __("vote cast", "yasr") . ")";
927
}
928
929
die(); // this is required to return a proper result
@@ -949,19 +1017,20 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
949
950
951
//Check if user specifyed a custom text to display when a vistor har rated
952
- $option = get_option('yasr_general_options');
953
954
- if($option['text_before_stars'] == 1 && $option['custom_text_user_voted'] != '') {
955
956
echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
957
- <br />" . __("Average Rating", "yasr") . " $average_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")<strong><br /> $option[custom_text_user_voted] </strong>";
958
959
}
960
961
else {
962
963
echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
964
- <br />" . __("Average Rating", "yasr") . " $average_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")<strong><br />" . __("You've already voted this article with $rating", "yasr") . "</strong>";
965
966
}
967
@@ -1026,7 +1095,7 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
1026
1027
echo ( "<tr>
1028
<td width=\"60%\"><a href=\"$link\">$post_title</a></td>
1029
- <td width=\"40%\"><div id=\"yasr_visitor_votes\"><div class=\"rateit charts\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1030
<br /> [" . __("Total:" , "yasr") . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , "yasr") . " $rating]</td>
1031
</tr>"
1032
@@ -1071,7 +1140,7 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
1071
1072
echo ("<tr>
1073
<td width=\"60%\"><a href=\"$link\">$post_title</a></td>
1074
- <td width=\"40%\"><div id=\"yasr_visitor_votes\"><div class=\"rateit charts\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1075
<br /> [" . __("Total:" , "yasr") . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , "yasr") . " $rating]</td>
1076
</tr>");
1077
332
<div id="yasr-content-tab-main">
333
334
<table id="yasr-table-tiny-popup-main" class="form-table">
335
+
336
<tr>
337
<th><label for="yasr-overall"><?php _e("Overall Rating / Review"); ?></label></th>
338
+ <td>
339
+ <input type="button" class="button-primary" id="yasr-overall" name="yasr-overall" value="Insert Overall Rating" /><br />
340
+ <small><?php _e("Insert Overall Rating / Review for this post"); ?></small>
341
+
342
+ <div id="yasr-overall-choose-size">
343
+ <small><?php _e("Choose Size"); ?><small>
344
+ <div class="yasr-tinymce-button-size">
345
+ <input type="button" class="button-secondary" id="yasr-overall-insert-small" name="yasr-overall-insert-small" value="Small" />
346
+ <input type="button" class="button-secondary" id="yasr-overall-insert-medium" name="yasr-overall-insert-medium" value="Medium" />
347
+ <input type="button" class="button-secondary" id="yasr-overall-insert-large" name="yasr-overall-insert-large" value="Large" />
348
+ </div>
349
+ </div>
350
+
351
+ </td>
352
</tr>
353
+
354
<tr>
355
<th><label for="yasr-id"><?php _e("Visitor Votes"); ?></label></th>
356
+ <td>
357
+ <input type="button" class="button-primary" name="yasr-visitor-votes" id="yasr-visitor-votes" value="Insert Visitor Votes"/><br />
358
+ <small><?php _e("Insert the ability for your visitor to vote"); ?></small>
359
+
360
+ <div id="yasr-visitor-choose-size">
361
+ <small><?php _e("Choose Size"); ?><small>
362
+ <div class="yasr-tinymce-button-size">
363
+ <input type="button" class="button-secondary" id="yasr-visitor-insert-small" name="yasr-visitor-insert-small" value="Small" />
364
+ <input type="button" class="button-secondary" id="yasr-visitor-insert-medium" name="yasr-visitor-insert-medium" value="Medium" />
365
+ <input type="button" class="button-secondary" id="yasr-visitor-insert-large" name="yasr-visitor-insert-large" value="Large" />
366
+ </div>
367
+ </div>
368
+
369
+ </td>
370
</tr>
371
372
<?php if ($n_multi_set>1) { //If multiple Set are found ?>
458
459
});
460
461
+ // Add shortcode for overall rating
462
jQuery('#yasr-overall').on("click", function(){
463
+ jQuery('#yasr-overall-choose-size').toggle('slow');
464
});
465
466
+ jQuery('#yasr-overall-insert-small').on("click", function(){
467
+ var shortcode = '[yasr_overall_rating size="small"]';
468
+ // inserts the shortcode into the active editor
469
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
470
+ // closes jqueryui
471
+ jQuery('#yasr-tinypopup-form').dialog('close');
472
+ });
473
+
474
+ jQuery('#yasr-overall-insert-medium').on("click", function(){
475
+ var shortcode = '[yasr_overall_rating size="medium"]';
476
+ // inserts the shortcode into the active editor
477
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
478
+ // closes jqueryui
479
+ jQuery('#yasr-tinypopup-form').dialog('close');
480
+ });
481
+
482
+ jQuery('#yasr-overall-insert-large').on("click", function(){
483
+ var shortcode = '[yasr_overall_rating size="large"]';
484
+ // inserts the shortcode into the active editor
485
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
486
+ // closes jqueryui
487
+ jQuery('#yasr-tinypopup-form').dialog('close');
488
+ });
489
+
490
//Add shortcode for visitors rating
491
jQuery('#yasr-visitor-votes').on("click", function(){
492
+ jQuery('#yasr-visitor-choose-size').toggle('slow');
493
});
494
495
+ jQuery('#yasr-visitor-insert-small').on("click", function(){
496
+ var shortcode = '[yasr_visitor_votes size="small"]';
497
+ // inserts the shortcode into the active editor
498
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
499
+ // closes Thickbox
500
+ jQuery('#yasr-tinypopup-form').dialog('close');
501
+ });
502
+
503
+ jQuery('#yasr-visitor-insert-medium').on("click", function(){
504
+ var shortcode = '[yasr_visitor_votes size="medium"]';
505
+ // inserts the shortcode into the active editor
506
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
507
+ // closes Thickbox
508
+ jQuery('#yasr-tinypopup-form').dialog('close');
509
+ });
510
+
511
+ jQuery('#yasr-visitor-insert-large').on("click", function(){
512
+ var shortcode = '[yasr_visitor_votes size="large"]';
513
+ // inserts the shortcode into the active editor
514
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
515
+ // closes Thickbox
516
+ jQuery('#yasr-tinypopup-form').dialog('close');
517
+ });
518
+
519
<?php if ($n_multi_set>1) { ?>
520
521
//Add shortcode for multiple set
982
983
if($row_exists_result) {
984
$total_rating = ($user_votes_sum / $number_of_votes);
985
+ $medium_rating=round ($total_rating, 1);
986
echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$total_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
987
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$number_of_votes &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
988
+ <strong>" . __("Vote Saved" , "yasr") . "</strong>";
989
}
990
991
elseif ($new_row_result) {
992
echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
993
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$number_of_votes &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
994
+ <strong>". __("Vote Saved" , "yasr");
995
}
996
997
die(); // this is required to return a proper result
1017
1018
1019
//Check if user specifyed a custom text to display when a vistor har rated
1020
1021
+ if( YASR_TEXT_BEFORE_STARS == 1 && YASR_CUSTOM_TEXT_USER_VOTED != '' ) {
1022
1023
echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1024
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$number_of_votes &nbsp; &nbsp;" . __("Average $average_rating/5" , "yasr") . "]</span>
1025
+ <strong>" . YASR_CUSTOM_TEXT_USER_VOTED . " </strong>";
1026
1027
}
1028
1029
else {
1030
1031
echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1032
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$number_of_votes &nbsp; &nbsp;" . __("Average $average_rating/5" , "yasr") . "]</span>
1033
+ <strong>" . __("You've already voted this article with $rating", "yasr") . "</strong>";
1034
1035
}
1036
1095
1096
echo ( "<tr>
1097
<td width=\"60%\"><a href=\"$link\">$post_title</a></td>
1098
+ <td width=\"40%\"><div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1099
<br /> [" . __("Total:" , "yasr") . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , "yasr") . " $rating]</td>
1100
</tr>"
1101
1140
1141
echo ("<tr>
1142
<td width=\"60%\"><a href=\"$link\">$post_title</a></td>
1143
+ <td width=\"40%\"><div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1144
<br /> [" . __("Total:" , "yasr") . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , "yasr") . " $rating]</td>
1145
</tr>");
1146
lib/yasr-db-functions.php CHANGED
@@ -81,6 +81,7 @@ function yasr_install() {
81
$option['auto_insert_enabled'] = 0;
82
$option['auto_insert_what'] = 'overall_rating';
83
$option['auto_insert_where'] = 'top';
84
$option['auto_insert_exclude_pages'] = 'yes';
85
$option['show_overall_in_loop'] = 'disabled';
86
$option['text_before_stars'] = 0;
81
$option['auto_insert_enabled'] = 0;
82
$option['auto_insert_what'] = 'overall_rating';
83
$option['auto_insert_where'] = 'top';
84
+ $option['auto_insert_size']='large';
85
$option['auto_insert_exclude_pages'] = 'yes';
86
$option['show_overall_in_loop'] = 'disabled';
87
$option['text_before_stars'] = 0;
lib/yasr-functions.php CHANGED
@@ -14,22 +14,13 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
14
wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', array('rateitcss'), NULL, 'all' );
15
wp_enqueue_style( 'jqueryui', YASR_CSS_DIR . 'jquery-ui.min.css', FALSE, NULL, 'all' );
16
17
- $chosen_color=NULL;
18
-
19
- $chosen_color = get_option( 'yasr_general_options' );
20
-
21
- //default color
22
- if(!$chosen_color || !$chosen_color['scheme_color'] ) {
23
- $chosen_color = array();
24
- $chosen_color['scheme_color'] = 'light';
25
- }
26
27
//If choosen is light or not dark (force to be default)
28
- if ($chosen_color['scheme_color'] === 'light' || $chosen_color['scheme_color'] != 'dark' ) {
29
wp_enqueue_style( 'yasrcsslightscheme', YASR_CSS_DIR . 'yasr-table-light.css', array('yasrcss'), NULL, 'all' );
30
}
31
32
- elseif ($chosen_color['scheme_color'] === 'dark') {
33
wp_enqueue_style( 'yasrcssdarkscheme', YASR_CSS_DIR . 'yasr-table-dark.css', array('yasrcss'), NULL, 'all' );
34
}
35
@@ -133,71 +124,84 @@ function overall_rating_auto_insert_code () {
133
$overall_rating = "-1";
134
}
135
136
- $option = get_option( 'yasr_general_options' );
137
138
- if($option['text_before_stars'] == 1 && $option['text_before_overall'] != '') {
139
- $shortcode_html = "<div class=\"yasr-container-custom-text-and-overall\">
140
- <span id=\"yasr-custom-text-before-overall\">$option[text_before_overall]</span>
141
- <div class=\"rateit bigstars\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
142
- </div>
143
- </div>";
144
- }
145
146
- else {
147
148
- $shortcode_html="<div class=\"rateit bigstars\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
149
- </div>";
150
151
- }
152
153
- //IF show overall rating in loop is disabled use is_singular && is_main query
154
- if ($option['show_overall_in_loop'] === 'disabled') {
155
156
- //If pages are not excluted
157
- if ($option['auto_insert_exclude_pages'] === 'no') {
158
159
- if( is_singular() && is_main_query() ) {
160
161
- return $shortcode_html;
162
163
- }
164
165
- }
166
167
- //If page are excluted
168
- else {
169
170
- if( is_singular() && is_main_query() && !is_page() )
171
172
- return $shortcode_html;
173
174
}
175
176
- } // End if ($option['show_overall_in_loop'] === 'disabled') {
177
178
- //If overall rating in loop is enabled don't use is_singular && is main_query
179
- elseif ($option['show_overall_in_loop'] === 'enabled') {
180
181
- //If pages are not excluted return always
182
- if ($option['auto_insert_exclude_pages'] === 'no') {
183
184
return $shortcode_html;
185
186
- }
187
188
- //Else if page are excluted return only if is not a page
189
- else {
190
191
- if ( !is_page() ) {
192
193
- return $shortcode_html;
194
195
- }
196
197
}
198
199
}
200
201
} //End function
202
203
@@ -208,9 +212,7 @@ is called and have initial different conditions ******/
208
209
function visitor_votes_auto_insert_code () {
210
211
- $option = get_option( 'yasr_general_options' );
212
-
213
- $shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
214
215
if( is_singular() && is_main_query() ) {
216
@@ -234,16 +236,6 @@ function visitor_votes_auto_insert_code () {
234
}
235
}
236
237
- $option = get_option( 'yasr_general_options' );
238
-
239
- if ( !$option ) {
240
- $allow_logged_option = array();
241
- $allow_logged_option['allowed_user']='allow_anonymous';
242
- }
243
-
244
- else {
245
- $allow_logged_option = $option;
246
- }
247
248
$image = YASR_IMG_DIR . "/loader.gif";
249
@@ -251,85 +243,281 @@ function visitor_votes_auto_insert_code () {
251
252
$medium_rating=round($medium_rating, 1);
253
254
255
- //if anonymous are allowed to vote
256
- if ($allow_logged_option['allowed_user']==='allow_anonymous') {
257
258
- //I've to block a logged in user that has already rated
259
- if ( is_user_logged_in() ) {
260
261
- //Chek if a logged in user has already rated for this post
262
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
263
264
- //If user has already rated show readonly stars
265
- if ($vote_if_user_already_rated) {
266
267
- global $current_user;
268
- get_currentuserinfo();
269
270
- $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=\"true\">
271
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
272
273
- }
274
275
- //else logged user can vote
276
- else {
277
278
- $vote_if_user_already_rated = 0;
279
280
if ($votes_number>0) {
281
- $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\">
282
</div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
283
}
284
285
else {
286
- $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\">
287
</div><br /> " . __("No rating yet" , "yasr") . "</div>";
288
}
289
290
- } //End else
291
292
- } //End if user is logged
293
294
295
- //else is not logged can vote
296
- else {
297
298
- if ($votes_number>0) {
299
- $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\">
300
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
301
- }
302
303
else {
304
- $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\">
305
- </div><br /> " . __("No rating yet" , "yasr") . "</div>";
306
}
307
308
- } //end else
309
-
310
- } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
311
312
313
314
- //If only logged in users can vote
315
- elseif ($allow_logged_option['allowed_user']==='logged_only') {
316
317
- //If user is logged in and can vote
318
- if ( is_user_logged_in() ) {
319
320
- //Chek if a logged in user has already rated for this post
321
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
322
323
- if ($vote_if_user_already_rated) {
324
325
- global $current_user;
326
- get_currentuserinfo();
327
328
- $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=\"true\">
329
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
330
331
}
332
333
else {
334
335
if ($votes_number>0) {
@@ -342,33 +530,71 @@ function visitor_votes_auto_insert_code () {
342
</div><br /> " . __("No rating yet" , "yasr") . "</div>";
343
}
344
345
- }
346
347
348
- } //End if user is logged in
349
350
- //Else mean user is not logged in
351
- else {
352
353
- if ($votes_number>0) {
354
- $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\">
355
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br />" . __("You must sign to vote", "yasr") . "</div>";
356
- }
357
358
else {
359
- $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\">
360
- </div><br /> " . __("No rating yet" , "yasr") . "<br />" . __("You must sign to vote", "") . "</div>";
361
}
362
363
- }
364
-
365
- } //end ($allow_logged_option['allowed_user']==='logged_only')
366
367
368
- if($option['text_before_stars'] == 1 && $option['text_before_visitor_rating'] != '') {
369
370
$shortcode_html_tmp = "<div class=\"yasr-container-custom-text-and-visitor-rating\">
371
- <div id=\"yasr-custom-text-before-visitor-rating\">$option[text_before_visitor_rating]</div>" . $shortcode_html . "</div>";
372
373
$shortcode_html = $shortcode_html_tmp;
374
@@ -456,7 +682,7 @@ function visitor_votes_auto_insert_code () {
456
457
<?php
458
459
- if ($option['auto_insert_exclude_pages'] === 'no') {
460
461
return $shortcode_html;
462
@@ -484,17 +710,15 @@ function visitor_votes_auto_insert_code () {
484
485
function yasr_auto_insert_shortcode_callback($content) {
486
487
- $option = get_option( 'yasr_general_options' );
488
-
489
- if ($option['auto_insert_enabled'] == 1) {
490
491
$auto_insert_shortcode=NULL; //To avoid undefined variable notice outside the loop (if (is_singular) )
492
493
$overall_rating_code = overall_rating_auto_insert_code();
494
$visitor_votes_code = visitor_votes_auto_insert_code();
495
496
- if ($option['auto_insert_what']==='overall_rating') {
497
- switch ($option['auto_insert_where']) {
498
case 'top':
499
return $overall_rating_code . $content;
500
break;
@@ -503,10 +727,10 @@ function visitor_votes_auto_insert_code () {
503
return $content . $overall_rating_code;
504
break;
505
} //End Switch
506
- } //end ($option['what']=='overall_rating')
507
508
- elseif ($option['auto_insert_what']==='visitor_rating') {
509
- switch ($option['auto_insert_where']) {
510
case 'top':
511
return $visitor_votes_code . $content;
512
break;
@@ -517,8 +741,8 @@ function visitor_votes_auto_insert_code () {
517
} //End Switch
518
}
519
520
- elseif ($option['auto_insert_what']==='both') {
521
- switch ($option['auto_insert_where']) {
522
case 'top':
523
return $overall_rating_code . $visitor_votes_code . $content;
524
break;
@@ -531,12 +755,15 @@ function visitor_votes_auto_insert_code () {
531
532
return $content;
533
534
- } //End if ($option['enabled'] == 1)
535
536
else {
537
return $content;
538
}
539
540
} //End function yasr_auto_insert_shortcode_callback
541
542
@@ -548,14 +775,7 @@ function visitor_votes_auto_insert_code () {
548
549
$schema=NULL; //To avoid undefined variable notice outside the loop
550
551
- $choosen_snippet = get_option( 'yasr_general_options' );
552
-
553
- if(!$choosen_snippet) {
554
- $choosen_snippet = array();
555
- $choosen_snippet['snippet'] = 'overall_rating';
556
- }
557
-
558
- if ($choosen_snippet['snippet'] == 'overall_rating') {
559
560
$overall_rating=yasr_get_overall_rating();
561
@@ -586,7 +806,7 @@ function visitor_votes_auto_insert_code () {
586
587
} //end if ($choosen_snippet['snippet'] == 'overall_rating')
588
589
- if ($choosen_snippet['snippet'] == 'visitor_rating') {
590
591
$visitor_rating = yasr_get_vistor_rating();
592
14
wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', array('rateitcss'), NULL, 'all' );
15
wp_enqueue_style( 'jqueryui', YASR_CSS_DIR . 'jquery-ui.min.css', FALSE, NULL, 'all' );
16
17
18
//If choosen is light or not dark (force to be default)
19
+ if (YASR_SCHEME_COLOR === 'light' || YASR_SCHEME_COLOR != 'dark' ) {
20
wp_enqueue_style( 'yasrcsslightscheme', YASR_CSS_DIR . 'yasr-table-light.css', array('yasrcss'), NULL, 'all' );
21
}
22
23
+ elseif (YASR_SCHEME_COLOR === 'dark') {
24
wp_enqueue_style( 'yasrcssdarkscheme', YASR_CSS_DIR . 'yasr-table-dark.css', array('yasrcss'), NULL, 'all' );
25
}
26
124
$overall_rating = "-1";
125
}
126
127
+ $shortcode_html = '';
128
129
+ if( YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_STARS != '' ) {
130
131
+ $shortcode_html = "<div class=\"yasr-container-custom-text-and-overall\">
132
+ <span id=\"yasr-custom-text-before-overall\">" . YASR_TEXT_BEFORE_OVERALL . "</span>";
133
134
+ }
135
136
+ switch (YASR_AUTO_INSERT_SIZE) {
137
+ case 'small':
138
+ $shortcode_html .= "<div class=\"rateit\" id=\"yasr_rateit_overall\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
139
+ break;
140
141
+ case 'medium':
142
+ $shortcode_html .= "<div class=\"rateit medium\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
143
+ break;
144
145
+ case 'large':
146
+ $shortcode_html .= "<div class=\"rateit bigstars\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
147
+ break;
148
+ }
149
150
+ if( YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_STARS != '' ) {
151
152
+ $shortcode_html .= "</div>";
153
154
+ }
155
156
157
+ //IF show overall rating in loop is disabled use is_singular && is_main query
158
+ if ( YASR_SHOW_OVERALL_IN_LOOP === 'disabled' ) {
159
160
+ //If pages are not excluted
161
+ if ( YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no' ) {
162
163
+ if( is_singular() && is_main_query() ) {
164
+
165
+ return $shortcode_html;
166
167
}
168
169
+ }
170
171
+ //If page are excluted
172
+ else {
173
174
+ if( is_singular() && is_main_query() && !is_page() )
175
176
return $shortcode_html;
177
178
+ }
179
180
+ } // End if YASR_SHOW_OVERALL_IN_LOOP === 'disabled') {
181
182
+ //If overall rating in loop is enabled don't use is_singular && is main_query
183
+ elseif ( YASR_SHOW_OVERALL_IN_LOOP === 'enabled' ) {
184
185
+ //If pages are not excluted return always
186
+ if ( YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no' ) {
187
188
+ return $shortcode_html;
189
+
190
+ }
191
+
192
+ //Else if page are excluted return only if is not a page
193
+ else {
194
+
195
+ if ( !is_page() ) {
196
+
197
+ return $shortcode_html;
198
199
}
200
201
}
202
203
+ }
204
+
205
} //End function
206
207
212
213
function visitor_votes_auto_insert_code () {
214
215
+ $shortcode_html = ''; //Avoid undefined variable outside is_singular && is_main_query
216
217
if( is_singular() && is_main_query() ) {
218
236
}
237
}
238
239
240
$image = YASR_IMG_DIR . "/loader.gif";
241
243
244
$medium_rating=round($medium_rating, 1);
245
246
+ if (YASR_AUTO_INSERT_SIZE === 'small') {
247
248
+ //if anonymous are allowed to vote
249
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
250
251
+ //I've to block a logged in user that has already rated
252
+ if ( is_user_logged_in() ) {
253
254
+ //Chek if a logged in user has already rated for this post
255
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
256
257
+ //If user has already rated show readonly stars
258
+ if ($vote_if_user_already_rated) {
259
260
+ global $current_user;
261
+ get_currentuserinfo();
262
263
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes_logged_rated\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
264
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
265
266
+ }
267
268
+ //else logged user can vote
269
+ else {
270
+
271
+ $vote_if_user_already_rated = 0;
272
273
+ if ($votes_number>0) {
274
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
275
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
276
+ }
277
+
278
+ else {
279
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
280
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
281
+ }
282
+
283
+ } //End else
284
+
285
+ } //End if user is logged
286
+
287
+
288
+ //else is not logged can vote
289
+ else {
290
291
if ($votes_number>0) {
292
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
293
</div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
294
}
295
296
else {
297
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
298
</div><br /> " . __("No rating yet" , "yasr") . "</div>";
299
}
300
301
+ } //end else
302
+
303
+ } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
304
305
306
+ //If only logged in users can vote
307
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
308
309
+ //If user is logged in and can vote
310
+ if ( is_user_logged_in() ) {
311
312
+ //Chek if a logged in user has already rated for this post
313
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
314
+
315
+ if ($vote_if_user_already_rated) {
316
+
317
+ global $current_user;
318
+ get_currentuserinfo();
319
+
320
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes_logged_rated\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
321
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
322
+
323
+ }
324
+
325
+ else {
326
+
327
+ if ($votes_number>0) {
328
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
329
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
330
+ }
331
+
332
+ else {
333
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
334
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
335
+ }
336
+
337
+ }
338
339
+
340
+ } //End if user is logged in
341
+
342
+ //Else mean user is not logged in
343
else {
344
+
345
+ if ($votes_number>0) {
346
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
347
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br />" . __("You must sign to vote", "yasr") . "</div>";
348
+ }
349
+
350
+ else {
351
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
352
+ </div><br /> " . __("No rating yet" , "yasr") . "<br />" . __("You must sign to vote", "") . "</div>";
353
+ }
354
+
355
}
356
+
357
+ } //end ($allow_logged_option['allowed_user']==='logged_only')
358
+
359
+ } // end if YASR_AUTO_INSERT_SIZE === 'small'
360
+
361
+
362
+ if (YASR_AUTO_INSERT_SIZE === 'medium') {
363
+
364
+ //if anonymous are allowed to vote
365
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
366
+
367
+ //I've to block a logged in user that has already rated
368
+ if ( is_user_logged_in() ) {
369
+
370
+ //Chek if a logged in user has already rated for this post
371
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
372
+
373
+ //If user has already rated show readonly stars
374
+ if ($vote_if_user_already_rated) {
375
+
376
+ global $current_user;
377
+ get_currentuserinfo();
378
+
379
+ $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=\"true\">
380
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
381
+
382
+ }
383
+
384
+ //else logged user can vote
385
+ else {
386
+
387
+ $vote_if_user_already_rated = 0;
388
+
389
+ if ($votes_number>0) {
390
+ $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\">
391
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
392
+ }
393
+
394
+ else {
395
+ $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\">
396
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
397
+ }
398
+
399
+ } //End else
400
+
401
+ } //End if user is logged
402
+
403
+
404
+ //else is not logged can vote
405
+ else {
406
+
407
+ if ($votes_number>0) {
408
+ $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\">
409
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
410
+ }
411
+
412
+ else {
413
+ $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\">
414
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
415
+ }
416
+
417
+ } //end else
418
+
419
+ } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
420
+
421
+
422
+ //If only logged in users can vote
423
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
424
+
425
+ //If user is logged in and can vote
426
+ if ( is_user_logged_in() ) {
427
428
+ //Chek if a logged in user has already rated for this post
429
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
430
431
+ if ($vote_if_user_already_rated) {
432
433
+ global $current_user;
434
+ get_currentuserinfo();
435
436
+ $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=\"true\">
437
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
438
439
+ }
440
+
441
+ else {
442
443
+ if ($votes_number>0) {
444
+ $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\">
445
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
446
+ }
447
+
448
+ else {
449
+ $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\">
450
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
451
+ }
452
+
453
+ }
454
455
456
+ } //End if user is logged in
457
+
458
+ //Else mean user is not logged in
459
+ else {
460
+
461
+ if ($votes_number>0) {
462
+ $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\">
463
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br />" . __("You must sign to vote", "yasr") . "</div>";
464
+ }
465
466
+ else {
467
+ $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\">
468
+ </div><br /> " . __("No rating yet" , "yasr") . "<br />" . __("You must sign to vote", "") . "</div>";
469
+ }
470
471
}
472
+
473
+ } //end ($allow_logged_option['allowed_user']==='logged_only')
474
+
475
+ } // end if YASR_AUTO_INSERT_SIZE === 'medium'
476
+
477
+
478
+ if (YASR_AUTO_INSERT_SIZE === 'large') {
479
+
480
+ //if anonymous are allowed to vote
481
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
482
+
483
+ //I've to block a logged in user that has already rated
484
+ if ( is_user_logged_in() ) {
485
+
486
+ //Chek if a logged in user has already rated for this post
487
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
488
+
489
+ //If user has already rated show readonly stars
490
+ if ($vote_if_user_already_rated) {
491
+
492
+ global $current_user;
493
+ get_currentuserinfo();
494
+
495
+ $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=\"true\">
496
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
497
498
+ }
499
+
500
+ //else logged user can vote
501
+ else {
502
+
503
+ $vote_if_user_already_rated = 0;
504
+
505
+ if ($votes_number>0) {
506
+ $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\">
507
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
508
+ }
509
+
510
+ else {
511
+ $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\">
512
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
513
+ }
514
+
515
+ } //End else
516
+
517
+ } //End if user is logged
518
+
519
+
520
+ //else is not logged can vote
521
else {
522
523
if ($votes_number>0) {
530
</div><br /> " . __("No rating yet" , "yasr") . "</div>";
531
}
532
533
+ } //end else
534
+
535
+ } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
536
537
538
+ //If only logged in users can vote
539
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
540
541
+ //If user is logged in and can vote
542
+ if ( is_user_logged_in() ) {
543
544
+ //Chek if a logged in user has already rated for this post
545
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
546
+
547
+ if ($vote_if_user_already_rated) {
548
+
549
+ global $current_user;
550
+ get_currentuserinfo();
551
+
552
+ $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=\"true\">
553
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
554
+
555
+ }
556
+
557
+ else {
558
+
559
+ if ($votes_number>0) {
560
+ $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\">
561
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
562
+ }
563
564
+ else {
565
+ $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\">
566
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
567
+ }
568
+
569
+ }
570
+
571
+
572
+ } //End if user is logged in
573
+
574
+ //Else mean user is not logged in
575
else {
576
+
577
+ if ($votes_number>0) {
578
+ $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\">
579
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br />" . __("You must sign to vote", "yasr") . "</div>";
580
+ }
581
+
582
+ else {
583
+ $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\">
584
+ </div><br /> " . __("No rating yet" , "yasr") . "<br />" . __("You must sign to vote", "") . "</div>";
585
+ }
586
+
587
}
588
+
589
+ } //end ($allow_logged_option['allowed_user']==='logged_only')
590
591
+ } //End if auto insert size large
592
593
594
+ if(YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_VISITOR_RATING != '') {
595
596
$shortcode_html_tmp = "<div class=\"yasr-container-custom-text-and-visitor-rating\">
597
+ <div id=\"yasr-custom-text-before-visitor-rating\">" . YASR_TEXT_BEFORE_VISITOR_RATING . "</div>" . $shortcode_html . "</div>";
598
599
$shortcode_html = $shortcode_html_tmp;
600
682
683
<?php
684
685
+ if (YASR_AUTO_INSERT_EXCLUDE_PAGES === 'no') {
686
687
return $shortcode_html;
688
710
711
function yasr_auto_insert_shortcode_callback($content) {
712
713
+ if (YASR_AUTO_INSERT_ENABLED == 1) {
714
715
$auto_insert_shortcode=NULL; //To avoid undefined variable notice outside the loop (if (is_singular) )
716
717
$overall_rating_code = overall_rating_auto_insert_code();
718
$visitor_votes_code = visitor_votes_auto_insert_code();
719
720
+ if (YASR_AUTO_INSERT_WHAT==='overall_rating') {
721
+ switch (YASR_AUTO_INSERT_WHERE) {
722
case 'top':
723
return $overall_rating_code . $content;
724
break;
727
return $content . $overall_rating_code;
728
break;
729
} //End Switch
730
+ } //end YASR_AUTO_INSERT_WHAT overall rating
731
732
+ elseif (YASR_AUTO_INSERT_WHAT==='visitor_rating') {
733
+ switch (YASR_AUTO_INSERT_WHERE) {
734
case 'top':
735
return $visitor_votes_code . $content;
736
break;
741
} //End Switch
742
}
743
744
+ elseif (YASR_AUTO_INSERT_WHAT==='both') {
745
+ switch (YASR_AUTO_INSERT_WHERE) {
746
case 'top':
747
return $overall_rating_code . $visitor_votes_code . $content;
748
break;
755
756
return $content;
757
758
+ } //End if (YASR_AUTO_INSERT_ENABLED
759
760
else {
761
+
762
return $content;
763
+
764
}
765
766
+
767
} //End function yasr_auto_insert_shortcode_callback
768
769
775
776
$schema=NULL; //To avoid undefined variable notice outside the loop
777
778
+ if (YASR_SNIPPET == 'overall_rating') {
779
780
$overall_rating=yasr_get_overall_rating();
781
806
807
} //end if ($choosen_snippet['snippet'] == 'overall_rating')
808
809
+ if (YASR_SNIPPET == 'visitor_rating') {
810
811
$visitor_rating = yasr_get_vistor_rating();
812
lib/yasr-settings-functions.php CHANGED
@@ -18,6 +18,7 @@
18
$option['auto_insert_what']='overall_rating';
19
$option['auto_insert_where']='top';
20
$option['auto_insert_exclude_pages']='yes';
21
}
22
23
//This is to avoid undefined offset
@@ -28,7 +29,7 @@
28
}
29
30
add_settings_section( 'yasr_general_options_section_id', __('General settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
31
- add_settings_field( 'yasr_use_auto_insert_id', __('Auto insert otions', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option );
32
add_settings_field( 'yasr_show_overall_in_loop', __('Show overall rating in Home Page?', 'yasr'), 'yasr_show_overall_in_loop_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
33
add_settings_field( 'yasr_custom_text', __('Insert custom text to show before / after stars', 'yasr'), 'yasr_custom_text_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
34
add_settings_field( 'yasr_color_scheme', __('Which color scheme do you want to use?', 'yasr') , 'yasr_color_scheme_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
@@ -101,6 +102,25 @@
101
102
<p>&nbsp;</p>
103
104
<strong><?php _e('Exclude Pages?', 'yasr'); ?></strong>
105
<br />
106
<input type="radio" name="yasr_general_options[auto_insert_exclude_pages]" value="yes" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_exclude_pages']==='yes' ) echo " checked=\"checked\" "; ?> >
@@ -215,12 +235,12 @@
215
<?php
216
217
_e("Light theme", "yasr");
218
- echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr-multi-set.png>";
219
220
echo "<br /> <br />";
221
222
_e("Dark Theme", "yasr");
223
- echo "<br /><br /><img src=" . YASR_IMG_DIR . "/dark-multi-set.png>";
224
?>
225
</div>
226
@@ -273,12 +293,12 @@
273
<?php
274
275
_e("If you select \"Review Rating\", your site will be indexed from search engines like this: ", "yasr");
276
- echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr_review.png>";
277
278
echo "<br /> <br />";
279
280
_e("If, instead, you choose \"Aggregate Rating\", your site will be indexed like this", "yasr");
281
- echo "<br /><br /><img src=" . YASR_IMG_DIR . "/yasr_aggregate.jpg>";
282
?>
283
</div>
284
18
$option['auto_insert_what']='overall_rating';
19
$option['auto_insert_where']='top';
20
$option['auto_insert_exclude_pages']='yes';
21
+ $option['auto_insert_size']='large';
22
}
23
24
//This is to avoid undefined offset
29
}
30
31
add_settings_section( 'yasr_general_options_section_id', __('General settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
32
+ add_settings_field( 'yasr_use_auto_insert_id', __('Auto insert options', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option );
33
add_settings_field( 'yasr_show_overall_in_loop', __('Show overall rating in Home Page?', 'yasr'), 'yasr_show_overall_in_loop_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
34
add_settings_field( 'yasr_custom_text', __('Insert custom text to show before / after stars', 'yasr'), 'yasr_custom_text_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
35
add_settings_field( 'yasr_color_scheme', __('Which color scheme do you want to use?', 'yasr') , 'yasr_color_scheme_callback', 'yasr_settings_page', 'yasr_general_options_section_id', $option);
102
103
<p>&nbsp;</p>
104
105
+ <strong><?php _e('Size', 'yasr'); ?></strong>
106
+ <br />
107
+ <div class="yasr-option-size">
108
+ <input type="radio" name="yasr_general_options[auto_insert_size]" value="small" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_size']==='small' ) echo " checked=\"checked\" "; ?> >
109
+ <img src="<?php echo YASR_IMG_DIR . "yasr-stars-small.png" ?>" class="yasr-img-option-size"><span class="yasr-text-options-size"><?php _e('Small', 'yasr')?></span>
110
+ </div>
111
+
112
+ <div class="yasr-option-size">
113
+ <input type="radio" name="yasr_general_options[auto_insert_size]" value="medium" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_size']==='medium' ) echo " checked=\"checked\" "; ?> >
114
+ <img src="<?php echo YASR_IMG_DIR . "yasr-stars-medium.png" ?>" class="yasr-img-option-size"><span class="yasr-text-options-size"><?php _e('Medium', 'yasr')?></span>
115
+ </div>
116
+
117
+ <div class="yasr-option-size">
118
+ <input type="radio" name="yasr_general_options[auto_insert_size]" value="large" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_size']==='large' ) echo " checked=\"checked\" "; ?> >
119
+ <img src="<?php echo YASR_IMG_DIR . "yasr-stars-large.png" ?>" class="yasr-img-option-size"><span class="yasr-text-options-size"><?php _e('Large', 'yasr')?></span>
120
+ </div>
121
+
122
+ <p>&nbsp;</p>
123
+
124
<strong><?php _e('Exclude Pages?', 'yasr'); ?></strong>
125
<br />
126
<input type="radio" name="yasr_general_options[auto_insert_exclude_pages]" value="yes" class="yasr_auto_insert_where_what_radio" <?php if ($option['auto_insert_exclude_pages']==='yes' ) echo " checked=\"checked\" "; ?> >
235
<?php
236
237
_e("Light theme", "yasr");
238
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr-multi-set.png>";
239
240
echo "<br /> <br />";
241
242
_e("Dark Theme", "yasr");
243
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "dark-multi-set.png>";
244
?>
245
</div>
246
293
<?php
294
295
_e("If you select \"Review Rating\", your site will be indexed from search engines like this: ", "yasr");
296
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr_review.png>";
297
298
echo "<br /> <br />";
299
300
_e("If, instead, you choose \"Aggregate Rating\", your site will be indexed like this", "yasr");
301
+ echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr_aggregate.jpg>";
302
?>
303
</div>
304
lib/yasr-shortcode-functions.php CHANGED
@@ -6,14 +6,24 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
6
7
add_shortcode ('yasr_overall_rating', 'shortcode_overall_rating_callback');
8
9
- function shortcode_overall_rating_callback () {
10
11
- $option = get_option( 'yasr_general_options' );
12
13
//To avoid double visualization, I will insert this only if auto insert is off or if auto insert is set on visitor rating.
14
//If auto insert is on overall rating this shortcode must return nothing
15
16
- if ($option['auto_insert_enabled'] == 0 || ($option['auto_insert_enabled'] == 1 && $option['auto_insert_what'] === 'visitor_rating' )) {
17
18
$overall_rating=yasr_get_overall_rating();
19
@@ -21,23 +31,38 @@ function shortcode_overall_rating_callback () {
21
$overall_rating = "-1";
22
}
23
24
- if($option['text_before_stars'] == 1 && $option['text_before_overall'] != '') {
25
$shortcode_html = "<div class=\"yasr-container-custom-text-and-overall\">
26
- <span id=\"yasr-custom-text-before-overall\">$option[text_before_overall]</span>
27
- <div class=\"rateit bigstars\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
28
- </div>
29
- </div>";
30
}
31
32
- else {
33
34
- $shortcode_html = "<div class=\"rateit bigstars\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
35
- </div>";
36
37
}
38
39
//IF show overall rating in loop is disabled use is_singular && is_main query
40
- if ($option['show_overall_in_loop'] === 'disabled') {
41
42
if( is_singular() && is_main_query() ) {
43
@@ -48,7 +73,7 @@ function shortcode_overall_rating_callback () {
48
}
49
50
//else don't
51
- elseif ($option['show_overall_in_loop'] === 'enabled') {
52
53
return $shortcode_html;
54
@@ -63,14 +88,12 @@ function shortcode_overall_rating_callback () {
63
64
add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
65
66
- function shortcode_visitor_votes_callback () {
67
-
68
- $option = get_option( 'yasr_general_options' );
69
70
//To avoid double visualization, I will insert this only if auto insert is off or if auto insert is set on overall rating.
71
//If auto insert is on visitor rating this shortcode must return nothing
72
73
- if ($option['auto_insert_enabled'] == 0 || ($option['auto_insert_enabled'] == 1 && $option['auto_insert_what'] === 'overall_rating' )) {
74
75
$shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
76
@@ -96,12 +119,6 @@ function shortcode_visitor_votes_callback () {
96
}
97
}
98
99
- $allow_logged_option = get_option( 'yasr_general_options' );
100
-
101
- if (!$allow_logged_option) {
102
- $allow_logged_option = array();
103
- $allow_logged_option['allowed_user']='allow_anonymous';
104
- }
105
106
$image = YASR_IMG_DIR . "/loader.gif";
107
@@ -109,122 +126,370 @@ function shortcode_visitor_votes_callback () {
109
110
$medium_rating=round($medium_rating, 1);
111
112
- //if anonymous are allowed to vote
113
- if ($allow_logged_option['allowed_user']==='allow_anonymous') {
114
115
- //I've to block a logged in user that has already rated
116
- if ( is_user_logged_in() ) {
117
118
- //Chek if a logged in user has already rated for this post
119
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
120
121
- //If user has already rated show readonly stars
122
- if ($vote_if_user_already_rated) {
123
124
- global $current_user;
125
- get_currentuserinfo();
126
127
- $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=\"true\">
128
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
129
130
- }
131
132
- //else logged user can vote
133
- else {
134
135
- $vote_if_user_already_rated = 0;
136
137
if ($votes_number>0) {
138
- $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\">
139
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
140
}
141
142
else {
143
- $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\">
144
- </div><br /> " . __("No rating yet" , "yasr") . "</div>";
145
}
146
147
- } //End else
148
149
- } //End if user is logged
150
151
152
- //else is not logged can vote
153
- else {
154
155
- if ($votes_number>0) {
156
- $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\">
157
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
158
- }
159
160
else {
161
- $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\">
162
- </div><br /> " . __("No rating yet" , "yasr") . "</div>";
163
}
164
165
- } //end else
166
-
167
- } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
168
169
170
171
- //If only logged in users can vote
172
- elseif ($allow_logged_option['allowed_user']==='logged_only') {
173
174
- //If user is logged in and can vote
175
- if ( is_user_logged_in() ) {
176
177
- //Chek if a logged in user has already rated for this post
178
- $vote_if_user_already_rated = yasr_check_if_user_already_voted();
179
180
- if ($vote_if_user_already_rated) {
181
182
- global $current_user;
183
- get_currentuserinfo();
184
185
- $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=\"true\">
186
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br /><strong>" . __("User ") . "$current_user->user_login" . __(" has already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
187
188
- }
189
190
else {
191
192
if ($votes_number>0) {
193
- $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\">
194
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
195
}
196
197
else {
198
- $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\">
199
- </div><br /> " . __("No rating yet" , "yasr") . "</div>";
200
}
201
202
- }
203
204
- } //End if user is logged in
205
206
- //Else mean user is not logged in
207
- else {
208
209
210
- if ($votes_number>0) {
211
- $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\">
212
- </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ") <br />" . __("You must sign to vote", "yasr") . "</div>";
213
- }
214
215
else {
216
- $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\">
217
- </div><br /> " . __("No rating yet" , "yasr") . "<br />" . __("You must sign to vote", "") . "</div>";
218
}
219
220
}
221
-
222
- }
223
224
- if($option['text_before_stars'] == 1 && $option['text_before_visitor_rating'] != '') {
225
226
$shortcode_html_tmp = "<div class=\"yasr-container-custom-text-and-visitor-rating\">
227
- <div id=\"yasr-custom-text-before-visitor-rating\">$option[text_before_visitor_rating]</div>" . $shortcode_html . "</div>";
228
229
$shortcode_html = $shortcode_html_tmp;
230
@@ -399,7 +664,7 @@ function yasr_top_ten_highest_rated_callback () {
399
400
$shortcode_html .= "<tr>
401
<td width=\"60%\"><a href=\"$link\">$post_title</a></td>
402
- <td width=\"40%\"><div class=\"rateit charts\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$result->overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
403
</tr>";
404
405
@@ -471,7 +736,7 @@ function yasr_most_or_highest_rated_posts_callback () {
471
472
$shortcode_html .= "<tr>
473
<td width=\"60%\"><a href=\"$link\">$post_title</a></td>
474
- <td width=\"40%\"><div id=\"yasr_visitor_votes\"><div class=\"rateit charts\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
475
<br /> [" . __("Total:" , "yasr") . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , "yasr") . " $rating]</td>
476
</tr>";
477
6
7
add_shortcode ('yasr_overall_rating', 'shortcode_overall_rating_callback');
8
9
+ function shortcode_overall_rating_callback ($atts) {
10
11
+ if (!$atts) {
12
+ $size = 'large';
13
+ }
14
+
15
+ else {
16
+ extract( shortcode_atts (
17
+ array(
18
+ 'size' => 'string',
19
+ ), $atts )
20
+ );
21
+ }
22
23
//To avoid double visualization, I will insert this only if auto insert is off or if auto insert is set on visitor rating.
24
//If auto insert is on overall rating this shortcode must return nothing
25
26
+ if (YASR_AUTO_INSERT_ENABLED == 0 || (YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_WHAT === 'visitor_rating' )) {
27
28
$overall_rating=yasr_get_overall_rating();
29
31
$overall_rating = "-1";
32
}
33
34
+ $shortcode_html = '';
35
+
36
+ if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
37
+
38
$shortcode_html = "<div class=\"yasr-container-custom-text-and-overall\">
39
+ <span id=\"yasr-custom-text-before-overall\">" . YASR_TEXT_BEFORE_OVERALL . "</span>";
40
+
41
}
42
43
+ switch ($size) {
44
+ case 'small':
45
+ $shortcode_html .= "<div class=\"rateit\" id=\"yasr_rateit_overall\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
46
+ break;
47
+
48
+ case 'medium':
49
+ $shortcode_html .= "<div class=\"rateit medium\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
50
+ break;
51
52
+ case 'large':
53
+ $shortcode_html .= "<div class=\"rateit bigstars\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
54
+ break;
55
+ }
56
+
57
+
58
+ if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
59
60
+ $shortcode_html .= "</div>";
61
+
62
}
63
64
//IF show overall rating in loop is disabled use is_singular && is_main query
65
+ if (YASR_SHOW_OVERALL_IN_LOOP === 'disabled') {
66
67
if( is_singular() && is_main_query() ) {
68
73
}
74
75
//else don't
76
+ elseif (YASR_SHOW_OVERALL_IN_LOOP === 'enabled') {
77
78
return $shortcode_html;
79
88
89
add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
90
91
+ function shortcode_visitor_votes_callback ($atts) {
92
93
//To avoid double visualization, I will insert this only if auto insert is off or if auto insert is set on overall rating.
94
//If auto insert is on visitor rating this shortcode must return nothing
95
96
+ if (YASR_AUTO_INSERT_ENABLED == 0 || (YASR_AUTO_INSERT_ENABLED == 1 && YASR_AUTO_INSERT_WHAT === 'overall_rating' )) {
97
98
$shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
99
119
}
120
}
121
122
123
$image = YASR_IMG_DIR . "/loader.gif";
124
126
127
$medium_rating=round($medium_rating, 1);
128
129
+ if (!$atts) {
130
+ $size = 'large';
131
+ }
132
+
133
+ else {
134
+ extract( shortcode_atts (
135
+ array(
136
+ 'size' => 'string',
137
+ ), $atts )
138
+ );
139
+ }
140
141
+ if ($size == 'small') {
142
143
+ //if anonymous are allowed to vote
144
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
145
146
+ //I've to block a logged in user that has already rated
147
+ if ( is_user_logged_in() ) {
148
149
+ //Chek if a logged in user has already rated for this post
150
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
151
152
+ //If user has already rated show readonly stars
153
+ if ($vote_if_user_already_rated) {
154
155
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes_logged_rated\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
156
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
157
+ <strong><span class=\"yasr-visitor-shortcode-small-already-voted-text\">" . __("You've already voted this article with $vote_if_user_already_rated ", "yasr") . "</span></strong></div>";
158
159
+ }
160
+
161
+ //else logged user can vote
162
+ else {
163
+
164
+ $vote_if_user_already_rated = 0;
165
+
166
+ if ($votes_number>0) {
167
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
168
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
169
+ }
170
171
+ else {
172
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
173
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
174
+ }
175
+
176
+ } //End else
177
+
178
+ } //End if user is logged
179
+
180
+
181
+ //else if is not logged can vote
182
+ else {
183
184
if ($votes_number>0) {
185
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
186
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
187
}
188
189
else {
190
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
191
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
192
}
193
194
+ } //end else
195
+
196
+ } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
197
198
199
200
+ //If only logged in users can vote
201
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
202
203
+ //If user is logged in and can vote
204
+ if ( is_user_logged_in() ) {
205
+
206
+ //Chek if a logged in user has already rated for this post
207
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
208
+
209
+ if ($vote_if_user_already_rated) {
210
211
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes_logged_rated\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
212
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
213
+ <strong><span=\"class=\"yasr-visitor-shortcode-small-already-voted-text\">\">" . __("You've already voted this article with $vote_if_user_already_rated ", "yasr") . "</span></strong></div>";
214
+
215
+ }
216
+
217
+ else {
218
+
219
+ if ($votes_number>0) {
220
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
221
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
222
+ </div>";
223
+ }
224
+
225
+ else {
226
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
227
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
228
+ </div>";
229
+ }
230
+
231
+ }
232
+
233
+ } //End if user is logged in
234
+
235
+ //Else mean user is not logged in
236
else {
237
+
238
+
239
+ if ($votes_number>0) {
240
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
241
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
242
+ " . __("You must sign to vote", "yasr") . "</div>";
243
+ }
244
+
245
+ else {
246
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit\" id=\"yasr_rateit_visitor_votes\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
247
+ <span class=\"yasr-total-average-text-small\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
248
+ </div>";
249
+ }
250
+
251
}
252
+
253
+ }
254
255
+ } //End if $size == 'small'
256
257
+ if ($size == 'medium') {
258
259
+ //if anonymous are allowed to vote
260
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
261
262
+ //I've to block a logged in user that has already rated
263
+ if ( is_user_logged_in() ) {
264
265
+ //Chek if a logged in user has already rated for this post
266
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
267
268
+ //If user has already rated show readonly stars
269
+ if ($vote_if_user_already_rated) {
270
271
+ $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=\"true\"></div>
272
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
273
+ <strong>" . __("You've already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
274
275
+ }
276
277
+ //else logged user can vote
278
+ else {
279
+
280
+ $vote_if_user_already_rated = 0;
281
+
282
+ if ($votes_number>0) {
283
+ $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>
284
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
285
+ }
286
+
287
+ else {
288
+ $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>
289
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
290
+ }
291
+
292
+ } //End else
293
+
294
+ } //End if user is logged
295
296
297
+ //else if is not logged can vote
298
else {
299
300
if ($votes_number>0) {
301
+ $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>
302
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
303
}
304
305
else {
306
+ $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>
307
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
308
}
309
310
+ } //end else
311
+
312
+ } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
313
314
315
316
+ //If only logged in users can vote
317
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
318
319
+ //If user is logged in and can vote
320
+ if ( is_user_logged_in() ) {
321
+
322
+ //Chek if a logged in user has already rated for this post
323
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
324
+
325
+ if ($vote_if_user_already_rated) {
326
+
327
+ $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=\"true\"></div>
328
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
329
+ <strong>" . __("You've already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
330
+
331
+ }
332
333
+ else {
334
+
335
+ if ($votes_number>0) {
336
+ $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>
337
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
338
+ </div>";
339
+ }
340
+
341
+ else {
342
+ $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>
343
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
344
+ </div>";
345
+ }
346
+
347
+ }
348
+
349
+ } //End if user is logged in
350
+
351
+ //Else mean user is not logged in
352
else {
353
+
354
+
355
+ if ($votes_number>0) {
356
+ $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>
357
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
358
+ " . __("You must sign to vote", "yasr") . "</div>";
359
+ }
360
+
361
+ else {
362
+ $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>
363
+ <span class=\"yasr-total-average-text-medium\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
364
+ </div>";
365
+ }
366
+
367
}
368
+
369
+ }
370
+
371
+ } //End if $size == 'medium'
372
+
373
+ if ($size == 'large') {
374
+
375
+ //if anonymous are allowed to vote
376
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
377
+
378
+ //I've to block a logged in user that has already rated
379
+ if ( is_user_logged_in() ) {
380
+
381
+ //Chek if a logged in user has already rated for this post
382
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
383
+
384
+ //If user has already rated show readonly stars
385
+ if ($vote_if_user_already_rated) {
386
+
387
+ $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=\"true\"></div>
388
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
389
+ <strong>" . __("You've already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
390
+
391
+ }
392
+
393
+ //else logged user can vote
394
+ else {
395
+
396
+ $vote_if_user_already_rated = 0;
397
+
398
+ if ($votes_number>0) {
399
+ $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>
400
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
401
+ }
402
+
403
+ else {
404
+ $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>
405
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
406
+ }
407
+
408
+ } //End else
409
+
410
+ } //End if user is logged
411
+
412
+
413
+ //else if is not logged can vote
414
+ else {
415
416
+ if ($votes_number>0) {
417
+ $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>
418
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
419
+ }
420
+
421
+ else {
422
+ $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>
423
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span></div>";
424
+ }
425
+
426
+ } //end else
427
+
428
+ } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
429
+
430
+
431
+
432
+ //If only logged in users can vote
433
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
434
+
435
+ //If user is logged in and can vote
436
+ if ( is_user_logged_in() ) {
437
+
438
+ //Chek if a logged in user has already rated for this post
439
+ $vote_if_user_already_rated = yasr_check_if_user_already_voted();
440
+
441
+ if ($vote_if_user_already_rated) {
442
+
443
+ $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=\"true\"></div>
444
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
445
+ <strong>" . __("You've already voted this article with $vote_if_user_already_rated ", "yasr") . "</strong></div>";
446
+
447
+ }
448
+
449
+ else {
450
+
451
+ if ($votes_number>0) {
452
+ $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>
453
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
454
+ </div>";
455
+ }
456
+
457
+ else {
458
+ $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>
459
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
460
+ </div>";
461
+ }
462
+
463
+ }
464
+
465
+ } //End if user is logged in
466
+
467
+ //Else mean user is not logged in
468
+ else {
469
+
470
+
471
+ if ($votes_number>0) {
472
+ $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>
473
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
474
+ " . __("You must sign to vote", "yasr") . "</div>";
475
+ }
476
+
477
+ else {
478
+ $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>
479
+ <span class=\"yasr-total-average-text\"> " . __("[Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average $medium_rating/5" , "yasr") . "]</span>
480
+ </div>";
481
+ }
482
+
483
+ }
484
+
485
}
486
487
+ } //End if $size == 'large'
488
+
489
+ if(YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_VISITOR_RATING != '') {
490
491
$shortcode_html_tmp = "<div class=\"yasr-container-custom-text-and-visitor-rating\">
492
+ <div id=\"yasr-custom-text-before-visitor-rating\">" . YASR_TEXT_BEFORE_VISITOR_RATING . "</div><br />" . $shortcode_html . "</div>";
493
494
$shortcode_html = $shortcode_html_tmp;
495
664
665
$shortcode_html .= "<tr>
666
<td width=\"60%\"><a href=\"$link\">$post_title</a></td>
667
+ <td width=\"40%\"><div class=\"rateit medium\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$result->overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
668
</tr>";
669
670
736
737
$shortcode_html .= "<tr>
738
<td width=\"60%\"><a href=\"$link\">$post_title</a></td>
739
+ <td width=\"40%\"><div id=\"yasr_visitor_votes\"><div class=\"rateit medium\" data-rateit-starwidth=\"24\" data-rateit-starheight=\"24\" data-rateit-value=\"$rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
740
<br /> [" . __("Total:" , "yasr") . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , "yasr") . " $rating]</td>
741
</tr>";
742
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
=== Yasr - Yet Another Stars Rating ===
2
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
3
- Tags: Rating, Review, Star, Snippet, Rich snippet, Schema, Schema.org, Serp
4
Requires at least: 3.5
5
Tested up to: 3.9.1
6
- Stable tag: 0.4.0
7
License: GPL2
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
@@ -76,6 +76,11 @@ Of course not: you can easily add it on the visual editor just by clicking on th
76
77
== Changelog ==
78
79
= 0.4.0 =
80
* Popup shortcode creatore it's now tabbed and got a link to the new doc
81
* Minor changes and bugfixes
1
=== Yasr - Yet Another Stars Rating ===
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, Schema.org, Serp
4
Requires at least: 3.5
5
Tested up to: 3.9.1
6
+ Stable tag: 0.4.1
7
License: GPL2
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
76
77
== Changelog ==
78
79
+ = 0.4.1 =
80
+ * Added 2 sizes for "overall_rating" and "visitor_votes" stars sets, now you can choose between 16px, 24px and 32px (default)
81
+ * MANY code changes: it should be a little faster
82
+ * Fixed typo errors
83
+
84
= 0.4.0 =
85
* Popup shortcode creatore it's now tabbed and got a link to the new doc
86
* Minor changes and bugfixes
yasr-metabox-overall-rating.php CHANGED
@@ -10,7 +10,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
10
11
add_action( 'admin_footer', 'yasr_overall_rating_javascript' );
12
13
- $option = get_option('yasr_general_options');
14
15
?>
16
@@ -34,9 +33,9 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
34
35
<?php
36
37
- if($option['auto_insert_enabled'] == 0) {
38
39
- echo "Remember to insert this shoortcode <strong>[yasr_overall_rating]</strong> where you want to display this rating";
40
41
}
42
10
11
add_action( 'admin_footer', 'yasr_overall_rating_javascript' );
12
13
14
?>
15
33
34
<?php
35
36
+ if( YASR_AUTO_INSERT_ENABLED == 0 ) {
37
38
+ echo "Remember to insert this shortcode <strong>[yasr_overall_rating]</strong> where you want to display this rating";
39
40
}
41
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.4.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.4.0');
32
33
//Plugin absolute path
34
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -63,7 +63,6 @@ require (YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php');
63
64
$version_installed = get_option('yasr-version') ;
65
66
-
67
//If this is a fresh new installation
68
69
if (!$version_installed ) {
@@ -84,7 +83,7 @@ define ("YASR_MULTI_SET_VALUES_TABLE", $wpdb->prefix . 'yasr_multi_values');
84
85
define ("YASR_LOG_TABLE", $wpdb->prefix . 'yasr_log');
86
87
-
88
if ($version_installed && $version_installed < '0.3.4') {
89
90
$wpdb->query ("ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " MODIFY field_name VARCHAR( 23 )");
@@ -102,6 +101,7 @@ if ($version_installed && $version_installed < '0.3.4') {
102
103
}
104
105
if ($version_installed && $version_installed < '0.3.8') {
106
107
$option = get_option( 'yasr_general_options' );
@@ -112,6 +112,44 @@ if ($version_installed && $version_installed < '0.3.8') {
112
113
}
114
115
update_option('yasr-version', YASR_VERSION_NUM);
116
117
?>
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.4.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.4.1');
32
33
//Plugin absolute path
34
define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
63
64
$version_installed = get_option('yasr-version') ;
65
66
//If this is a fresh new installation
67
68
if (!$version_installed ) {
83
84
define ("YASR_LOG_TABLE", $wpdb->prefix . 'yasr_log');
85
86
+ // To remove in the end of August
87
if ($version_installed && $version_installed < '0.3.4') {
88
89
$wpdb->query ("ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " MODIFY field_name VARCHAR( 23 )");
101
102
}
103
104
+ // To remove in the end of August
105
if ($version_installed && $version_installed < '0.3.8') {
106
107
$option = get_option( 'yasr_general_options' );
112
113
}
114
115
+ if ($version_installed && $version_installed < '0.4.1') {
116
+
117
+ $option = get_option( 'yasr_general_options' );
118
+
119
+ $option['auto_insert_size'] = 'large';
120
+
121
+ update_option("yasr_general_options", $option);
122
+
123
+ }
124
+
125
update_option('yasr-version', YASR_VERSION_NUM);
126
127
+ $stored_options = get_option( 'yasr_general_options' );
128
+
129
+ define ("YASR_AUTO_INSERT_ENABLED", $stored_options['auto_insert_enabled']);
130
+
131
+ if ( YASR_AUTO_INSERT_ENABLED == 1 ) {
132
+
133
+ define ("YASR_AUTO_INSERT_WHAT", $stored_options['auto_insert_what']);
134
+ define ("YASR_AUTO_INSERT_WHERE", $stored_options['auto_insert_where']);
135
+ define ("YASR_AUTO_INSERT_SIZE", $stored_options['auto_insert_size']);
136
+ define ("YASR_AUTO_INSERT_EXCLUDE_PAGES", $stored_options['auto_insert_exclude_pages']);
137
+
138
+ }
139
+
140
+ define ("YASR_SHOW_OVERALL_IN_LOOP", $stored_options['show_overall_in_loop']);
141
+ define ("YASR_TEXT_BEFORE_STARS", $stored_options['text_before_stars']);
142
+
143
+ if ( YASR_TEXT_BEFORE_STARS == 1 ) {
144
+
145
+ define ("YASR_TEXT_BEFORE_OVERALL", $stored_options['text_before_overall']);
146
+ define ("YASR_TEXT_BEFORE_VISITOR_RATING", $stored_options['text_before_visitor_rating']);
147
+ define ("YASR_CUSTOM_TEXT_USER_VOTED", $stored_options['custom_text_user_voted']);
148
+
149
+ }
150
+
151
+ define ("YASR_SNIPPET", $stored_options['snippet']);
152
+ define ("YASR_ALLOWED_USER", $stored_options['allowed_user']);
153
+ define ("YASR_SCHEME_COLOR", $stored_options['scheme_color']);
154
+
155
?>