Yasr – Yet Another Stars Rating - Version 1.2.0

Version Description

  • FIXED: if more then one visitor multiset for page were used only the last use to work
  • TWEAKED: transient are used to cache ratings: this means that Yasr is faster then ever
  • TWEAKED: shortcode creator is now above of tinymce. It now uses thickbox
  • TWEAKED: added filter 'yasr_filter_ip' to filter stored ip address
  • TWEAKED: code cleanup
Download this release

Release Info

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

Code changes from version 1.1.9 to 1.2.0

css/yasr.css CHANGED
@@ -13,20 +13,10 @@
13
-webkit-touch-callout: none;
14
}
15
16
- .rateit .rateit-range
17
- {
18
- position: relative;
19
- display: -moz-inline-box;
20
- display: inline-block;
21
- background: url('../img/star.png');
22
- height: 16px;
23
- outline: none;
24
- vertical-align: -5px;
25
- }
26
27
- .rateit .rateit-range * {
28
display:block;
29
- }
30
31
/* for IE 6 */
32
* html .rateit, * html .rateit .rateit-range
@@ -46,44 +36,29 @@
46
left: 0px;
47
}
48
49
- .rateit .rateit-hover
50
- {
51
- background: url('../img/star.png') left -16px;
52
- }
53
-
54
-
55
- .rateit .rateit-selected
56
- {
57
- background: url('../img/star.png') left -32px;
58
- }
59
-
60
- .rateit .rateit-preset
61
- {
62
- background: url('../img/star.png') left -48px;
63
- }
64
-
65
- .rateit button.rateit-reset
66
{
67
- background: url('../img/delete.gif') 0 0;
68
- width: 16px;
69
- height: 16px;
70
display: -moz-inline-box;
71
display: inline-block;
72
- float: left;
73
outline: none;
74
- border:none;
75
- padding: 0;
76
}
77
78
- .rateit button.rateit-reset:hover, .rateit button.rateit-reset:focus
79
{
80
- background-position: 0 -16px;
81
}
82
83
- .yasr_settings_fields_content {
84
- background-color: #F7F7F7;
85
- }
86
87
88
89
/*** RTL RULES, thank's to Arik Numlock ***/
@@ -162,6 +137,25 @@ div.bigstars .rateit-selected
162
height: 32px;
163
}
164
165
/****** End rateit rules ******/
166
167
@@ -205,7 +199,7 @@ div.bigstars .rateit-selected
205
}
206
207
.yasr-dashicons-visitor-stats {
208
- vertical-align: bottom;
209
text-decoration: none;
210
cursor: pointer;
211
cursor: hand;
13
-webkit-touch-callout: none;
14
}
15
16
17
+ /*.rateit .rateit-range * {
18
display:block;
19
+ }*/
20
21
/* for IE 6 */
22
* html .rateit, * html .rateit .rateit-range
36
left: 0px;
37
}
38
39
+ .rateit .rateit-range
40
{
41
+ position: relative;
42
display: -moz-inline-box;
43
display: inline-block;
44
+ background: url('../img/star.png');
45
+ height: 16px;
46
+ width: 16px;
47
outline: none;
48
+ vertical-align: -5px;
49
}
50
51
+
52
+ .rateit .rateit-hover
53
{
54
+ background: url('../img/star.png') left -16px;
55
}
56
57
58
+ .rateit .rateit-selected
59
+ {
60
+ background: url('../img/star.png') left -32px;
61
+ }
62
63
64
/*** RTL RULES, thank's to Arik Numlock ***/
137
height: 32px;
138
}
139
140
+
141
+ .rateit button.rateit-reset
142
+ {
143
+ background: url('../img/delete.gif') 0 0;
144
+ width: 16px;
145
+ height: 16px;
146
+ display: -moz-inline-box;
147
+ display: inline-block;
148
+ float: left;
149
+ outline: none;
150
+ border:none;
151
+ padding: 0;
152
+ }
153
+
154
+ .rateit button.rateit-reset:hover, .rateit button.rateit-reset:focus
155
+ {
156
+ background-position: 0 -16px;
157
+ }
158
+
159
/****** End rateit rules ******/
160
161
199
}
200
201
.yasr-dashicons-visitor-stats {
202
+ vertical-align: bottom !important;
203
text-decoration: none;
204
cursor: pointer;
205
cursor: hand;
js/addButton_tinymcs.js DELETED
@@ -1,47 +0,0 @@
1
- jQuery(document).ready(function() {
2
-
3
- tinymce.create('tinymce.plugins.yasr_plugin', {
4
- init : function(ed, url) {
5
- // Register command for when button is clicked
6
- ed.addCommand('yasr_insert_shortcode', function() {
7
-
8
- jQuery('#yasr-tinypopup-form').dialog({
9
- title: 'Insert YASR shortcode',
10
- width: 530, // overcomes width:'auto' and maxWidth bug
11
- maxWidth: 600,
12
- height: 'auto',
13
- modal: true,
14
- fluid: true, //new option
15
- resizable: false
16
-
17
- });
18
- });
19
-
20
- // Register buttons - trigger above command when clicked
21
- ed.addButton('yasr_button', {title : 'Yasr Shortcode', cmd : 'yasr_insert_shortcode', image: url + '/../img/star_tiny.png' });
22
- },
23
- });
24
-
25
- // Register our TinyMCE plugin
26
- // first parameter is the button ID1
27
- // second parameter must match the first parameter of the tinymce.create() function above
28
- tinymce.PluginManager.add('yasr_button', tinymce.plugins.yasr_plugin);
29
-
30
- // executes this when the DOM is ready
31
- jQuery(document).ready(function(){
32
-
33
- var data = {
34
- action: 'yasr_create_shortcode'
35
- }
36
-
37
- jQuery.post(ajaxurl, data, function(button_content) {
38
- // creates a table to be displayed everytime the button is clicked
39
-
40
- var response=button_content;
41
-
42
- jQuery(response).appendTo('body').hide();
43
-
44
- });
45
- });
46
-
47
- });
js/yasr-admin.js CHANGED
@@ -20,9 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
20
21
function yasrDisplayTopRightMetabox(defaultbox, postid, nonceOverall, nonceSnippet) {
22
23
- if (defaultbox == 'stars' ) {
24
25
- yasrPrintEventSendOverallWithStars(postid, nonceOverall);
26
27
} //end if if (defaultbox == 'stars' )
28
@@ -40,7 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
40
//This is for the stars
41
function yasrPrintEventSendOverallWithStars(postid, nonce) {
42
43
- jQuery('#yasr_rateit_overall').on('rated', function() {
44
jQuery('#loader-overall-rating').show();
45
var el = jQuery(this);
46
var value = el.rateit('value');
@@ -48,7 +48,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
48
49
var data = {
50
action: 'yasr_send_overall_rating',
51
- nonce: nonce,
52
rating: value,
53
post_id: postid
54
};
@@ -56,19 +56,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
56
//Send value to the Server
57
jQuery.post(ajaxurl, data, function(response) {
58
jQuery('#loader-overall-rating').hide();
59
- jQuery('#yasr_rateit_overall_value').text(response);
60
}) ;
61
62
});
63
64
- jQuery('#yasr_rateit_overall').on('reset', function() {
65
jQuery('#loader-overall-rating').show();
66
var el = jQuery(this);
67
var value = '-1';
68
69
var data = {
70
action: 'yasr_send_overall_rating',
71
- nonce: nonce,
72
rating: value,
73
post_id: postid
74
};
@@ -76,7 +76,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
76
//Send value to the Server
77
jQuery.post(ajaxurl, data, function(response) {
78
jQuery('#loader-overall-rating').hide();
79
- jQuery('#yasr_rateit_overall_value').text(response);
80
}) ;
81
82
});
@@ -107,7 +107,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
107
}
108
109
});
110
-
111
jQuery('#yasr-send-overall-numbers').on('click', function() {
112
113
var integer = jQuery('#yasr-vote-overall-numbers-int').val();
@@ -118,7 +118,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
118
119
var data = {
120
action: 'yasr_send_overall_rating',
121
- nonce: nonce,
122
rating: value,
123
post_id: postid
124
};
@@ -154,7 +154,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
154
}) ;
155
156
return false;
157
- preventDefault();
158
159
});
160
@@ -165,7 +165,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
165
166
167
/****** Yasr Metabox Multiple Rating ******/
168
-
169
function yasrDisplayMultiMetabox (nMultiSet, postid, nonceMulti, setId) {
170
171
// --------------IF multiple set are found -------------------
@@ -173,9 +173,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
173
if (nMultiSet > 1) {
174
175
jQuery('#yasr-button-select-set').on("click", function() {
176
-
177
//get the multi data
178
- var data_id = {
179
action: 'yasr_send_id_nameset',
180
set_id: jQuery('#select_set').val(),
181
post_id: postid
@@ -189,10 +189,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
189
jQuery('#yasr_rateit_multi_rating').html(response);
190
jQuery('.rateit').rateit();
191
192
- jQuery('.multi').on('rated', function() {
193
var el = jQuery(this);
194
var value = el.rateit('value');
195
- var value = value.toFixed(1);
196
var idField = el.attr('id');
197
var setType = jQuery('#select_set').val();
198
@@ -200,7 +200,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
200
201
var data = {
202
action: 'yasr_send_id_field_with_vote',
203
- nonce: nonceMulti,
204
rating: value,
205
post_id: postid,
206
id_field: idField,
@@ -214,7 +214,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
214
});
215
216
217
- jQuery('.multi').on('reset', function() {
218
var el = jQuery(this);
219
var value = '0';
220
var idField = el.attr('id');
@@ -224,7 +224,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
224
225
var data = {
226
action: 'yasr_send_id_field_with_vote',
227
- nonce: nonceMulti,
228
rating: value,
229
post_id: postid,
230
id_field: idField,
@@ -236,7 +236,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
236
jQuery("#yasr-loader-multi-set-field-"+idField).hide();
237
});
238
});
239
-
240
});
241
242
return false; // prevent default click action from happening!
@@ -250,28 +250,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
250
251
// --------------IF we're using just 1 set -------------------
252
253
- var data_id = {
254
action: 'yasr_send_id_nameset',
255
set_id: setId,
256
post_id: postid
257
}
258
-
259
//Send value to the Server
260
jQuery.post(ajaxurl, data_id, function(response) {
261
jQuery('#yasr_rateit_multi_rating').html(response);
262
jQuery('.rateit').rateit();
263
264
- jQuery('.multi').on('rated', function() {
265
var el = jQuery(this);
266
var value = el.rateit('value');
267
- var value = value.toFixed(1);
268
var idField = el.attr('id');
269
270
jQuery("#yasr-loader-multi-set-field-"+idField).show();
271
272
var data = {
273
action: 'yasr_send_id_field_with_vote',
274
- nonce: nonceMulti,
275
rating: value,
276
post_id: postid,
277
id_field: idField,
@@ -285,7 +285,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
285
286
});
287
288
- jQuery('.multi').on('reset', function() {
289
var el = jQuery(this);
290
var value = '0';
291
var idField = el.attr('id');
@@ -295,7 +295,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
295
296
var data = {
297
action: 'yasr_send_id_field_with_vote',
298
- nonce: nonceMulti,
299
rating: value,
300
post_id: postid,
301
id_field: idField,
@@ -343,7 +343,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
343
if (jQuery('#yasr_text_before_star_off').is(':checked')) {
344
jQuery('.yasr-general-options-text-before').prop('disabled', true);
345
}
346
-
347
jQuery('#yasr_text_before_star_on').on('click', function(){
348
349
jQuery('.yasr-general-options-text-before').prop('disabled', false);
@@ -372,7 +372,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
372
//Second div code
373
374
//On click show proceed button
375
- jQuery('#import-gdstar').on('click', function() {
376
jQuery('#yasr-import-gdstar-div').toggle();
377
});
378
@@ -381,7 +381,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
381
382
jQuery('#yasr-loader-importer').show();
383
384
- var data = {
385
action : 'yasr_import_step1'
386
};
387
@@ -400,7 +400,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
400
var data = {
401
action: 'yasr_import_multi_set'
402
};
403
-
404
jQuery.post(ajaxurl, data, function(response) {
405
jQuery('#yasr-loader-importer2').hide();
406
jQuery('#result-import').append(response);
@@ -427,7 +427,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
427
jQuery('#yasr-multi-set-doc-box').toggle("slow");
428
});
429
430
- if (nMultiSet == 1) {
431
432
var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
433
@@ -439,14 +439,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
439
jQuery('#yasr-element-limit').show();
440
jQuery('#yasr-add-field-edit-multiset').hide();
441
return false;
442
- }
443
-
444
var newTextBoxDiv = jQuery(document.createElement('tr'))
445
-
446
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
447
-
448
newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
449
-
450
counter++;
451
452
});
@@ -454,16 +454,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
454
455
} //End if ($n_multi_set == 1)
456
457
- if (nMultiSet > 1) {
458
459
//If more then 1 set is used...
460
jQuery('#yasr-button-select-set-edit-form').on("click", function() {
461
-
462
var data = {
463
action : 'yasr_get_multi_set',
464
set_id : jQuery('#yasr_select_edit_set').val()
465
- }
466
-
467
jQuery.post(ajaxurl, data, function(response) {
468
jQuery('#yasr-multi-set-response').show();
469
jQuery('#yasr-multi-set-response').html(response);
@@ -473,36 +473,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
473
preventDefault(); // same thing as above
474
475
});
476
-
477
jQuery(document).ajaxComplete(function(){
478
479
var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
480
481
counter++;
482
-
483
jQuery("#yasr-add-field-edit-multiset").on('click', function() {
484
-
485
if(counter>9){
486
jQuery('#yasr-element-limit').show();
487
jQuery('#yasr-add-field-edit-multiset').hide();
488
return false;
489
- }
490
-
491
var newTextBoxDiv = jQuery(document.createElement('tr'))
492
-
493
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
494
-
495
newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
496
-
497
counter++;
498
499
});
500
-
501
});
502
503
- } //End if ($n_multi_set > 1)
504
505
-
506
507
} //end if active_tab=='manage_multi'
508
@@ -527,7 +527,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
527
528
jQuery('#yasr-ask-five-stars').hide();
529
530
- var data = {
531
action: 'yasr_hide_ask_rating_metabox',
532
choose: 'hide',
533
nonce: nonceHideAskRating
@@ -544,7 +544,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
544
545
jQuery('#yasr-ask-five-stars').hide();
546
547
- var data = {
548
action: 'yasr_hide_ask_rating_metabox',
549
choose: 'close',
550
nonce: nonceHideAskRating
@@ -588,7 +588,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
588
589
});
590
591
- // Add shortcode for overall rating
592
jQuery('#yasr-overall').on("click", function(){
593
jQuery('#yasr-overall-choose-size').toggle('slow');
594
});
@@ -597,24 +597,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
597
var shortcode = '[yasr_overall_rating size="small"]';
598
// inserts the shortcode into the active editor
599
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
600
- // closes jqueryui
601
- jQuery('#yasr-tinypopup-form').dialog('close');
602
});
603
604
jQuery('#yasr-overall-insert-medium').on("click", function(){
605
var shortcode = '[yasr_overall_rating size="medium"]';
606
// inserts the shortcode into the active editor
607
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
608
- // closes jqueryui
609
- jQuery('#yasr-tinypopup-form').dialog('close');
610
});
611
612
jQuery('#yasr-overall-insert-large').on("click", function(){
613
var shortcode = '[yasr_overall_rating size="large"]';
614
// inserts the shortcode into the active editor
615
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
616
- // closes jqueryui
617
- jQuery('#yasr-tinypopup-form').dialog('close');
618
});
619
620
//Add shortcode for visitors rating
@@ -623,30 +624,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
623
});
624
625
jQuery('#yasr-visitor-insert-small').on("click", function(){
626
- var shortcode = '[yasr_visitor_votes size="small"]';
627
// inserts the shortcode into the active editor
628
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
629
// closes Thickbox
630
- jQuery('#yasr-tinypopup-form').dialog('close');
631
});
632
633
jQuery('#yasr-visitor-insert-medium').on("click", function(){
634
- var shortcode = '[yasr_visitor_votes size="medium"]';
635
// inserts the shortcode into the active editor
636
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
637
// closes Thickbox
638
- jQuery('#yasr-tinypopup-form').dialog('close');
639
});
640
641
jQuery('#yasr-visitor-insert-large').on("click", function(){
642
- var shortcode = '[yasr_visitor_votes size="large"]';
643
// inserts the shortcode into the active editor
644
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
645
// closes Thickbox
646
- jQuery('#yasr-tinypopup-form').dialog('close');
647
});
648
649
- if (nMultiSet > 1) {
650
651
//Add shortcode for multiple set
652
jQuery('#yasr-insert-multiset-select').on("click", function(){
@@ -654,7 +655,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
654
var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
655
656
if (!visitorSet) {
657
-
658
var shortcode = '[yasr_visitor_multiset setid=';
659
660
}
@@ -669,13 +670,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
669
shortcode += ']';
670
// inserts the shortcode into the active editor
671
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
672
- // closes jqueryui
673
- jQuery('#yasr-tinypopup-form').dialog('close');
674
});
675
676
} //End if
677
678
- else if (nMultiSet==1) {
679
680
//Add shortcode for single set (if only 1 are found)
681
jQuery('#yasr-single-set').on("click", function(){
@@ -684,7 +685,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
684
var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
685
686
if (!visitorSet) {
687
-
688
var shortcode = '[yasr_visitor_multiset setid=';
689
690
}
@@ -699,19 +700,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
699
shortcode += ']';
700
// inserts the shortcode into the active editor
701
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
702
- // closes jqueryui
703
- jQuery('#yasr-tinypopup-form').dialog('close');
704
});
705
706
- } //End elseif
707
708
// Add shortcode for top 10 by overall ratings
709
jQuery('#yasr-top-10-overall-rating').on("click", function(){
710
var shortcode = '[yasr_top_ten_highest_rated]';
711
// inserts the shortcode into the active editor
712
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
713
- // closes jqueryui
714
- jQuery('#yasr-tinypopup-form').dialog('close');
715
});
716
717
// Add shortcode for 10 highest most rated
@@ -719,8 +720,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
719
var shortcode = '[yasr_most_or_highest_rated_posts]';
720
// inserts the shortcode into the active editor
721
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
722
- // closes jqueryui
723
- jQuery('#yasr-tinypopup-form').dialog('close');
724
});
725
726
// Add shortcode for top 5 active reviewer
@@ -728,8 +729,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
728
var shortcode = '[yasr_top_5_reviewers]';
729
// inserts the shortcode into the active editor
730
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
731
- // closes jqueryui
732
- jQuery('#yasr-tinypopup-form').dialog('close');
733
});
734
735
// Add shortcode for top 10 active users
@@ -737,8 +738,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
737
var shortcode = '[yasr_top_ten_active_users]';
738
// inserts the shortcode into the active editor
739
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
740
- // closes jqueryui
741
- jQuery('#yasr-tinypopup-form').dialog('close');
742
});
743
744
} //End function
@@ -755,7 +756,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
755
756
jQuery('#yasr-loader-log-metabox').show();
757
758
- var data = {
759
action : 'yasr_change_log_page',
760
pagenum: jQuery(this).val(),
761
totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')
@@ -775,7 +776,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
775
776
jQuery('#yasr-loader-log-metabox').show();
777
778
- var data = {
779
action : 'yasr_change_log_page',
780
pagenum: jQuery(this).val(),
781
totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')
@@ -801,7 +802,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
801
802
jQuery('#yasr-loader-user-log-metabox').show();
803
804
- var data = {
805
action : 'yasr_change_user_log_page',
806
pagenum: jQuery(this).val(),
807
totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-user-log-total-pages')
@@ -811,7 +812,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
811
jQuery.post(ajaxurl, data, function(response) {
812
jQuery('#yasr-loader-log-metabox').hide();
813
jQuery('#yasr-user-log-container').html(response);
814
- });
815
816
});
817
@@ -821,7 +822,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
821
822
jQuery('#yasr-loader-user-log-metabox').show();
823
824
- var data = {
825
action : 'yasr_change_user_log_page',
826
pagenum: jQuery(this).val(),
827
totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-user-log-total-pages')
@@ -837,4 +838,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
837
838
});
839
840
- /****** End yasr db functions ******/
20
21
function yasrDisplayTopRightMetabox(defaultbox, postid, nonceOverall, nonceSnippet) {
22
23
+ if (defaultbox == 'stars' ) {
24
25
+ yasrPrintEventSendOverallWithStars(postid, nonceOverall);
26
27
} //end if if (defaultbox == 'stars' )
28
40
//This is for the stars
41
function yasrPrintEventSendOverallWithStars(postid, nonce) {
42
43
+ jQuery('#yasr_rateit_overall').on('rated', function() {
44
jQuery('#loader-overall-rating').show();
45
var el = jQuery(this);
46
var value = el.rateit('value');
48
49
var data = {
50
action: 'yasr_send_overall_rating',
51
+ nonce: nonce,
52
rating: value,
53
post_id: postid
54
};
56
//Send value to the Server
57
jQuery.post(ajaxurl, data, function(response) {
58
jQuery('#loader-overall-rating').hide();
59
+ jQuery('#yasr_rateit_overall_value').text(response);
60
}) ;
61
62
});
63
64
+ jQuery('#yasr_rateit_overall').on('reset', function() {
65
jQuery('#loader-overall-rating').show();
66
var el = jQuery(this);
67
var value = '-1';
68
69
var data = {
70
action: 'yasr_send_overall_rating',
71
+ nonce: nonce,
72
rating: value,
73
post_id: postid
74
};
76
//Send value to the Server
77
jQuery.post(ajaxurl, data, function(response) {
78
jQuery('#loader-overall-rating').hide();
79
+ jQuery('#yasr_rateit_overall_value').text(response);
80
}) ;
81
82
});
107
}
108
109
});
110
+
111
jQuery('#yasr-send-overall-numbers').on('click', function() {
112
113
var integer = jQuery('#yasr-vote-overall-numbers-int').val();
118
119
var data = {
120
action: 'yasr_send_overall_rating',
121
+ nonce: nonce,
122
rating: value,
123
post_id: postid
124
};
154
}) ;
155
156
return false;
157
+ preventDefault();
158
159
});
160
165
166
167
/****** Yasr Metabox Multiple Rating ******/
168
+
169
function yasrDisplayMultiMetabox (nMultiSet, postid, nonceMulti, setId) {
170
171
// --------------IF multiple set are found -------------------
173
if (nMultiSet > 1) {
174
175
jQuery('#yasr-button-select-set').on("click", function() {
176
+
177
//get the multi data
178
+ var data_id = {
179
action: 'yasr_send_id_nameset',
180
set_id: jQuery('#select_set').val(),
181
post_id: postid
189
jQuery('#yasr_rateit_multi_rating').html(response);
190
jQuery('.rateit').rateit();
191
192
+ jQuery('.multi').on('rated', function() {
193
var el = jQuery(this);
194
var value = el.rateit('value');
195
+ var value = value.toFixed(1);
196
var idField = el.attr('id');
197
var setType = jQuery('#select_set').val();
198
200
201
var data = {
202
action: 'yasr_send_id_field_with_vote',
203
+ nonce: nonceMulti,
204
rating: value,
205
post_id: postid,
206
id_field: idField,
214
});
215
216
217
+ jQuery('.multi').on('reset', function() {
218
var el = jQuery(this);
219
var value = '0';
220
var idField = el.attr('id');
224
225
var data = {
226
action: 'yasr_send_id_field_with_vote',
227
+ nonce: nonceMulti,
228
rating: value,
229
post_id: postid,
230
id_field: idField,
236
jQuery("#yasr-loader-multi-set-field-"+idField).hide();
237
});
238
});
239
+
240
});
241
242
return false; // prevent default click action from happening!
250
251
// --------------IF we're using just 1 set -------------------
252
253
+ var data_id = {
254
action: 'yasr_send_id_nameset',
255
set_id: setId,
256
post_id: postid
257
}
258
+
259
//Send value to the Server
260
jQuery.post(ajaxurl, data_id, function(response) {
261
jQuery('#yasr_rateit_multi_rating').html(response);
262
jQuery('.rateit').rateit();
263
264
+ jQuery('.multi').on('rated', function() {
265
var el = jQuery(this);
266
var value = el.rateit('value');
267
+ var value = value.toFixed(1);
268
var idField = el.attr('id');
269
270
jQuery("#yasr-loader-multi-set-field-"+idField).show();
271
272
var data = {
273
action: 'yasr_send_id_field_with_vote',
274
+ nonce: nonceMulti,
275
rating: value,
276
post_id: postid,
277
id_field: idField,
285
286
});
287
288
+ jQuery('.multi').on('reset', function() {
289
var el = jQuery(this);
290
var value = '0';
291
var idField = el.attr('id');
295
296
var data = {
297
action: 'yasr_send_id_field_with_vote',
298
+ nonce: nonceMulti,
299
rating: value,
300
post_id: postid,
301
id_field: idField,
343
if (jQuery('#yasr_text_before_star_off').is(':checked')) {
344
jQuery('.yasr-general-options-text-before').prop('disabled', true);
345
}
346
+
347
jQuery('#yasr_text_before_star_on').on('click', function(){
348
349
jQuery('.yasr-general-options-text-before').prop('disabled', false);
372
//Second div code
373
374
//On click show proceed button
375
+ jQuery('#import-gdstar').on('click', function() {
376
jQuery('#yasr-import-gdstar-div').toggle();
377
});
378
381
382
jQuery('#yasr-loader-importer').show();
383
384
+ var data = {
385
action : 'yasr_import_step1'
386
};
387
400
var data = {
401
action: 'yasr_import_multi_set'
402
};
403
+
404
jQuery.post(ajaxurl, data, function(response) {
405
jQuery('#yasr-loader-importer2').hide();
406
jQuery('#result-import').append(response);
427
jQuery('#yasr-multi-set-doc-box').toggle("slow");
428
});
429
430
+ if (nMultiSet == 1) {
431
432
var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
433
439
jQuery('#yasr-element-limit').show();
440
jQuery('#yasr-add-field-edit-multiset').hide();
441
return false;
442
+ }
443
+
444
var newTextBoxDiv = jQuery(document.createElement('tr'))
445
+
446
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
447
+
448
newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
449
+
450
counter++;
451
452
});
454
455
} //End if ($n_multi_set == 1)
456
457
+ if (nMultiSet > 1) {
458
459
//If more then 1 set is used...
460
jQuery('#yasr-button-select-set-edit-form').on("click", function() {
461
+
462
var data = {
463
action : 'yasr_get_multi_set',
464
set_id : jQuery('#yasr_select_edit_set').val()
465
+ }
466
+
467
jQuery.post(ajaxurl, data, function(response) {
468
jQuery('#yasr-multi-set-response').show();
469
jQuery('#yasr-multi-set-response').html(response);
473
preventDefault(); // same thing as above
474
475
});
476
+
477
jQuery(document).ajaxComplete(function(){
478
479
var counter = jQuery("#yasr-edit-form-number-elements").attr('value');
480
481
counter++;
482
+
483
jQuery("#yasr-add-field-edit-multiset").on('click', function() {
484
+
485
if(counter>9){
486
jQuery('#yasr-element-limit').show();
487
jQuery('#yasr-add-field-edit-multiset').hide();
488
return false;
489
+ }
490
+
491
var newTextBoxDiv = jQuery(document.createElement('tr'))
492
+
493
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
494
+
495
newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
496
+
497
counter++;
498
499
});
500
+
501
});
502
503
+ } //End if ($n_multi_set > 1)
504
+
505
506
507
} //end if active_tab=='manage_multi'
508
527
528
jQuery('#yasr-ask-five-stars').hide();
529
530
+ var data = {
531
action: 'yasr_hide_ask_rating_metabox',
532
choose: 'hide',
533
nonce: nonceHideAskRating
544
545
jQuery('#yasr-ask-five-stars').hide();
546
547
+ var data = {
548
action: 'yasr_hide_ask_rating_metabox',
549
choose: 'close',
550
nonce: nonceHideAskRating
588
589
});
590
591
+ // Add shortcode for overall rating
592
jQuery('#yasr-overall').on("click", function(){
593
jQuery('#yasr-overall-choose-size').toggle('slow');
594
});
597
var shortcode = '[yasr_overall_rating size="small"]';
598
// inserts the shortcode into the active editor
599
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
600
+ // close
601
+ tb_remove();
602
+ //jQuery('#yasr-tinypopup-form').dialog('close');
603
});
604
605
jQuery('#yasr-overall-insert-medium').on("click", function(){
606
var shortcode = '[yasr_overall_rating size="medium"]';
607
// inserts the shortcode into the active editor
608
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
609
+ // close
610
+ tb_remove();
611
});
612
613
jQuery('#yasr-overall-insert-large').on("click", function(){
614
var shortcode = '[yasr_overall_rating size="large"]';
615
// inserts the shortcode into the active editor
616
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
617
+ // close
618
+ tb_remove();
619
});
620
621
//Add shortcode for visitors rating
624
});
625
626
jQuery('#yasr-visitor-insert-small').on("click", function(){
627
+ var shortcode = '[yasr_visitor_votes size="small"]';
628
// inserts the shortcode into the active editor
629
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
630
// closes Thickbox
631
+ tb_remove();
632
});
633
634
jQuery('#yasr-visitor-insert-medium').on("click", function(){
635
+ var shortcode = '[yasr_visitor_votes size="medium"]';
636
// inserts the shortcode into the active editor
637
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
638
// closes Thickbox
639
+ tb_remove();
640
});
641
642
jQuery('#yasr-visitor-insert-large').on("click", function(){
643
+ var shortcode = '[yasr_visitor_votes size="large"]';
644
// inserts the shortcode into the active editor
645
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
646
// closes Thickbox
647
+ tb_remove();
648
});
649
650
+ if (nMultiSet > 1) {
651
652
//Add shortcode for multiple set
653
jQuery('#yasr-insert-multiset-select').on("click", function(){
655
var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
656
657
if (!visitorSet) {
658
+
659
var shortcode = '[yasr_visitor_multiset setid=';
660
661
}
670
shortcode += ']';
671
// inserts the shortcode into the active editor
672
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
673
+ // closes Thickbox
674
+ tb_remove();
675
});
676
677
} //End if
678
679
+ else if (nMultiSet==1) {
680
681
//Add shortcode for single set (if only 1 are found)
682
jQuery('#yasr-single-set').on("click", function(){
685
var visitorSet = jQuery("#yasr-allow-vote-multiset").is(':checked');
686
687
if (!visitorSet) {
688
+
689
var shortcode = '[yasr_visitor_multiset setid=';
690
691
}
700
shortcode += ']';
701
// inserts the shortcode into the active editor
702
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
703
+ // closes Thickbox
704
+ tb_remove();
705
});
706
707
+ } //End elseif
708
709
// Add shortcode for top 10 by overall ratings
710
jQuery('#yasr-top-10-overall-rating').on("click", function(){
711
var shortcode = '[yasr_top_ten_highest_rated]';
712
// inserts the shortcode into the active editor
713
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
714
+ // closes Thickbox
715
+ tb_remove();
716
});
717
718
// Add shortcode for 10 highest most rated
720
var shortcode = '[yasr_most_or_highest_rated_posts]';
721
// inserts the shortcode into the active editor
722
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
723
+ // closes Thickbox
724
+ tb_remove();
725
});
726
727
// Add shortcode for top 5 active reviewer
729
var shortcode = '[yasr_top_5_reviewers]';
730
// inserts the shortcode into the active editor
731
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
732
+ // closes Thickbox
733
+ tb_remove();
734
});
735
736
// Add shortcode for top 10 active users
738
var shortcode = '[yasr_top_ten_active_users]';
739
// inserts the shortcode into the active editor
740
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
741
+ // closes Thickbox
742
+ tb_remove();
743
});
744
745
} //End function
756
757
jQuery('#yasr-loader-log-metabox').show();
758
759
+ var data = {
760
action : 'yasr_change_log_page',
761
pagenum: jQuery(this).val(),
762
totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')
776
777
jQuery('#yasr-loader-log-metabox').show();
778
779
+ var data = {
780
action : 'yasr_change_log_page',
781
pagenum: jQuery(this).val(),
782
totalpages: jQuery('#yasr-log-total-pages').data('yasr-log-total-pages')
802
803
jQuery('#yasr-loader-user-log-metabox').show();
804
805
+ var data = {
806
action : 'yasr_change_user_log_page',
807
pagenum: jQuery(this).val(),
808
totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-user-log-total-pages')
812
jQuery.post(ajaxurl, data, function(response) {
813
jQuery('#yasr-loader-log-metabox').hide();
814
jQuery('#yasr-user-log-container').html(response);
815
+ });
816
817
});
818
822
823
jQuery('#yasr-loader-user-log-metabox').show();
824
825
+ var data = {
826
action : 'yasr_change_user_log_page',
827
pagenum: jQuery(this).val(),
828
totalpages: jQuery('#yasr-user-log-total-pages').data('yasr-user-log-total-pages')
838
839
});
840
841
+ /****** End yasr db functions ******/
js/yasr-front.js CHANGED
@@ -3,8 +3,6 @@
3
4
yasrCommonData (postid, ajaxurl, loggedUser, visitorStatsEnabled, loaderHtml, tooltipValues)
5
6
- yasrVisitorsVotesData (, postid, starSize, nonceVisitor, )
7
-
8
yasrMultiSetData (setType, nonce)
9
10
@@ -28,13 +26,6 @@ document.addEventListener('DOMContentLoaded', function(event) {
28
29
}
30
31
- //If is not undefined yasrMultiSetData means that the shortcode yasr_visitor_multiset is used
32
- if (typeof yasrMultiSetData !== 'undefined') {
33
-
34
- yasrVisitorsMultiSet ();
35
-
36
- }
37
-
38
});
39
40
@@ -45,7 +36,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
45
jQuery('.rateit').bind('over', function (event, value) { jQuery(this).attr('title', yasrCommonData.tooltipValues[value-1]); });
46
47
//on vote...
48
- jQuery('.rateit').on('rated', function() {
49
50
var el = jQuery(this);
51
var value = el.rateit('value');
@@ -58,7 +49,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
58
59
if (value < 1) {
60
jQuery('#yasr_visitor_votes_' + postid).html('You can\'t vote 0');
61
- }
62
63
else {
64
@@ -93,10 +84,10 @@ document.addEventListener('DOMContentLoaded', function(event) {
93
//Send value to the Server
94
jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
95
//response
96
- jQuery('#yasr_visitor_votes_' + postid).html(response);
97
jQuery('.rateit').rateit();
98
99
- }) ;
100
101
} //End else value <1
102
@@ -107,18 +98,18 @@ document.addEventListener('DOMContentLoaded', function(event) {
107
/*** End Yasr Visitor Votes ***/
108
109
110
- function yasrVisitorsMultiSet () {
111
112
//will have field id and vote
113
var ratingObject = "";
114
115
//an array with all the ratingonjects
116
- var ratingArray = new Array();
117
118
- jQuery('.yasr-visitor-multi-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).on('rated', function() {
119
var el = jQuery(this);
120
var value = el.rateit('value');
121
- var value = value.toFixed(1);
122
var idField = el.attr('id');
123
124
ratingObject = {
@@ -133,31 +124,32 @@ document.addEventListener('DOMContentLoaded', function(event) {
133
134
});
135
136
- jQuery('#yasr-send-visitor-multiset-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).on('click', function() {
137
138
- jQuery('#yasr-send-visitor-multiset-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).hide();
139
140
141
- jQuery('#yasr-loader-multiset-visitor-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).show();
142
143
var data = {
144
145
action: 'yasr_visitor_multiset_field_vote',
146
- nonce: yasrMultiSetData.nonce,
147
- post_id: yasrMultiSetData.postid,
148
rating: ratingArray,
149
- set_type: yasrMultiSetData.setType
150
151
}
152
153
//Send value to the Server
154
- jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
155
- jQuery('#yasr-loader-multiset-visitor-'+yasrMultiSetData.postid+'-'+yasrMultiSetData.setType).text(response);
156
});
157
158
});
159
160
- } //End function
161
162
163
function yasrMostOrHighestRatedChart () {
@@ -211,7 +203,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
211
j=j+1;
212
213
}
214
-
215
}
216
217
//used in shortcode page and ajax page
@@ -237,7 +229,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
237
tipsContent(response);
238
});
239
240
- }
241
242
else {
243
return varTipsContent;
@@ -245,8 +237,8 @@ document.addEventListener('DOMContentLoaded', function(event) {
245
246
},
247
disabled: true,
248
- close: function( event, ui ) {
249
- jQuery(this).tooltip('disable');
250
}
251
252
});
@@ -281,9 +273,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
281
j=j+1;
282
283
}
284
-
285
}
286
287
/****** End progressbar function *******/
288
-
289
-
3
4
yasrCommonData (postid, ajaxurl, loggedUser, visitorStatsEnabled, loaderHtml, tooltipValues)
5
6
yasrMultiSetData (setType, nonce)
7
8
26
27
}
28
29
});
30
31
36
jQuery('.rateit').bind('over', function (event, value) { jQuery(this).attr('title', yasrCommonData.tooltipValues[value-1]); });
37
38
//on vote...
39
+ jQuery('.yasr_visitor_votes_stars_div').on('rated', function() {
40
41
var el = jQuery(this);
42
var value = el.rateit('value');
49
50
if (value < 1) {
51
jQuery('#yasr_visitor_votes_' + postid).html('You can\'t vote 0');
52
+ }
53
54
else {
55
84
//Send value to the Server
85
jQuery.post(yasrCommonData.ajaxurl, data, function(response) {
86
//response
87
+ jQuery('#yasr_visitor_votes_' + postid).html(response);
88
jQuery('.rateit').rateit();
89
90
+ }) ;
91
92
} //End else value <1
93
98
/*** End Yasr Visitor Votes ***/
99
100
101
+ function yasrVisitorsMultiSet (postId, setType, ajaxurl, nonce) {
102
103
//will have field id and vote
104
var ratingObject = "";
105
106
//an array with all the ratingonjects
107
+ var ratingArray = [];
108
109
+ jQuery('.yasr-visitor-multi-'+postId+'-'+setType).on('rated', function() {
110
var el = jQuery(this);
111
var value = el.rateit('value');
112
+ var value = value.toFixed(1);
113
var idField = el.attr('id');
114
115
ratingObject = {
124
125
});
126
127
+ jQuery('#yasr-send-visitor-multiset-'+postId+'-'+setType).on('click', function() {
128
129
+ jQuery('#yasr-send-visitor-multiset-'+postId+'-'+setType).hide();
130
131
+ var cookiename = "yasr_multi_visitor_vote_" + postId+'_'+setType;
132
133
+ jQuery('#yasr-loader-multiset-visitor-'+postId+'-'+setType).show();
134
135
var data = {
136
137
action: 'yasr_visitor_multiset_field_vote',
138
+ nonce: nonce,
139
+ post_id: postId,
140
rating: ratingArray,
141
+ set_type: setType
142
143
}
144
145
//Send value to the Server
146
+ jQuery.post(ajaxurl, data, function(response) {
147
+ jQuery('#yasr-loader-multiset-visitor-'+postId+'-'+setType).text(response);
148
});
149
150
});
151
152
+ } //End function
153
154
155
function yasrMostOrHighestRatedChart () {
203
j=j+1;
204
205
}
206
+
207
}
208
209
//used in shortcode page and ajax page
229
tipsContent(response);
230
});
231
232
+ }
233
234
else {
235
return varTipsContent;
237
238
},
239
disabled: true,
240
+ close: function( event, ui ) {
241
+ jQuery(this).tooltip('disable');
242
}
243
244
});
273
j=j+1;
274
275
}
276
+
277
}
278
279
/****** End progressbar function *******/
js/yasr-shortcode-creator.js ADDED
@@ -0,0 +1,17 @@
1
+ // executes this when the DOM is ready
2
+ jQuery(document).ready(function(){
3
+
4
+ var data = {
5
+ action: 'yasr_create_shortcode'
6
+ }
7
+
8
+ jQuery.post(ajaxurl, data, function(button_content) {
9
+
10
+ var response=button_content;
11
+
12
+ jQuery(response).appendTo('body').hide();
13
+
14
+ });
15
+ });
16
+
17
+ //});
lib/yasr-admin-actions.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
3
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
@@ -29,7 +29,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
29
}
30
31
32
- //DElete caches for wp_super_Cache and wp_rocket
33
add_action('yasr_action_on_visitor_vote', 'yasr_delete_cache' );
34
add_action('yasr_action_on_update_visitor_vote', 'yasr_delete_cache');
35
@@ -42,4 +42,4 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
42
43
}
44
45
- ?>
1
+ <?php
2
3
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
29
}
30
31
32
+ //Delete caches for wp_super_Cache and wp_rocket
33
add_action('yasr_action_on_visitor_vote', 'yasr_delete_cache' );
34
add_action('yasr_action_on_update_visitor_vote', 'yasr_delete_cache');
35
42
43
}
44
45
+ ?>
lib/yasr-ajax-functions.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
3
/*
4
@@ -16,6 +16,7 @@ GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>
19
*/
20
21
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
@@ -31,8 +32,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
31
function yasr_insert_overall_rating_callback() {
32
33
if (isset($_POST['rating']) && ($_POST['post_id']) && $_POST['post_id'] != '') {
34
- $rating = $_POST['rating'];
35
- $post_id = $_POST['post_id'];
36
$nonce = $_POST['nonce'];
37
}
38
@@ -45,7 +46,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
45
}
46
47
if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_insert_overall_rating' ) ) {
48
- die( 'Security check' );
49
}
50
51
if ($rating > 5) {
@@ -97,10 +98,14 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
97
}
98
99
} // End if(!$update_result)
100
-
101
if ($update_result || $replace_result) {
102
103
- if ($rating != '-1') {
104
$text = __("You've rated it ", "yet-another-stars-rating");
105
echo $text . $rating;
106
}
@@ -111,7 +116,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
111
112
}
113
114
- die(); // this is required to return a proper result
115
}
116
117
@@ -162,7 +167,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
162
}
163
164
if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_review_type' ) ) {
165
- die( 'Security check' );
166
}
167
168
global $wpdb;
@@ -204,149 +209,154 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
204
}
205
206
207
- /****** Get Set name from post or page and output the set,
208
used in yasr-metabox-multiple-rating******/
209
210
add_action( 'wp_ajax_yasr_send_id_nameset', 'yasr_output_multiple_set_callback' );
211
212
function yasr_output_multiple_set_callback() {
213
- if(isset($_POST['set_id']) && isset($_POST['post_id']) && $_POST['post_id'] != '' && $_POST['set_id'] != '' ) {
214
- $set_type = $_POST['set_id'];
215
- $post_id = $_POST['post_id'];
216
- }
217
- else {
218
- exit();
219
- }
220
221
- if ( ! current_user_can( 'publish_posts' ) ) {
222
- wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ) );
223
- }
224
225
- global $wpdb;
226
227
- $set_values=yasr_get_multi_set_values_and_field ($post_id, $set_type);
228
229
- //If this is a new post or post has no multi values data
230
- if (!$set_values) {
231
232
- echo "<p>";
233
234
- _e('Choose a vote for each element', 'yet-another-stars-rating');
235
236
- echo "
237
238
- <br /> <br />
239
240
- <table class=\"yasr_table_multi_set_admin\">";
241
- //Get Set fields name
242
- $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
243
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
244
- WHERE parent_set_id=%f
245
- ORDER BY field_id ASC",
246
- $set_type));
247
248
- foreach ($set_name as $name) {
249
250
- //// first, I've to rate all the values to -1, or if someone is leaved empty /////
251
- //// will disappear later
252
253
- //get the highest id in table cause it is not AI
254
- $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
255
-
256
- if (!$highest_id) {
257
- $new_id=0;
258
- }
259
260
- foreach ($highest_id as $id) {
261
- $new_id=$id->id + 1;
262
- }
263
264
- $query_success=$wpdb->replace(
265
- YASR_MULTI_SET_VALUES_TABLE,
266
- array (
267
- 'id'=>$new_id,
268
- 'post_id'=>$post_id,
269
- 'field_id'=>$name->id,
270
- 'votes'=>'-1',
271
- 'set_type'=>$set_type,
272
- 'number_of_votes' => '0',
273
- 'sum_votes' => '0'
274
- ),
275
- array ("%d", "%d", "%d", "%s", "%d", "%d", "%d")
276
- );
277
278
279
- echo "<tr> <td>";
280
- echo "$name->name </td>";
281
- echo "<td>
282
- <div class=\"rateit bigstars multi\" id=\"$name->id\" data-rateit-value=\"\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div>
283
-
284
- <span id=\"yasr-loader-multi-set-field-$name->id\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>
285
- </td>
286
- </tr>";
287
288
-
289
- } //End foreach
290
291
- echo "</table>
292
293
- </p>";
294
295
- echo "<p>";
296
297
- _e("If you want to insert this multiset, paste this shortcode ", 'yet-another-stars-rating');
298
- echo "<strong> [yasr_multiset setid=$set_type] </strong> <br />";
299
- _e("If, instead, you want allow your visitor to vote on this multiset, use this shortcode", 'yet-another-stars-rating');
300
- echo "<strong> [yasr_visitor_multiset setid=$set_type] </strong>. In this case, you don't need to vote here <br />";
301
302
- echo "</p>";
303
304
- } //
305
306
- //else means that post already has vote and here I show it
307
- else {
308
- _e('Choose a vote for every element', 'yet-another-stars-rating');
309
310
- echo "<table class=\"yasr_table_multi_set_admin\">";
311
312
- foreach ($set_values as $set_content) {
313
314
- echo "<tr><td width=\"50%\">$set_content->name </td>";
315
316
- $integer_vote = floor($set_content->vote);
317
- if($set_content->vote < ($integer_vote+0.3)) {
318
- $set_content->vote = $integer_vote;
319
- }
320
- elseif ($set_content->vote >= ($integer_vote+0.3) AND $set_content->vote < ($integer_vote+0.7)) {
321
- $set_content->vote = $integer_vote+0.5;
322
- }
323
- elseif ($set_content->vote >= ($integer_vote+0.7)) {
324
- $set_content->vote = $integer_vote+1;
325
- }
326
327
- echo "<td width=\"50%\">
328
- <div class=\"rateit bigstars multi\" id=\"$set_content->id\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div>
329
330
- <span id=\"yasr-loader-multi-set-field-$set_content->id\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\"></span>
331
- </td>
332
- </tr>";
333
334
335
- } //End foreach
336
337
- echo "</table>";
338
339
- echo "<p>";
340
341
- _e("If you want to insert this multiset, paste this shortcode ", 'yet-another-stars-rating');
342
- echo "<strong> [yasr_multiset setid=$set_type] </strong> <br />";
343
- _e("If, instead, you want allow your visitor to vote on this multiset, use this shortcode", 'yet-another-stars-rating');
344
- echo "<strong> [yasr_visitor_multiset setid=$set_type] </strong>. In this case, you don't need to vote here <br />";
345
346
- echo "</p>";
347
- }
348
349
- die();
350
}
351
352
@@ -377,24 +387,26 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
377
}
378
379
if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_insert_multi_rating' ) ) {
380
- die( 'Security check' );
381
}
382
383
global $wpdb;
384
385
//Check if vote already exist
386
- $vote_already_exist=$wpdb->get_results($wpdb->prepare("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . "
387
WHERE post_id = %d
388
AND set_type = %d
389
AND field_id = %d
390
- ",
391
$post_id, $set_type, $id_field));
392
393
//If vote already exist, overwrite it
394
if ($vote_already_exist) {
395
foreach ($vote_already_exist as $index_id) {
396
$id = $index_id->id;
397
- }
398
$query_success=$wpdb->update(
399
YASR_MULTI_SET_VALUES_TABLE,
400
array (
@@ -421,7 +433,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
421
422
//get the highest id in table
423
$highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
424
-
425
if (!$highest_id) {
426
$new_id=0;
427
}
@@ -449,7 +461,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
449
} //End else
450
451
die();
452
-
453
} //End callback function
454
455
@@ -472,7 +484,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
472
$multi_set=yasr_get_multi_set();
473
474
$n_multi_set=$wpdb->num_rows;
475
-
476
?>
477
478
<div id="yasr-tinypopup-form">
@@ -559,7 +571,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
559
<?php } //End foreach ?>
560
</td>
561
</tr>
562
- <?php
563
}
564
//End elseif ?>
565
</table>
@@ -606,7 +618,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
606
jQuery( document ).ready(function() {
607
608
var nMultiSet = <?php echo (json_encode("$n_multi_set")); ?>
609
-
610
yasrShortcodeCreator(nMultiSet);
611
612
});
@@ -617,7 +629,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
617
618
die();
619
620
- } //End callback function
621
622
/********** END Functions used while wirting a new post or page ********/
623
@@ -625,7 +637,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
625
626
/********* IMPORT FUNCTIONS *********/
627
628
- add_action( 'plugins_loaded', 'add_action_import_gdstar_1' );
629
630
function add_action_import_gdstar_1() {
631
if ( current_user_can( 'manage_options' ) ) {
@@ -652,7 +664,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
652
653
}
654
655
- //Import reviews from GD star
656
$reviews=yasr_import_gdstar_data();
657
658
//Insert GD star review in yasr votes table
@@ -662,7 +674,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
662
663
<div class="yasr-result-step-1">
664
<?php
665
- if ($check_query_success) {
666
_e( "Reviews and Visitor Votes have been successfull imported.", 'yet-another-stars-rating');
667
668
update_option('yasr-gdstar-imported', '1');
@@ -691,7 +703,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
691
} //End import step 1
692
693
694
- add_action( 'plugins_loaded', 'add_action_import_gdstar_2' );
695
696
function add_action_import_gdstar_2() {
697
if ( current_user_can( 'manage_options' ) ) {
@@ -717,19 +729,19 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
717
if ($insert_multi_set) {
718
echo "&nbsp;&nbsp;&nbsp;";
719
_e("Multi Set's name has been successfull imported.", 'yet-another-stars-rating');
720
- echo "<br /><strong>";
721
_e("Now I'm going to import Multi Set data", 'yet-another-stars-rating');
722
echo "</strong> <br />";
723
724
//Import multiple set's values from GD star rating
725
$multi_data=yasr_import_gdstar_multi_value();
726
727
- //If set values are found, insert Gd Star multi values in yasr_multi_values
728
if($multi_data) {
729
$insert_multidata=yasr_insert_gdstar_multi_value($multi_data);
730
if ($insert_multidata) {
731
echo "&nbsp;&nbsp;&nbsp;";
732
- _e( "All votes has been successfull imported.", 'yet-another-stars-rating');
733
echo "<br />";
734
echo "<button href=\"#\" class=\"button-delete\" id=\"end-import\">" . __('Done', 'yet-another-stars-rating') . "</button>";
735
@@ -739,24 +751,24 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
739
_e("I've found Multiple Set's votes but I couldn't insert into db", 'yet-another-stars-rating');
740
echo "<br />";
741
}
742
- } //End if $multi_data
743
744
//Multiple set are found, but there is not data
745
- else {
746
echo "&nbsp;&nbsp;&nbsp;";
747
- _e( "I've found Multi Set but with no data", 'yet-another-stars-rating');
748
echo "<br />";
749
}
750
751
} //End if $insert_multi_set
752
753
- //Query failed insert set name
754
else {
755
echo "&nbsp;&nbsp;&nbsp;";
756
_e("I've found Multi Sets names but I couldn't insert into db", 'yet-another-stars-rating');
757
echo "<br />";
758
}
759
-
760
} //End if $multi_set_names
761
762
else {
@@ -779,162 +791,162 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
779
780
add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
781
782
- function yasr_change_log_page_callback () {
783
784
- if ( ! current_user_can( 'manage_options' ) ) {
785
- wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ) );
786
- }
787
788
- if (isset($_POST['pagenum'])) {
789
790
- $page_num = $_POST['pagenum'];
791
- $num_of_pages = $_POST['totalpages'];
792
793
- }
794
795
- else {
796
- $page_num = 1;
797
- }
798
799
- $limit = 8; //max number of row to echo
800
801
- $offset = ( $page_num - 1 ) * $limit;
802
803
- global $wpdb;
804
805
- $log_result = $wpdb->get_results ("SELECT * FROM ". YASR_LOG_TABLE . " ORDER BY date DESC LIMIT $offset, $limit ");
806
807
- if (!$log_result) {
808
- _e("No Recenet votes yet", 'yet-another-stars-rating');
809
- }
810
811
- else {
812
813
- foreach ($log_result as $column) {
814
-
815
- $user = get_user_by( 'id', $column->user_id ); //Get info user from user id
816
817
- //If ! user means that the vote are anonymous
818
- if ($user == FALSE) {
819
820
- $user = (object) array('user_login');
821
- $user->user_login = __('anonymous');
822
823
- }
824
825
- $avatar = get_avatar($column->user_id, '32'); //Get avatar from user id
826
827
- $title_post = get_the_title( $column->post_id ); //Get post title from post id
828
- $link = get_permalink( $column->post_id ); //Get post link from post id
829
830
- $yasr_log_vote_text = sprintf(__('Vote %d from %s on', 'yet-another-stars-rating'), $column->vote, '<strong style="color: blue">'.$user->user_login.'</strong>' );
831
832
- echo "
833
-
834
- <div class=\"yasr-log-div-child\">
835
836
- <div class=\"yasr-log-image\">
837
- $avatar
838
- </div>
839
840
- <div class=\"yasr-log-child-head\">
841
- <span id=\"yasr-log-vote\">$yasr_log_vote_text<span id=\"yasr-log-post\"><a href=\"$link\"> $title_post</a></span>
842
- </div>
843
844
- <div class=\"yasr-log-ip-date\">
845
846
- <span class=\"yasr-log-ip\">" . __("Ip address" , 'yet-another-stars-rating') . ": <span style=\"color:blue\">$column->ip</span></span>
847
848
- <span class=\"yasr-log-date\">$column->date</span>
849
850
</div>
851
852
- </div>
853
-
854
- ";
855
-
856
- } //End foreach
857
858
- echo "<div id=\"yasr-log-page-navigation\">";
859
860
- //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
861
- //the "last" button coul not exists
862
- echo "<span id=\"yasr-log-total-pages\" data-yasr-log-total-pages=\"$num_of_pages\">";
863
864
- _e("Pages", 'yet-another-stars-rating'); echo ": ($num_of_pages) &nbsp;&nbsp;&nbsp;";
865
866
- echo "</span>";
867
868
- if ($num_of_pages <= 3) {
869
-
870
- for ($i=1; $i<=$num_of_pages; $i++) {
871
872
- if ($i == $page_num) {
873
- echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
874
- }
875
876
- else {
877
- echo "<button class=\"yasr-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
878
879
}
880
-
881
- }
882
883
- echo "<span id=\"yasr-loader-log-metabox\" style=\"display:none;\">&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>";
884
885
- }
886
887
- else {
888
889
- $start_for = $page_num - 1;
890
891
- if ($start_for <= 0) {
892
- $start_for = 1;
893
- }
894
895
- $end_for = $page_num + 1;
896
897
- if ($end_for >= $num_of_pages) {
898
- $end_for = $num_of_pages;
899
}
900
901
- if ($page_num >= 3) {
902
- echo "<button class=\"yasr-log-page-num\" value=\"1\">&laquo; First </button>&nbsp;&nbsp;...&nbsp;&nbsp;";
903
- }
904
905
- for ($i=$start_for; $i<=$end_for; $i++) {
906
907
- if ($i == $page_num) {
908
- echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
909
- }
910
911
- else {
912
- echo "<button class=\"yasr-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
913
}
914
915
- }
916
-
917
- $num_of_page_less_one = $num_of_pages-1;
918
919
- if ($page_num != $num_of_pages && $page_num != $num_of_page_less_one) {
920
- echo "...&nbsp;&nbsp;<button class=\"yasr-log-page-num\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
921
- }
922
923
- echo "<span id=\"yasr-loader-log-metabox\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>";
924
925
- }
926
927
- echo "
928
929
- </div>
930
931
- </div>";
932
933
- } // End else if !$log result
934
935
- die();
936
937
- }
938
939
940
add_action( 'wp_ajax_yasr_change_user_log_page', 'yasr_change_user_log_page_callback' );
@@ -953,7 +965,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
953
$page_num = 1;
954
}
955
956
- $limit = 8; //max number of row to echo
957
958
$offset = ( $page_num - 1 ) * $limit;
959
@@ -976,10 +988,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
976
$title_post = get_the_title( $column->post_id ); //Get post title from post id
977
$link = get_permalink( $column->post_id ); //Get post link from post id
978
979
- $yasr_log_vote_text = sprintf(__('You rated %s on ', 'yet-another-stars-rating'), '<strong style="color: blue">'.$column->vote.'</strong>');
980
981
echo "
982
-
983
<div class=\"yasr-log-div-child\">
984
985
<div class=\"yasr-log-image\">
@@ -999,14 +1011,14 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
999
</div>
1000
1001
</div>
1002
-
1003
";
1004
-
1005
} //End foreach
1006
1007
echo "<div id=\"yasr-log-page-navigation\">";
1008
1009
- //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
1010
//the "last" button coul not exists
1011
//This is required on ajax, not here, but still doing it here to take it simple
1012
echo "<span id=\"yasr-user-log-total-pages\" data-yasr-user-log-total-pages=\"$num_of_pages\">";
@@ -1016,7 +1028,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1016
echo "</span>";
1017
1018
if ($num_of_pages <= 3) {
1019
-
1020
for ($i=1; $i<=$num_of_pages; $i++) {
1021
1022
if ($i == $page_num) {
@@ -1027,7 +1039,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1027
echo "<button class=\"yasr-user-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
1028
1029
}
1030
-
1031
}
1032
1033
@@ -1144,7 +1156,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1144
/********************* NON Admin ajax functions ****************/
1145
1146
/****** Yasr insert visitor votes, called from yasr-shortcode-function ******/
1147
-
1148
add_action( 'wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
1149
add_action( 'wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
1150
@@ -1169,7 +1181,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1169
}
1170
1171
if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1172
- die( 'Security check' );
1173
}
1174
1175
$row_exists_result=NULL; //Avoid Undefined variable notice
@@ -1200,15 +1212,17 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1200
1201
do_action('yasr_action_on_visitor_vote', $post_id);
1202
1203
1204
global $wpdb;
1205
1206
- $row_exists = $wpdb->get_results($wpdb->prepare("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . "
1207
- WHERE post_id=%d",
1208
- $post_id));
1209
1210
//If post already has vote, find where it is and sum it
1211
if ($row_exists) {
1212
foreach ($row_exists as $user_votes) {
1213
$number_of_votes = $user_votes->number_of_votes;
1214
$user_votes_sum = $user_votes->sum_votes;
@@ -1221,15 +1235,15 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1221
YASR_VOTES_TABLE,
1222
array (
1223
'number_of_votes' => $number_of_votes,
1224
- 'sum_votes' => $user_votes_sum,
1225
),
1226
array (
1227
'post_id' => $post_id
1228
),
1229
array('%d', '%s' ),
1230
- array( '%d' )
1231
);
1232
-
1233
} //End if row_exists
1234
1235
else {
@@ -1271,7 +1285,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1271
'vote' => $rating,
1272
'date' => date('Y-m-d H:i:s'),
1273
'ip' => $ip_adress
1274
- ),
1275
array ('%d', '%d', '%d', '%s', '%s', '%s')
1276
);
1277
}
@@ -1293,7 +1307,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1293
echo "<div class=\"$rateit_class\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1294
<span class=\"yasr-total-average-text\" title=\"yasr-stats\"> [" . __("Total: ", 'yet-another-stars-rating') . "$number_of_votes &nbsp; &nbsp;" . __("Average:", 'yet-another-stars-rating') . " $rating/5 ]</span>
1295
<span class=\"yasr-small-block-bold\" id=\"yasr-vote-saved\">" . __("Vote Saved" , 'yet-another-stars-rating') . "</span>";
1296
-
1297
}
1298
1299
die(); // this is required to return a proper result
@@ -1301,7 +1315,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1301
1302
1303
/****** Update vote for logged in user ******/
1304
-
1305
add_action( 'wp_ajax_yasr_update_visitor_rating', 'yasr_update_visitor_rating_callback' );
1306
add_action( 'wp_ajax_nopriv_yasr_update_visitor_rating', 'yasr_update_visitor_rating_callback' );
1307
@@ -1320,22 +1334,23 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1320
}
1321
1322
}
1323
-
1324
else {
1325
exit();
1326
}
1327
1328
-
1329
-
1330
if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1331
- die( 'Security check' );
1332
}
1333
1334
if ($new_rating < 1) {
1335
_e("Error: you can't vote 0", 'yet-another-stars-rating');
1336
die();
1337
}
1338
1339
elseif ($new_rating > 5 ) {
1340
$rating = 5;
1341
}
@@ -1353,8 +1368,13 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1353
$px_size = '32';
1354
}
1355
1356
do_action('yasr_action_on_update_visitor_vote', $post_id);
1357
1358
global $wpdb;
1359
1360
$all_post_votes = $wpdb->get_results($wpdb->prepare("SELECT sum_votes, number_of_votes FROM " . YASR_VOTES_TABLE . " WHERE post_id=%d", $post_id));
@@ -1362,8 +1382,14 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1362
global $current_user;
1363
get_currentuserinfo();
1364
1365
- $previous_vote = $wpdb->get_results($wpdb->prepare("SELECT vote FROM " . YASR_LOG_TABLE . " WHERE user_id=%d AND post_id=%d", $current_user->ID, $post_id));
1366
1367
1368
foreach ($all_post_votes as $votes) {
1369
$old_votes_sum = $votes->sum_votes;
@@ -1376,16 +1402,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1376
$number_of_votes = 1;
1377
}
1378
1379
- foreach ($previous_vote as $vote) {
1380
- $old_vote = $vote->vote;
1381
- }
1382
-
1383
- //just to be sure it's not negative
1384
- if ($old_vote < 0) {
1385
-
1386
- $old_vote = 0;
1387
-
1388
- }
1389
1390
//Calculate the new sum: get the old sum and subtract the old vote
1391
$new_sum = $old_votes_sum - $old_vote;
@@ -1403,12 +1419,11 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1403
'post_id' => $post_id
1404
),
1405
array( '%s' ),
1406
- array( '%d' )
1407
);
1408
1409
1410
//Update the log table
1411
-
1412
$update_log = $wpdb->update (
1413
YASR_LOG_TABLE,
1414
array (
@@ -1424,15 +1439,14 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1424
1425
1426
$total_rating = ($new_sum / $number_of_votes);
1427
- $medium_rating=round ($total_rating, 1);
1428
-
1429
1430
echo "<div class=\"$rateit_class\" id=\"yasr-rateit-user-votes-updated\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$total_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
1431
1432
if (YASR_VISITORS_STATS === 'yes') {
1433
echo "<span class=\"yasr-total-average-text\"><span class=\"dashicons dashicons-chart-bar\" id=\"yasr-total-average-$post_id\"></span>[" . __("Total: ", 'yet-another-stars-rating') . "$number_of_votes &nbsp; &nbsp;" . __("Average $medium_rating/5" , 'yet-another-stars-rating') . "]</span>";
1434
}
1435
-
1436
echo "<span class=\"yasr-small-block-bold\" id=\"yasr-already-voted-text\">" . __("Vote updated", 'yet-another-stars-rating') . "</span>";
1437
1438
die(); // this is required to return a proper result
@@ -1458,7 +1472,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1458
}
1459
1460
if ($rating == "") {
1461
- exit("You must insert at least a rating");
1462
}
1463
1464
}
@@ -1467,24 +1481,26 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1467
}
1468
1469
if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_insert_visitor_rating_multiset' ) ) {
1470
- die( 'Security check' );
1471
}
1472
1473
global $wpdb;
1474
1475
$array_error = array();
1476
1477
foreach ($rating as $rating_values) {
1478
-
1479
$id_field = $rating_values['field'];
1480
$rating = $rating_values['rating'];
1481
1482
//Find the existing votes
1483
- $existing_vote=$wpdb->get_results($wpdb->prepare("SELECT number_of_votes, sum_votes FROM " . YASR_MULTI_SET_VALUES_TABLE . "
1484
WHERE post_id = %d
1485
AND set_type = %d
1486
AND field_id = %d
1487
- ",
1488
$post_id, $set_type, $id_field));
1489
1490
if(!empty($existing_vote)) {
@@ -1509,7 +1525,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1509
'set_type' => $set_type
1510
),
1511
array('%d', '%s' ),
1512
- array( '%d', '%d', '%d' )
1513
);
1514
1515
}
@@ -1517,17 +1533,15 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1517
else {
1518
1519
//Find the highest_id (it's not auto increment on db due to gd star compatibility)
1520
- $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
1521
-
1522
//highest id is 0 in data is empty
1523
if (!$highest_id) {
1524
$new_id=0;
1525
}
1526
1527
- //or is n+1
1528
- foreach ($highest_id as $id) {
1529
- $new_id=$id->id + 1;
1530
- }
1531
1532
1533
$query_success=$wpdb->replace(
@@ -1548,7 +1562,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1548
1549
if ($query_success) {
1550
1551
- $array_error[] = 0;
1552
1553
}
1554
@@ -1563,7 +1577,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1563
$error_found = FALSE;
1564
1565
foreach ($array_error as $error) {
1566
-
1567
if ($error === 1) {
1568
1569
$error_found = TRUE;
@@ -1589,7 +1603,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1589
}
1590
1591
die();
1592
-
1593
} //End callback function
1594
1595
@@ -1611,7 +1625,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1611
global $wpdb;
1612
1613
$stats = $wpdb->get_results( $wpdb->prepare ("SELECT ROUND( vote, 0 ) as vote, COUNT( vote ) AS n_of_votes
1614
- FROM ". YASR_LOG_TABLE . "
1615
WHERE post_id=%d
1616
GROUP BY vote
1617
ORDER BY vote DESC
@@ -1620,8 +1634,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1620
ARRAY_A);
1621
1622
$total_votes=0; //Avoid undefined variable if stats exists. Necessary if $stats not exists
1623
-
1624
- //if query return 0 wirte an empty array $existing_votes
1625
if (!$stats) {
1626
$existing_votes = array();
1627
}
@@ -1649,7 +1663,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1649
//If in the new array there are some vote missing create a new array
1650
if(!in_array($i, $existing_votes)) {
1651
$missing_vote[$i] = array();
1652
- $missing_vote[$i]['vote'] = $i;
1653
$missing_vote[$i]['n_of_votes'] = 0;
1654
}
1655
@@ -1657,7 +1671,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1657
1658
}
1659
1660
- //If missing_vote exists merge it
1661
if ($missing_vote) {
1662
1663
$stats = array_merge($stats, $missing_vote);
@@ -1684,28 +1698,28 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1684
if ($i==1) {
1685
$stars_text = __("star", 'yet-another-stars-rating');
1686
}
1687
-
1688
echo "<div class=\"yasr-progress-bar-row-container\">
1689
<span class=\"yasr-progress-bar-name\">$i $stars_text</span>
1690
<span class=\"yasr-progress-bar\" id=\"yasr-progress-bar-postid-$post_id-progress-bar-$i\" ></span>
1691
<span class=\"yasr-progress-bar-votes-count\">$logged_votes[n_of_votes]</span>
1692
- </div>";
1693
-
1694
$value_progressbar = $increase_bar_value * $logged_votes['n_of_votes']; //value of the single bar
1695
1696
$value_progressbar = round ($value_progressbar, 2); //use only 2 decimal
1697
1698
- $array_values_progressbar[] = $value_progressbar;
1699
1700
$i--;
1701
-
1702
1703
} //End foreach
1704
1705
echo "</div>";
1706
1707
?>
1708
-
1709
<script type="text/javascript">
1710
jQuery( document ).ready(function() {
1711
1
+ <?php
2
3
/*
4
16
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>
19
+
20
*/
21
22
if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
32
function yasr_insert_overall_rating_callback() {
33
34
if (isset($_POST['rating']) && ($_POST['post_id']) && $_POST['post_id'] != '') {
35
+ $rating = $_POST['rating'];
36
+ $post_id = $_POST['post_id'];
37
$nonce = $_POST['nonce'];
38
}
39
46
}
47
48
if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_insert_overall_rating' ) ) {
49
+ die( 'Security check' );
50
}
51
52
if ($rating > 5) {
98
}
99
100
} // End if(!$update_result)
101
+
102
if ($update_result || $replace_result) {
103
104
+ $transient_name = 'yasr_overall_rating_' . $post_id;
105
+
106
+ set_transient( $transient_name, $rating, WEEK_IN_SECONDS );
107
+
108
+ if ($rating != '-1') {
109
$text = __("You've rated it ", "yet-another-stars-rating");
110
echo $text . $rating;
111
}
116
117
}
118
119
+ die(); // this is required to return a proper result
120
}
121
122
167
}
168
169
if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_review_type' ) ) {
170
+ die( 'Security check' );
171
}
172
173
global $wpdb;
209
}
210
211
212
+ /****** Get Set name from post or page and output the set,
213
used in yasr-metabox-multiple-rating******/
214
215
add_action( 'wp_ajax_yasr_send_id_nameset', 'yasr_output_multiple_set_callback' );
216
217
function yasr_output_multiple_set_callback() {
218
219
+ if(isset($_POST['set_id']) && isset($_POST['post_id']) && $_POST['post_id'] != '' && $_POST['set_id'] != '' ) {
220
+ $set_type = $_POST['set_id'];
221
+ $post_id = $_POST['post_id'];
222
+ }
223
+ else {
224
+ exit();
225
+ }
226
227
+ if ( ! current_user_can( 'publish_posts' ) ) {
228
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ) );
229
+ }
230
231
+ global $wpdb;
232
233
+ //delete transient first
234
+ delete_transient( 'yasr_get_multi_set_values_and_field_' . $post_id . '_' . $set_type );
235
236
+ $set_values=yasr_get_multi_set_values_and_field ($post_id, $set_type);
237
238
+ //If this is a new post or post has no multi values data
239
+ if (!$set_values) {
240
241
+ echo "<p>";
242
243
+ _e('Choose a vote for each element', 'yet-another-stars-rating');
244
245
+ echo "
246
247
+ <br /> <br />
248
249
+ <table class=\"yasr_table_multi_set_admin\">";
250
+ //Get Set fields name
251
+ $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
252
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
253
+ WHERE parent_set_id=%f
254
+ ORDER BY field_id ASC",
255
+ $set_type));
256
257
+ foreach ($set_name as $name) {
258
259
+ //// first, I've to rate all the values to -1, or if someone is leaved empty /////
260
+ //// will disappear later
261
262
+ //get the highest id in table cause it is not AI
263
+ $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
264
265
+ if (!$highest_id) {
266
+ $new_id=0;
267
+ }
268
269
+ foreach ($highest_id as $id) {
270
+ $new_id=$id->id + 1;
271
+ }
272
273
+ $query_success=$wpdb->replace(
274
+ YASR_MULTI_SET_VALUES_TABLE,
275
+ array (
276
+ 'id'=>$new_id,
277
+ 'post_id'=>$post_id,
278
+ 'field_id'=>$name->id,
279
+ 'votes'=>'-1',
280
+ 'set_type'=>$set_type,
281
+ 'number_of_votes' => '0',
282
+ 'sum_votes' => '0'
283
+ ),
284
+ array ("%d", "%d", "%d", "%s", "%d", "%d", "%d")
285
+ );
286
287
288
+ echo "<tr> <td>";
289
+ echo "$name->name </td>";
290
+ echo "<td>
291
+ <div class=\"rateit bigstars multi\" id=\"$name->id\" data-rateit-value=\"\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div>
292
293
+ <span id=\"yasr-loader-multi-set-field-$name->id\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>
294
+ </td>
295
+ </tr>";
296
297
298
+ } //End foreach
299
300
+ echo "</table>
301
302
+ </p>";
303
304
+ echo "<p>";
305
306
+ _e("If you want to insert this multiset, paste this shortcode ", 'yet-another-stars-rating');
307
+ echo "<strong> [yasr_multiset setid=$set_type] </strong> <br />";
308
+ _e("If, instead, you want allow your visitor to vote on this multiset, use this shortcode", 'yet-another-stars-rating');
309
+ echo "<strong> [yasr_visitor_multiset setid=$set_type] </strong>. In this case, you don't need to vote here <br />";
310
311
+ echo "</p>";
312
313
+ } //
314
315
+ //else means that post already has vote and here I show it
316
+ else {
317
+ _e('Choose a vote for every element', 'yet-another-stars-rating');
318
319
+ echo "<table class=\"yasr_table_multi_set_admin\">";
320
321
+ foreach ($set_values as $set_content) {
322
323
+ echo "<tr><td width=\"50%\">$set_content->name </td>";
324
325
+ $integer_vote = floor($set_content->vote);
326
+ if($set_content->vote < ($integer_vote+0.3)) {
327
+ $set_content->vote = $integer_vote;
328
+ }
329
+ elseif ($set_content->vote >= ($integer_vote+0.3) AND $set_content->vote < ($integer_vote+0.7)) {
330
+ $set_content->vote = $integer_vote+0.5;
331
+ }
332
+ elseif ($set_content->vote >= ($integer_vote+0.7)) {
333
+ $set_content->vote = $integer_vote+1;
334
+ }
335
336
+ echo "<td width=\"50%\">
337
+ <div class=\"rateit bigstars multi\" id=\"$set_content->id\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div>
338
339
+ <span id=\"yasr-loader-multi-set-field-$set_content->id\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\"></span>
340
+ </td>
341
+ </tr>";
342
343
344
+ } //End foreach
345
+
346
+ echo "</table>";
347
+
348
+ echo "<p>";
349
+
350
+ _e("If you want to insert this multiset, paste this shortcode ", 'yet-another-stars-rating');
351
+ echo "<strong> [yasr_multiset setid=$set_type] </strong> <br />";
352
+ _e("If, instead, you want allow your visitor to vote on this multiset, use this shortcode", 'yet-another-stars-rating');
353
+ echo "<strong> [yasr_visitor_multiset setid=$set_type] </strong>. In this case, you don't need to vote here <br />";
354
+
355
+ echo "</p>";
356
+ }
357
+
358
+ die();
359
+
360
}
361
362
387
}
388
389
if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_insert_multi_rating' ) ) {
390
+ die( 'Security check' );
391
}
392
393
+ delete_transient( 'yasr_get_multi_set_values_and_field_' . $post_id . '_' . $set_type );
394
+
395
global $wpdb;
396
397
//Check if vote already exist
398
+ $vote_already_exist=$wpdb->get_results($wpdb->prepare("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . "
399
WHERE post_id = %d
400
AND set_type = %d
401
AND field_id = %d
402
+ ",
403
$post_id, $set_type, $id_field));
404
405
//If vote already exist, overwrite it
406
if ($vote_already_exist) {
407
foreach ($vote_already_exist as $index_id) {
408
$id = $index_id->id;
409
+ }
410
$query_success=$wpdb->update(
411
YASR_MULTI_SET_VALUES_TABLE,
412
array (
433
434
//get the highest id in table
435
$highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
436
+
437
if (!$highest_id) {
438
$new_id=0;
439
}
461
} //End else
462
463
die();
464
+
465
} //End callback function
466
467
484
$multi_set=yasr_get_multi_set();
485
486
$n_multi_set=$wpdb->num_rows;
487
+
488
?>
489
490
<div id="yasr-tinypopup-form">
571
<?php } //End foreach ?>
572
</td>
573
</tr>
574
+ <?php
575
}
576
//End elseif ?>
577
</table>
618
jQuery( document ).ready(function() {
619
620
var nMultiSet = <?php echo (json_encode("$n_multi_set")); ?>
621
+
622
yasrShortcodeCreator(nMultiSet);
623
624
});
629
630
die();
631
632
+ } //End callback function
633
634
/********** END Functions used while wirting a new post or page ********/
635
637
638
/********* IMPORT FUNCTIONS *********/
639
640
+ add_action( 'plugins_loaded', 'add_action_import_gdstar_1' );
641
642
function add_action_import_gdstar_1() {
643
if ( current_user_can( 'manage_options' ) ) {
664
665
}
666
667
+ //Import reviews from GD star
668
$reviews=yasr_import_gdstar_data();
669
670
//Insert GD star review in yasr votes table
674
675
<div class="yasr-result-step-1">
676
<?php
677
+ if ($check_query_success) {
678
_e( "Reviews and Visitor Votes have been successfull imported.", 'yet-another-stars-rating');
679
680
update_option('yasr-gdstar-imported', '1');
703
} //End import step 1
704
705
706
+ add_action( 'plugins_loaded', 'add_action_import_gdstar_2' );
707
708
function add_action_import_gdstar_2() {
709
if ( current_user_can( 'manage_options' ) ) {
729
if ($insert_multi_set) {
730
echo "&nbsp;&nbsp;&nbsp;";
731
_e("Multi Set's name has been successfull imported.", 'yet-another-stars-rating');
732
+ echo "<br /><strong>";
733
_e("Now I'm going to import Multi Set data", 'yet-another-stars-rating');
734
echo "</strong> <br />";
735
736
//Import multiple set's values from GD star rating
737
$multi_data=yasr_import_gdstar_multi_value();
738
739
+ //If set values are found, insert Gd Star multi values in yasr_multi_values
740
if($multi_data) {
741
$insert_multidata=yasr_insert_gdstar_multi_value($multi_data);
742
if ($insert_multidata) {
743
echo "&nbsp;&nbsp;&nbsp;";
744
+ _e( "All votes has been successfull imported.", 'yet-another-stars-rating');
745
echo "<br />";
746
echo "<button href=\"#\" class=\"button-delete\" id=\"end-import\">" . __('Done', 'yet-another-stars-rating') . "</button>";
747
751
_e("I've found Multiple Set's votes but I couldn't insert into db", 'yet-another-stars-rating');
752
echo "<br />";
753
}
754
+ } //End if $multi_data
755
756
//Multiple set are found, but there is not data
757
+ else {
758
echo "&nbsp;&nbsp;&nbsp;";
759
+ _e( "I've found Multi Set but with no data", 'yet-another-stars-rating');
760
echo "<br />";
761
}
762
763
} //End if $insert_multi_set
764
765
+ //Query failed insert set name
766
else {
767
echo "&nbsp;&nbsp;&nbsp;";
768
_e("I've found Multi Sets names but I couldn't insert into db", 'yet-another-stars-rating');
769
echo "<br />";
770
}
771
+
772
} //End if $multi_set_names
773
774
else {
791
792
add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
793
794
+ function yasr_change_log_page_callback () {
795
796
+ if ( ! current_user_can( 'manage_options' ) ) {
797
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yet-another-stars-rating' ) );
798
+ }
799
800
+ if (isset($_POST['pagenum'])) {
801
802
+ $page_num = $_POST['pagenum'];
803
+ $num_of_pages = $_POST['totalpages'];
804
805
+ }
806
807
+ else {
808
+ $page_num = 1;
809
+ }
810
811
+ $limit = 8; //max number of row to echo
812
813
+ $offset = ( $page_num - 1 ) * $limit;
814
815
+ global $wpdb;
816
817
+ $log_result = $wpdb->get_results ("SELECT * FROM ". YASR_LOG_TABLE . " ORDER BY date DESC LIMIT $offset, $limit ");
818
819
+ if (!$log_result) {
820
+ _e("No Recenet votes yet", 'yet-another-stars-rating');
821
+ }
822
823
+ else {
824
825
+ foreach ($log_result as $column) {
826
827
+ $user = get_user_by( 'id', $column->user_id ); //Get info user from user id
828
829
+ //If ! user means that the vote are anonymous
830
+ if ($user == FALSE) {
831
832
+ $user = (object) array('user_login');
833
+ $user->user_login = __('anonymous');
834
835
+ }
836
837
+ $avatar = get_avatar($column->user_id, '32'); //Get avatar from user id
838
839
+ $title_post = get_the_title( $column->post_id ); //Get post title from post id
840
+ $link = get_permalink( $column->post_id ); //Get post link from post id
841
842
+ $yasr_log_vote_text = sprintf(__('Vote %d from %s on', 'yet-another-stars-rating'), $column->vote, '<strong style="color: blue">'.$user->user_login.'</strong>' );
843
844
+ echo "
845
846
+ <div class=\"yasr-log-div-child\">
847
+
848
+ <div class=\"yasr-log-image\">
849
+ $avatar
850
+ </div>
851
852
+ <div class=\"yasr-log-child-head\">
853
+ <span id=\"yasr-log-vote\">$yasr_log_vote_text<span id=\"yasr-log-post\"><a href=\"$link\"> $title_post</a></span>
854
+ </div>
855
+
856
+ <div class=\"yasr-log-ip-date\">
857
+
858
+ <span class=\"yasr-log-ip\">" . __("Ip address" , 'yet-another-stars-rating') . ": <span style=\"color:blue\">$column->ip</span></span>
859
860
+ <span class=\"yasr-log-date\">$column->date</span>
861
862
+ </div>
863
864
</div>
865
866
+ ";
867
868
+ } //End foreach
869
870
+ echo "<div id=\"yasr-log-page-navigation\">";
871
872
+ //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
873
+ //the "last" button coul not exists
874
+ echo "<span id=\"yasr-log-total-pages\" data-yasr-log-total-pages=\"$num_of_pages\">";
875
876
+ _e("Pages", 'yet-another-stars-rating'); echo ": ($num_of_pages) &nbsp;&nbsp;&nbsp;";
877
878
+ echo "</span>";
879
880
+ if ($num_of_pages <= 3) {
881
882
+ for ($i=1; $i<=$num_of_pages; $i++) {
883
+
884
+ if ($i == $page_num) {
885
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
886
+ }
887
+
888
+ else {
889
+ echo "<button class=\"yasr-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
890
+
891
+ }
892
893
}
894
895
+ echo "<span id=\"yasr-loader-log-metabox\" style=\"display:none;\">&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>";
896
897
+ }
898
899
+ else {
900
901
+ $start_for = $page_num - 1;
902
903
+ if ($start_for <= 0) {
904
+ $start_for = 1;
905
+ }
906
907
+ $end_for = $page_num + 1;
908
909
+ if ($end_for >= $num_of_pages) {
910
+ $end_for = $num_of_pages;
911
+ }
912
+
913
+ if ($page_num >= 3) {
914
+ echo "<button class=\"yasr-log-page-num\" value=\"1\">&laquo; First </button>&nbsp;&nbsp;...&nbsp;&nbsp;";
915
}
916
917
+ for ($i=$start_for; $i<=$end_for; $i++) {
918
919
+ if ($i == $page_num) {
920
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
921
+ }
922
923
+ else {
924
+ echo "<button class=\"yasr-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
925
+ }
926
927
}
928
929
+ $num_of_page_less_one = $num_of_pages-1;
930
931
+ if ($page_num != $num_of_pages && $page_num != $num_of_page_less_one) {
932
+ echo "...&nbsp;&nbsp;<button class=\"yasr-log-page-num\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
933
+ }
934
935
+ echo "<span id=\"yasr-loader-log-metabox\" style=\"display:none;\" >&nbsp;<img src=\"" . YASR_IMG_DIR . "/loader.gif\" ></span>";
936
937
+ }
938
939
+ echo "
940
941
+ </div>
942
943
+ </div>";
944
945
+ } // End else if !$log result
946
947
+ die();
948
949
+ }
950
951
952
add_action( 'wp_ajax_yasr_change_user_log_page', 'yasr_change_user_log_page_callback' );
965
$page_num = 1;
966
}
967
968
+ $limit = 8; //max number of row to echo
969
970
$offset = ( $page_num - 1 ) * $limit;
971
988
$title_post = get_the_title( $column->post_id ); //Get post title from post id
989
$link = get_permalink( $column->post_id ); //Get post link from post id
990
991
+ $yasr_log_vote_text = sprintf(__('You rated %s on ', 'yet-another-stars-rating'), '<strong style="color: blue">'.$column->vote.'</strong>');
992
993
echo "
994
+
995
<div class=\"yasr-log-div-child\">
996
997
<div class=\"yasr-log-image\">
1011
</div>
1012
1013
</div>
1014
+
1015
";
1016
+
1017
} //End foreach
1018
1019
echo "<div id=\"yasr-log-page-navigation\">";
1020
1021
+ //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
1022
//the "last" button coul not exists
1023
//This is required on ajax, not here, but still doing it here to take it simple
1024
echo "<span id=\"yasr-user-log-total-pages\" data-yasr-user-log-total-pages=\"$num_of_pages\">";
1028
echo "</span>";
1029
1030
if ($num_of_pages <= 3) {
1031
+
1032
for ($i=1; $i<=$num_of_pages; $i++) {
1033
1034
if ($i == $page_num) {
1039
echo "<button class=\"yasr-user-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
1040
1041
}
1042
+
1043
}
1044
1045
1156
/********************* NON Admin ajax functions ****************/
1157
1158
/****** Yasr insert visitor votes, called from yasr-shortcode-function ******/
1159
+
1160
add_action( 'wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
1161
add_action( 'wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
1162
1181
}
1182
1183
if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1184
+ die( 'Security check' );
1185
}
1186
1187
$row_exists_result=NULL; //Avoid Undefined variable notice
1212
1213
do_action('yasr_action_on_visitor_vote', $post_id);
1214
1215
+ $transient_name = 'yasr_visitor_votes_' . $post_id;
1216
+
1217
+ delete_transient( $transient_name );
1218
1219
global $wpdb;
1220
1221
+ $row_exists = yasr_get_visitor_votes ($post_id, $create_transient=FALSE);
1222
1223
//If post already has vote, find where it is and sum it
1224
if ($row_exists) {
1225
+
1226
foreach ($row_exists as $user_votes) {
1227
<