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
  $number_of_votes = $user_votes->number_of_votes;
1228
  $user_votes_sum = $user_votes->sum_votes;
1235
  YASR_VOTES_TABLE,
1236
  array (
1237
  'number_of_votes' => $number_of_votes,
1238
+ 'sum_votes' => $user_votes_sum
1239
  ),
1240
  array (
1241
  'post_id' => $post_id
1242
  ),
1243
  array('%d', '%s' ),
1244
+ array( '%d' )
1245
  );
1246
+
1247
  } //End if row_exists
1248
 
1249
  else {
1285
  'vote' => $rating,
1286
  'date' => date('Y-m-d H:i:s'),
1287
  'ip' => $ip_adress
1288
+ ),
1289
  array ('%d', '%d', '%d', '%s', '%s', '%s')
1290
  );
1291
  }
1307
  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>
1308
  <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>
1309
  <span class=\"yasr-small-block-bold\" id=\"yasr-vote-saved\">" . __("Vote Saved" , 'yet-another-stars-rating') . "</span>";
1310
+
1311
  }
1312
 
1313
  die(); // this is required to return a proper result
1315
 
1316
 
1317
  /****** Update vote for logged in user ******/
1318
+
1319
  add_action( 'wp_ajax_yasr_update_visitor_rating', 'yasr_update_visitor_rating_callback' );
1320
  add_action( 'wp_ajax_nopriv_yasr_update_visitor_rating', 'yasr_update_visitor_rating_callback' );
1321
 
1334
  }
1335
 
1336
  }
1337
+
1338
  else {
1339
  exit();
1340
  }
1341
 
1342
+ //Check nonce
 
1343
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1344
+ die( 'Security check' );
1345
  }
1346
 
1347
+ //Rating can't be <1
1348
  if ($new_rating < 1) {
1349
  _e("Error: you can't vote 0", 'yet-another-stars-rating');
1350
  die();
1351
  }
1352
 
1353
+ //or >5
1354
  elseif ($new_rating > 5 ) {
1355
  $rating = 5;
1356
  }
1368
  $px_size = '32';
1369
  }
1370
 
1371
+ //create an hook
1372
  do_action('yasr_action_on_update_visitor_vote', $post_id);
1373
 
1374
+ $transient_name = 'yasr_visitor_votes_' . $post_id;
1375
+
1376
+ delete_transient( $transient_name );
1377
+
1378
  global $wpdb;
1379
 
1380
  $all_post_votes = $wpdb->get_results($wpdb->prepare("SELECT sum_votes, number_of_votes FROM " . YASR_VOTES_TABLE . " WHERE post_id=%d", $post_id));
1382
  global $current_user;
1383
  get_currentuserinfo();
1384
 
1385
+ $old_vote = $wpdb->get_var($wpdb->prepare("SELECT vote FROM " . YASR_LOG_TABLE . " WHERE user_id=%d AND post_id=%d", $current_user->ID, $post_id));
1386
 
1387
+ //just to be sure it's not negative
1388
+ if ($old_vote < 0) {
1389
+
1390
+ $old_vote = 0;
1391
+
1392
+ }
1393
 
1394
  foreach ($all_post_votes as $votes) {
1395
  $old_votes_sum = $votes->sum_votes;
1402
  $number_of_votes = 1;
1403
  }
1404
 
 
 
 
 
 
 
 
 
 
 
1405
 
1406
  //Calculate the new sum: get the old sum and subtract the old vote
1407
  $new_sum = $old_votes_sum - $old_vote;
1419
  'post_id' => $post_id
1420
  ),
1421
  array( '%s' ),
1422
+ array( '%d' )
1423
  );
1424
 
1425
 
1426
  //Update the log table
 
1427
  $update_log = $wpdb->update (
1428
  YASR_LOG_TABLE,
1429
  array (
1439
 
1440
 
1441
  $total_rating = ($new_sum / $number_of_votes);
1442
+ $medium_rating= round ($total_rating, 1);
 
1443
 
1444
  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>";
1445
 
1446
  if (YASR_VISITORS_STATS === 'yes') {
1447
  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>";
1448
  }
1449
+
1450
  echo "<span class=\"yasr-small-block-bold\" id=\"yasr-already-voted-text\">" . __("Vote updated", 'yet-another-stars-rating') . "</span>";
1451
 
1452
  die(); // this is required to return a proper result
1472
  }
1473
 
1474
  if ($rating == "") {
1475
+ exit("You must insert at least a rating");
1476
  }
1477
 
1478
  }
1481
  }
1482
 
1483
  if ( ! wp_verify_nonce( $nonce, 'yasr_nonce_insert_visitor_rating_multiset' ) ) {
1484
+ die( 'Security check' );
1485
  }
1486
 
1487
+ delete_transient( 'yasr_visitor_multi_set_' . $post_id . '_' . $set_type );
1488
+
1489
  global $wpdb;
1490
 
1491
  $array_error = array();
1492
 
1493
  foreach ($rating as $rating_values) {
1494
+
1495
  $id_field = $rating_values['field'];
1496
  $rating = $rating_values['rating'];
1497
 
1498
  //Find the existing votes
1499
+ $existing_vote=$wpdb->get_results($wpdb->prepare("SELECT number_of_votes, sum_votes FROM " . YASR_MULTI_SET_VALUES_TABLE . "
1500
  WHERE post_id = %d
1501
  AND set_type = %d
1502
  AND field_id = %d
1503
+ ",
1504
  $post_id, $set_type, $id_field));
1505
 
1506
  if(!empty($existing_vote)) {
1525
  'set_type' => $set_type
1526
  ),
1527
  array('%d', '%s' ),
1528
+ array( '%d', '%d', '%d' )
1529
  );
1530
 
1531
  }
1533
  else {
1534
 
1535
  //Find the highest_id (it's not auto increment on db due to gd star compatibility)
1536
+ $highest_id=$wpdb->get_var("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
1537
+
1538
  //highest id is 0 in data is empty
1539
  if (!$highest_id) {
1540
  $new_id=0;
1541
  }
1542
 
1543
+
1544
+ $new_id=$highest_id + 1;
 
 
1545
 
1546
 
1547
  $query_success=$wpdb->replace(
1562
 
1563
  if ($query_success) {
1564
 
1565
+ $array_error[] = 0;
1566
 
1567
  }
1568
 
1577
  $error_found = FALSE;
1578
 
1579
  foreach ($array_error as $error) {
1580
+
1581
  if ($error === 1) {
1582
 
1583
  $error_found = TRUE;
1603
  }
1604
 
1605
  die();
1606
+
1607
  } //End callback function
1608
 
1609
 
1625
  global $wpdb;
1626
 
1627
  $stats = $wpdb->get_results( $wpdb->prepare ("SELECT ROUND( vote, 0 ) as vote, COUNT( vote ) AS n_of_votes
1628
+ FROM ". YASR_LOG_TABLE . "
1629
  WHERE post_id=%d
1630
  GROUP BY vote
1631
  ORDER BY vote DESC
1634
  ARRAY_A);
1635
 
1636
  $total_votes=0; //Avoid undefined variable if stats exists. Necessary if $stats not exists
1637
+
1638
+ //if query return 0 wirte an empty array $existing_votes
1639
  if (!$stats) {
1640
  $existing_votes = array();
1641
  }
1663
  //If in the new array there are some vote missing create a new array
1664
  if(!in_array($i, $existing_votes)) {
1665
  $missing_vote[$i] = array();
1666
+ $missing_vote[$i]['vote'] = $i;
1667
  $missing_vote[$i]['n_of_votes'] = 0;
1668
  }
1669
 
1671
 
1672
  }
1673
 
1674
+ //If missing_vote exists merge it
1675
  if ($missing_vote) {
1676
 
1677
  $stats = array_merge($stats, $missing_vote);
1698
  if ($i==1) {
1699
  $stars_text = __("star", 'yet-another-stars-rating');
1700
  }
1701
+
1702
  echo "<div class=\"yasr-progress-bar-row-container\">
1703
  <span class=\"yasr-progress-bar-name\">$i $stars_text</span>
1704
  <span class=\"yasr-progress-bar\" id=\"yasr-progress-bar-postid-$post_id-progress-bar-$i\" ></span>
1705
  <span class=\"yasr-progress-bar-votes-count\">$logged_votes[n_of_votes]</span>
1706
+ </div>";
1707
+
1708
  $value_progressbar = $increase_bar_value * $logged_votes['n_of_votes']; //value of the single bar
1709
 
1710
  $value_progressbar = round ($value_progressbar, 2); //use only 2 decimal
1711
 
1712
+ $array_values_progressbar[] = $value_progressbar;
1713
 
1714
  $i--;
1715
+
1716
 
1717
  } //End foreach
1718
 
1719
  echo "</div>";
1720
 
1721
  ?>
1722
+
1723
  <script type="text/javascript">
1724
  jQuery( document ).ready(function() {
1725
 
lib/yasr-db-functions.php CHANGED
@@ -25,7 +25,7 @@ function yasr_install() {
25
  global $wpdb; //Database wordpress object
26
 
27
  $prefix=$wpdb->prefix . 'yasr_'; //Table prefix
28
-
29
  $yasr_votes_table = $prefix . 'votes';
30
  $yasr_multi_set_table = $prefix . 'multi_set';
31
  $yasr_multi_set_fields = $prefix . 'multi_set_fields';
@@ -40,7 +40,7 @@ function yasr_install() {
40
  sum_votes decimal(11,1) NOT NULL,
41
  review_type VARCHAR(10),
42
  PRIMARY KEY (id),
43
- UNIQUE KEY post_id (post_id)
44
  );";
45
 
46
  $sql_yasr_multi_set_table= "CREATE TABLE IF NOT EXISTS $yasr_multi_set_table (
@@ -82,7 +82,7 @@ function yasr_install() {
82
  PRIMARY KEY (id),
83
  UNIQUE KEY id (id)
84
  );";
85
-
86
 
87
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
88
 
@@ -103,7 +103,7 @@ function yasr_install() {
103
  $option['auto_insert_what'] = 'overall_rating';
104
  $option['auto_insert_where'] = 'top';
105
  $option['auto_insert_size']='large';
106
- $option['auto_insert_exclude_pages'] = 'yes';
107
  $option['auto_insert_custom_post_only'] = 'no';
108
  $option['show_overall_in_loop'] = 'disabled';
109
  $option['show_visitor_votes_in_loop'] = 'disabled';
@@ -122,7 +122,7 @@ function yasr_install() {
122
  $style_options['scheme_color_multiset'] = 'light';
123
 
124
  update_option("yasr_style_options", $style_options);
125
-
126
 
127
  }
128
 
@@ -131,38 +131,51 @@ function yasr_install() {
131
 
132
  /****** Get overall rating from yasr_votes table
133
  used in yasr_add_filter_for_schema() and yasr_get_id_value_callback() ******/
134
- function yasr_get_overall_rating($post_id_referenced=FALSE) {
135
  global $wpdb;
136
 
 
137
  //if values it's not passed get the post id, most of cases and default one
138
- if(!$post_id_referenced) {
139
 
140
  $post_id=get_the_ID();
141
 
142
  }
143
 
144
- //referenced is necessary for ajax calls
145
- else {
146
 
147
- $post_id = $post_id_referenced;
148
 
149
  }
150
 
151
- if (!$post_id) {
152
 
153
- return;
 
 
 
 
 
 
 
154
 
155
  }
156
 
157
- $result=$wpdb->get_results($wpdb->prepare("SELECT overall_rating FROM " . YASR_VOTES_TABLE . " WHERE post_id=%d", $post_id));
 
158
 
159
- if ($result) {
160
- foreach ($result as $rating) {
161
- $overall_rating=$rating->overall_rating;
162
 
163
- return $overall_rating;
164
- }
165
  }
 
 
 
 
 
 
 
 
 
166
  }
167
 
168
 
@@ -213,33 +226,62 @@ function yasr_get_multi_set() {
213
  $result = $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
214
 
215
  return $result;
216
- }
217
 
218
 
219
  /****** Get multi set values and field's name, used in ajax function and shortcode function ******/
220
  function yasr_get_multi_set_values_and_field ($post_id, $set_type) {
221
- global $wpdb;
222
 
223
- $result=$wpdb->get_results($wpdb->prepare("SELECT f.field_name AS name, f.field_id AS id, v.votes AS vote
224
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f, " . YASR_MULTI_SET_VALUES_TABLE . " AS v
225
- WHERE f.parent_set_id=%d
226
- AND f.field_id = v.field_id
227
- AND v.post_id = %d
228
- AND v.set_type = %d
229
- AND f.parent_set_id=v.set_type
230
- ORDER BY f.field_id ASC", $set_type, $post_id, $set_type));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
- return $result;
233
  }
234
 
235
 
236
  /****** Get multi set visitor votes ******/
237
  function yasr_get_multi_set_visitor ($post_id, $set_type) {
238
 
 
 
 
 
 
 
 
 
239
  global $wpdb;
240
 
241
- $result=$wpdb->get_results($wpdb->prepare("SELECT f.field_name AS name, f.field_id AS id, v.number_of_votes AS number_of_votes, v.sum_votes AS sum_votes
242
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f, " . YASR_MULTI_SET_VALUES_TABLE . " AS v
243
  WHERE f.parent_set_id=%d
244
  AND f.field_id = v.field_id
245
  AND v.post_id = %d
@@ -247,6 +289,14 @@ function yasr_get_multi_set_visitor ($post_id, $set_type) {
247
  AND f.parent_set_id=v.set_type
248
  ORDER BY f.field_id ASC", $set_type, $post_id, $set_type));
249
 
 
 
 
 
 
 
 
 
250
  return $result;
251
 
252
  }
@@ -254,39 +304,89 @@ function yasr_get_multi_set_visitor ($post_id, $set_type) {
254
 
255
 
256
  /****** Get visitor votes ******/
257
- function yasr_get_visitor_votes ($post_id_referenced=FALSE) {
258
  global $wpdb;
259
 
260
  //if values it's not passed get the post id, most of cases and default one
261
- if(!$post_id_referenced) {
262
 
263
  $post_id=get_the_ID();
264
 
265
  }
266
 
267
- //referenced is necessary for ajax calls
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  else {
269
 
270
- $post_id = $post_id_referenced;
 
 
 
 
 
 
 
 
271
 
272
  }
273
 
274
- if (!$post_id) {
275
 
276
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
 
278
  }
279
 
280
- $result = $wpdb->get_results($wpdb->prepare("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . " WHERE post_id=%d", $post_id));
281
 
282
- return $result;
283
  }
284
 
285
 
286
 
287
  /****** Adding logs widget to the dashboard ******/
288
 
289
- add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
290
 
291
  function add_action_dashboard_widget_log() {
292
 
@@ -313,8 +413,8 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
313
 
314
  function yasr_widget_log_dashboard_callback () {
315
 
316
-
317
- $limit = 8; //max number of row to echo
318
 
319
  global $wpdb;
320
 
@@ -331,13 +431,13 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
331
  echo "<div class=\"yasr-log-container\" id=\"yasr-log-container\">";
332
 
333
  foreach ($log_result as $column) {
334
-
335
  $user = get_user_by( 'id', $column->user_id );
336
 
337
  //If ! user means that the vote are anonymous
338
  if ($user == FALSE) {
339
 
340
- $user = (object) array('user_login');
341
  $user->user_login = __('anonymous');
342
 
343
  }
@@ -347,10 +447,10 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
347
  $title_post = get_the_title( $column->post_id );
348
  $link = get_permalink( $column->post_id );
349
 
350
- $yasr_log_vote_text = sprintf(__('Vote %d from %s on ', 'yet-another-stars-rating'), $column->vote, '<strong style="color: blue">'.$user->user_login.'</strong>' );
351
 
352
  echo "
353
-
354
  <div class=\"yasr-log-div-child\">
355
 
356
  <div class=\"yasr-log-image\">
@@ -370,16 +470,16 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
370
  </div>
371
 
372
  </div>
373
-
374
  ";
375
-
376
  } //End foreach
377
 
378
  echo "<div id=\"yasr-log-page-navigation\">";
379
 
380
  $num_of_pages = ceil($n_rows/$limit);
381
 
382
- //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
383
  //the "last" button coul not exists
384
  //This is required on ajax, not here, but still doing it here to take it simple
385
  echo "<span id=\"yasr-log-total-pages\" data-yasr-log-total-pages=\"$num_of_pages\">";
@@ -389,7 +489,7 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
389
  echo "</span>";
390
 
391
  if ($num_of_pages <= 3) {
392
-
393
  for ($i=1; $i<=$num_of_pages; $i++) {
394
 
395
  if ($i == 1) {
@@ -453,8 +553,8 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
453
 
454
  function yasr_users_dashboard_widget_callback () {
455
 
456
-
457
- $limit = 8; //max number of row to echo
458
 
459
  //Get current user id: don't need to check if is >0 cause user is logged in here
460
  $user_id = get_current_user_id();
@@ -480,10 +580,10 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
480
  $title_post = get_the_title( $column->post_id );
481
  $link = get_permalink( $column->post_id );
482
 
483
- $yasr_log_vote_text = sprintf(__('You rated %s on ', 'yet-another-stars-rating'), '<strong style="color: blue">'.$column->vote.'</strong>');
484
 
485
  echo "
486
-
487
  <div class=\"yasr-log-div-child\">
488
 
489
  <div class=\"yasr-log-image\">
@@ -503,16 +603,16 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
503
  </div>
504
 
505
  </div>
506
-
507
  ";
508
-
509
  } //End foreach
510
 
511
  echo "<div id=\"yasr-log-page-navigation\">";
512
 
513
  $num_of_pages = ceil($n_rows/$limit);
514
 
515
- //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
516
  //the "last" button coul not exists
517
  //This is required on ajax, not here, but still doing it here to take it simple
518
  echo "<span id=\"yasr-user-log-total-pages\" data-yasr-user-log-total-pages=\"$num_of_pages\">";
@@ -522,7 +622,7 @@ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
522
  echo "</span>";
523
 
524
  if ($num_of_pages <= 3) {
525
-
526
  for ($i=1; $i<=$num_of_pages; $i++) {
527
 
528
  if ($i == 1) {
@@ -623,64 +723,19 @@ add_action ('admin_init', 'admin_init_delete_data_on_post_callback');
623
  '%d'
624
  )
625
  );
626
-
627
-
628
- }
629
 
630
 
 
631
 
632
- /****** Check if a logged in user has already rated. Return user vote for a post if exists ******/
633
-
634
- function yasr_check_if_user_already_voted($post_id=FALSE) {
635
-
636
- global $wpdb;
637
-
638
- global $current_user;
639
- get_currentuserinfo();
640
-
641
- $user_id = $current_user->ID;
642
-
643
- //just to be safe
644
- if(!$post_id) {
645
-
646
- $post_id = get_the_ID();
647
-
648
- }
649
-
650
- if (!$post_id || !$user_id) {
651
-
652
- exit();
653
-
654
- }
655
-
656
- $result = $wpdb->get_results($wpdb->prepare("SELECT vote FROM " . YASR_LOG_TABLE . " WHERE post_id=%d AND user_id=%d ORDER BY id DESC LIMIT 1 ", $post_id, $user_id));
657
-
658
- if ($result) {
659
-
660
- foreach ($result as $row) {
661
-
662
- $vote = $row->vote;
663
-
664
- }
665
-
666
- return $vote;
667
-
668
- }
669
-
670
- else {
671
-
672
- return FALSE;
673
 
674
- }
675
 
676
 
677
- }
678
 
679
 
680
  /****** Function to get always the last id in the log table ******/
681
 
682
  function yasr_count_logged_vote () {
683
-
684
  global $wpdb;
685
 
686
  $result = $wpdb->get_var("SELECT COUNT(id) FROM " . YASR_LOG_TABLE );
25
  global $wpdb; //Database wordpress object
26
 
27
  $prefix=$wpdb->prefix . 'yasr_'; //Table prefix
28
+
29
  $yasr_votes_table = $prefix . 'votes';
30
  $yasr_multi_set_table = $prefix . 'multi_set';
31
  $yasr_multi_set_fields = $prefix . 'multi_set_fields';
40
  sum_votes decimal(11,1) NOT NULL,
41
  review_type VARCHAR(10),
42
  PRIMARY KEY (id),
43
+ UNIQUE KEY post_id (post_id)
44
  );";
45
 
46
  $sql_yasr_multi_set_table= "CREATE TABLE IF NOT EXISTS $yasr_multi_set_table (
82
  PRIMARY KEY (id),
83
  UNIQUE KEY id (id)
84
  );";
85
+
86
 
87
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
88
 
103
  $option['auto_insert_what'] = 'overall_rating';
104
  $option['auto_insert_where'] = 'top';
105
  $option['auto_insert_size']='large';
106
+ $option['auto_insert_exclude_pages'] = 'yes';
107
  $option['auto_insert_custom_post_only'] = 'no';
108
  $option['show_overall_in_loop'] = 'disabled';
109
  $option['show_visitor_votes_in_loop'] = 'disabled';
122
  $style_options['scheme_color_multiset'] = 'light';
123
 
124
  update_option("yasr_style_options", $style_options);
125
+
126
 
127
  }
128
 
131
 
132
  /****** Get overall rating from yasr_votes table
133
  used in yasr_add_filter_for_schema() and yasr_get_id_value_callback() ******/
134
+ function yasr_get_overall_rating($post_id=FALSE) {
135
  global $wpdb;
136
 
137
+
138
  //if values it's not passed get the post id, most of cases and default one
139
+ if(!$post_id) {
140
 
141
  $post_id=get_the_ID();
142
 
143
  }
144
 
145
+ if (!$post_id) {
 
146
 
147
+ return;
148
 
149
  }
150
 
151
+ $overall_rating = FALSE;
152
 
153
+ $transient_name = 'yasr_overall_rating_' . $post_id;
154
+
155
+ $transient_overall = get_transient($transient_name);
156
+
157
+ //if transient exists return it
158
+ if ($transient_overall) {
159
+
160
+ return $transient_overall;
161
 
162
  }
163
 
164
+ //get value from db
165
+ else {
166
 
167
+ $overall_rating=$wpdb->get_var($wpdb->prepare("SELECT overall_rating FROM " . YASR_VOTES_TABLE . " WHERE post_id=%d", $post_id));
 
 
168
 
 
 
169
  }
170
+
171
+ if ($overall_rating) {
172
+
173
+ set_transient( $transient_name, $overall_rating, WEEK_IN_SECONDS );
174
+
175
+ }
176
+
177
+ return $overall_rating;
178
+
179
  }
180
 
181
 
226
  $result = $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
227
 
228
  return $result;
229
+ }
230
 
231
 
232
  /****** Get multi set values and field's name, used in ajax function and shortcode function ******/
233
  function yasr_get_multi_set_values_and_field ($post_id, $set_type) {
 
234
 
235
+ $result = get_transient( 'yasr_get_multi_set_values_and_field_' . $post_id . '_' . $set_type );
236
+
237
+ if ($result !== FALSE) {
238
+
239
+ return $result;
240
+
241
+ }
242
+
243
+ else {
244
+
245
+ global $wpdb;
246
+
247
+ $result=$wpdb->get_results($wpdb->prepare("SELECT f.field_name AS name, f.field_id AS id, v.votes AS vote
248
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f, " . YASR_MULTI_SET_VALUES_TABLE . " AS v
249
+ WHERE f.parent_set_id=%d
250
+ AND f.field_id = v.field_id
251
+ AND v.post_id = %d
252
+ AND v.set_type = %d
253
+ AND f.parent_set_id=v.set_type
254
+ ORDER BY f.field_id ASC", $set_type, $post_id, $set_type));
255
+
256
+ if (!empty($result)) {
257
+
258
+ set_transient( 'yasr_get_multi_set_values_and_field_' . $post_id . '_' . $set_type, $result, WEEK_IN_SECONDS );
259
+
260
+ }
261
+
262
+ return $result;
263
+
264
+ }
265
+
266
 
 
267
  }
268
 
269
 
270
  /****** Get multi set visitor votes ******/
271
  function yasr_get_multi_set_visitor ($post_id, $set_type) {
272
 
273
+ $result = get_transient( 'yasr_visitor_multi_set_' . $post_id . '_' . $set_type );
274
+
275
+ if ($result !== FALSE) {
276
+
277
+ return $result;
278
+
279
+ }
280
+
281
  global $wpdb;
282
 
283
+ $result=$wpdb->get_results($wpdb->prepare("SELECT f.field_name AS name, f.field_id AS id, v.number_of_votes AS number_of_votes, v.sum_votes AS sum_votes
284
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f, " . YASR_MULTI_SET_VALUES_TABLE . " AS v
285
  WHERE f.parent_set_id=%d
286
  AND f.field_id = v.field_id
287
  AND v.post_id = %d
289
  AND f.parent_set_id=v.set_type
290
  ORDER BY f.field_id ASC", $set_type, $post_id, $set_type));
291
 
292
+ //Should be never empty because first time it's called
293
+ //all values are set to 0, just to be safe
294
+ if(!empty($result)) {
295
+
296
+ set_transient('yasr_visitor_multi_set_' . $post_id . '_' . $set_type, $result, WEEK_IN_SECONDS );
297
+
298
+ }
299
+
300
  return $result;
301
 
302
  }
304
 
305
 
306
  /****** Get visitor votes ******/
307
+ function yasr_get_visitor_votes ($post_id=FALSE, $create_transient=TRUE) {
308
  global $wpdb;
309
 
310
  //if values it's not passed get the post id, most of cases and default one
311
+ if(!$post_id) {
312
 
313
  $post_id=get_the_ID();
314
 
315
  }
316
 
317
+ if (!$post_id) {
318
+
319
+ return;
320
+
321
+ }
322
+
323
+ $transient_name = 'yasr_visitor_votes_' . $post_id;
324
+
325
+ $transient_visitor_votes = get_transient( $transient_name );
326
+
327
+ if ($transient_visitor_votes) {
328
+
329
+ return $transient_visitor_votes;
330
+
331
+ }
332
+
333
  else {
334
 
335
+ $result = $wpdb->get_results($wpdb->prepare("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . " WHERE post_id=%d", $post_id));
336
+
337
+ if ($create_transient == TRUE) {
338
+
339
+ set_transient( $transient_name, $result, WEEK_IN_SECONDS );
340
+
341
+ }
342
+
343
+ return $result;
344
 
345
  }
346
 
347
+ }
348
 
349
+ /****** Check if a logged in user has already rated. Return user vote for a post if exists ******/
350
+
351
+ function yasr_check_if_user_already_voted($post_id=FALSE) {
352
+
353
+ global $wpdb;
354
+
355
+ global $current_user;
356
+ get_currentuserinfo();
357
+
358
+ $user_id = $current_user->ID;
359
+
360
+ //just to be safe
361
+ if(!$post_id) {
362
+
363
+ $post_id = get_the_ID();
364
+
365
+ }
366
+
367
+ if (!$post_id || !$user_id) {
368
+
369
+ exit();
370
+
371
+ }
372
+
373
+ $rating = $wpdb->get_var($wpdb->prepare("SELECT vote FROM " . YASR_LOG_TABLE . " WHERE post_id=%d AND user_id=%d ORDER BY id DESC LIMIT 1 ", $post_id, $user_id));
374
+
375
+ if ($rating === NULL) {
376
+
377
+ $rating = FALSE;
378
 
379
  }
380
 
381
+ return $rating;
382
 
 
383
  }
384
 
385
 
386
 
387
  /****** Adding logs widget to the dashboard ******/
388
 
389
+ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
390
 
391
  function add_action_dashboard_widget_log() {
392
 
413
 
414
  function yasr_widget_log_dashboard_callback () {
415
 
416
+
417
+ $limit = 8; //max number of row to echo
418
 
419
  global $wpdb;
420
 
431
  echo "<div class=\"yasr-log-container\" id=\"yasr-log-container\">";
432
 
433
  foreach ($log_result as $column) {
434
+
435
  $user = get_user_by( 'id', $column->user_id );
436
 
437
  //If ! user means that the vote are anonymous
438
  if ($user == FALSE) {
439
 
440
+ $user = (object) array('user_login');
441
  $user->user_login = __('anonymous');
442
 
443
  }
447
  $title_post = get_the_title( $column->post_id );
448
  $link = get_permalink( $column->post_id );
449
 
450
+ $yasr_log_vote_text = sprintf(__('Vote %d from %s on ', 'yet-another-stars-rating'), $column->vote, '<strong style="color: blue">'.$user->user_login.'</strong>' );
451
 
452
  echo "
453
+
454
  <div class=\"yasr-log-div-child\">
455
 
456
  <div class=\"yasr-log-image\">
470
  </div>
471
 
472
  </div>
473
+
474
  ";
475
+
476
  } //End foreach
477
 
478
  echo "<div id=\"yasr-log-page-navigation\">";
479
 
480
  $num_of_pages = ceil($n_rows/$limit);
481
 
482
+ //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
483
  //the "last" button coul not exists
484
  //This is required on ajax, not here, but still doing it here to take it simple
485
  echo "<span id=\"yasr-log-total-pages\" data-yasr-log-total-pages=\"$num_of_pages\">";
489
  echo "</span>";
490
 
491
  if ($num_of_pages <= 3) {
492
+
493
  for ($i=1; $i<=$num_of_pages; $i++) {
494
 
495
  if ($i == 1) {
553
 
554
  function yasr_users_dashboard_widget_callback () {
555
 
556
+
557
+ $limit = 8; //max number of row to echo
558
 
559
  //Get current user id: don't need to check if is >0 cause user is logged in here
560
  $user_id = get_current_user_id();
580
  $title_post = get_the_title( $column->post_id );
581
  $link = get_permalink( $column->post_id );
582
 
583
+ $yasr_log_vote_text = sprintf(__('You rated %s on ', 'yet-another-stars-rating'), '<strong style="color: blue">'.$column->vote.'</strong>');
584
 
585
  echo "
586
+
587
  <div class=\"yasr-log-div-child\">
588
 
589
  <div class=\"yasr-log-image\">
603
  </div>
604
 
605
  </div>
606
+
607
  ";
608
+
609
  } //End foreach
610
 
611
  echo "<div id=\"yasr-log-page-navigation\">";
612
 
613
  $num_of_pages = ceil($n_rows/$limit);
614
 
615
+ //use data attribute instead of value of #yasr-log-total-pages, because, on ajaxresponse,
616
  //the "last" button coul not exists
617
  //This is required on ajax, not here, but still doing it here to take it simple
618
  echo "<span id=\"yasr-user-log-total-pages\" data-yasr-user-log-total-pages=\"$num_of_pages\">";
622
  echo "</span>";
623
 
624
  if ($num_of_pages <= 3) {
625
+
626
  for ($i=1; $i<=$num_of_pages; $i++) {
627
 
628
  if ($i == 1) {
723
  '%d'
724
  )
725
  );
 
 
 
726
 
727
 
728
+ }
729
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
 
 
731
 
732
 
 
733
 
734
 
735
  /****** Function to get always the last id in the log table ******/
736
 
737
  function yasr_count_logged_vote () {
738
+
739
  global $wpdb;
740
 
741
  $result = $wpdb->get_var("SELECT COUNT(id) FROM " . YASR_LOG_TABLE );
lib/yasr-functions.php CHANGED
@@ -23,16 +23,16 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
23
 
24
  /***** Adding javascript and css *****/
25
 
26
- add_action( 'wp_enqueue_scripts', 'yasr_add_scripts' );
27
  add_action( 'admin_enqueue_scripts', 'yasr_add_admin_scripts' );
28
 
29
  function yasr_add_scripts () {
30
 
31
- do_action( 'yasr_add_front_script_css' );
32
-
33
- //This will run only if doesn't exists yasrcss yet. That's why must be after do_action
34
  wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', FALSE, NULL, 'all' );
35
 
 
 
 
36
  //If choosen is light or not dark (force to be default)
37
  if (YASR_SCHEME_COLOR === 'light' || YASR_SCHEME_COLOR != 'dark' ) {
38
  wp_enqueue_style( 'yasrcsslightscheme', YASR_CSS_DIR . 'yasr-table-light.css', array('yasrcss'), NULL, 'all' );
@@ -46,7 +46,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
46
  wp_add_inline_style( 'yasrcss', YASR_CUSTOM_CSS_RULES );
47
  }
48
 
49
- wp_enqueue_script( 'rateit', YASR_JS_DIR . 'jquery.rateit.min.js' , array('jquery'), '1.0.22', TRUE );
50
 
51
  wp_enqueue_script( 'yasrfront', YASR_JS_DIR . 'yasr-front.js' , array('jquery', 'rateit'), '1.0.0', TRUE );
52
 
@@ -62,7 +62,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
62
  'postid' => get_the_ID(),
63
  'ajaxurl' => admin_url('admin-ajax.php'),
64
  'loggedUser' => is_user_logged_in(),
65
- 'visitorStatsEnabled' => YASR_VISITORS_STATS,
66
  'tooltipValues' => $tooltip_values_exploded,
67
  'loaderHtml' => $yasr_visitor_votes_loader
68
 
@@ -97,13 +97,23 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
97
  }
98
 
99
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  /****** Translating YASR ******/
102
-
103
  add_action('init', 'yasr_translate_option', 110);
104
 
105
  function yasr_translate_option() {
106
- load_plugin_textdomain('yet-another-stars-rating', FALSE, YASR_LANG_DIR);
107
  }
108
 
109
 
@@ -127,7 +137,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
127
  }
128
 
129
 
130
- // Settings Page Content
131
  function yasr_settings_page_callback () {
132
 
133
  if ( ! current_user_can( 'manage_options' ) ) {
@@ -155,7 +165,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
155
  if ($custom_post_types) {
156
 
157
  //First merge array then changes keys to int
158
- $post_type_where_display_metabox = array_values(array_merge($post_type_where_display_metabox, $custom_post_types));
159
 
160
  }
161
 
@@ -164,7 +174,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
164
  add_meta_box( 'yasr_metabox_overall_rating', 'YASR', 'yasr_metabox_overall_rating_content', $post_type, 'side', 'high' );
165
  }
166
 
167
- $multi_set=yasr_get_multi_set();
168
  //If multiset are used then add the second metabox
169
  if ($multi_set) {
170
  foreach ($post_type_where_display_metabox as $post_type) {
@@ -191,7 +201,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
191
  else {
192
  _e("You don't have enough privileges to insert a Multi Set");
193
  }
194
-
195
  }
196
 
197
 
@@ -214,7 +224,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
214
  case 'top':
215
  $content_and_stars = $overall_rating_code . $content;
216
  break;
217
-
218
  case 'bottom':
219
  $content_and_stars = $content . $overall_rating_code;
220
  break;
@@ -226,7 +236,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
226
  case 'top':
227
  $content_and_stars = $visitor_votes_code . $content;
228
  break;
229
-
230
  case 'bottom':
231
  $content_and_stars = $content . $visitor_votes_code;
232
  break;
@@ -238,7 +248,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
238
  case 'top':
239
  $content_and_stars = $overall_rating_code . $visitor_votes_code . $content;
240
  break;
241
-
242
  case 'bottom':
243
  $content_and_stars = $content . $overall_rating_code . $visitor_votes_code;
244
  break;
@@ -294,7 +304,7 @@ add_filter('the_content', 'yasr_add_schema');
294
  //Add buddypress compatibility
295
  if (function_exists('bp_is_active')) {
296
 
297
- //Return content only if is page. This will disable schema for all page.
298
  //Dunno why, but if I try to return $content after if (YASR_SNIPPET == 'overall_rating')
299
  //or (YASR_SNIPPET == 'visitor_rating') $content will have only wp content, losing the buddypress one
300
  if (is_page()) {
@@ -322,7 +332,7 @@ add_filter('the_content', 'yasr_add_schema');
322
  return $content . $filtered_schema;
323
 
324
  }
325
-
326
  if (YASR_SNIPPET == 'overall_rating') {
327
 
328
  $overall_rating=yasr_get_overall_rating();
@@ -372,7 +382,7 @@ add_filter('the_content', 'yasr_add_schema');
372
  $schema = $div . $title . $date . $author . $rating . $end_div;
373
 
374
  }
375
-
376
 
377
  }
378
 
@@ -424,7 +434,7 @@ add_filter('the_content', 'yasr_add_schema');
424
  }
425
 
426
  $author = __( ' written by ' , 'yet-another-stars-rating' ) . get_the_author();
427
-
428
  $span_1 = "<span itemprop=\"aggregateRating\" itemscope itemtype=\"http://schema.org/AggregateRating\">";
429
  $rating = __( ' average rating ' , 'yet-another-stars-rating' ) . "<span itemprop=\"ratingValue\">" . $average_rating . "</span>/<span itemprop=\"bestRating\">5</span>";
430
  $n_ratings = " - <span itemprop=\"ratingCount\"> " . $visitor_rating['votes_number'] . "</span>" . __(' user ratings', 'yet-another-stars-rating');
@@ -444,7 +454,7 @@ add_filter('the_content', 'yasr_add_schema');
444
 
445
  else {
446
  return $content;
447
- }
448
 
449
 
450
  } //End if(YASR_SCHEMA_FORMAT != 'jsonld'){
@@ -533,7 +543,7 @@ add_filter('the_content', 'yasr_add_schema');
533
  $rich_snippet["image"] = wp_get_attachment_url(get_post_thumbnail_id());
534
 
535
  }
536
-
537
 
538
  }
539
 
@@ -572,7 +582,7 @@ add_filter('the_content', 'yasr_add_schema');
572
 
573
  //name
574
  $rich_snippet["name"] = $review_name;
575
-
576
  $rich_snippet["aggregateRating"] = array (
577
  "@type" => "AggregateRating",
578
  "ratingValue" => "$average_rating",
@@ -621,7 +631,7 @@ add_filter('the_content', 'yasr_add_schema');
621
 
622
  else {
623
  return $content;
624
- }
625
 
626
  }
627
 
@@ -658,9 +668,9 @@ add_filter('the_content', 'yasr_add_schema');
658
 
659
  ?>
660
 
661
- <select id="yasr-choose-reviews-types-list">
662
 
663
- <?php
664
 
665
  $i = 1;
666
 
@@ -690,41 +700,21 @@ add_filter('the_content', 'yasr_add_schema');
690
  } //End function yasr_select_itemtype()
691
 
692
 
693
- /****** Create a new button in Tinymce for use shortag
694
- (Thanks to wordpress.stackexchange) ******/
695
 
696
- // init process for registering our button
697
- add_action('admin_init', 'yasr_shortcode_button_init');
698
- function yasr_shortcode_button_init() {
699
 
700
- //Abort early if the user will never see TinyMCE
701
- if ( ! current_user_can('publish_posts') && ! current_user_can('publish_posts') && get_user_option('rich_editing') == 'true')
702
- return;
703
 
704
- //Add a callback to register our tinymce plugin
705
- add_filter("mce_external_plugins", "yasr_register_tinymce_plugin");
706
 
707
- // Add a callback to add our button to the TinyMCE toolbar
708
- add_filter('mce_buttons', 'yasr_add_tinymce_button');
709
 
710
- }
711
-
712
-
713
- //This callback registers our plug-in
714
- function yasr_register_tinymce_plugin($plugin_array) {
715
- $plugin_array['yasr_button'] = YASR_JS_DIR . 'addButton_tinymcs.js';
716
- return $plugin_array;
717
- }
718
 
719
- //This callback adds our button to the toolbar
720
- function yasr_add_tinymce_button($buttons) {
721
- //Add the button ID to the $button array
722
- $buttons[] = "yasr_button";
723
- return $buttons;
724
- }
725
 
726
 
727
- /****** Return the custom post type if exists
728
  Argument is to set what to return, if array or boolean value.
729
  Default: array******/
730
 
@@ -739,7 +729,7 @@ add_action( 'admin_init', 'yasr_get_custom_post_type');
739
  $output = 'names'; // names or objects, note names is the default
740
  $operator = 'and'; // 'and' or 'or'
741
 
742
- $post_types = get_post_types( $args, $output, $operator );
743
 
744
  if ($post_types) {
745
  if ($exit == 'array') {
@@ -765,18 +755,18 @@ function yasr_stars_size ($size) {
765
  $stars_attribute = array();
766
 
767
  if ($size === 'small') {
768
- $stars_attribute['class'] = 'rateit';
769
  $stars_attribute['px_size'] = '16';
770
  }
771
 
772
  elseif ($size === 'medium') {
773
- $stars_attribute['class'] = 'rateit medium';
774
  $stars_attribute['px_size'] = '24';
775
  }
776
 
777
  //default values
778
  else {
779
- $stars_attribute['class'] = 'rateit bigstars';
780
  $stars_attribute['px_size'] = '32';
781
  }
782
 
@@ -788,14 +778,14 @@ function yasr_stars_size ($size) {
788
 
789
  /*** Add support for wp super cache ***/
790
  function yasr_wp_super_cache_support($post_id) {
791
-
792
  if(function_exists('wp_cache_post_change')) {
793
  wp_cache_post_change($post_id);
794
  }
795
 
796
  }
797
 
798
- /*** Add support for wp rocket, thanks to GeekPress
799
  https://wordpress.org/support/topic/compatibility-with-wp-rocket-2
800
  ***/
801
 
@@ -821,11 +811,22 @@ function yasr_wp_rocket_support($post_id) {
821
  }
822
 
823
 
824
- /*** Function to get ip, since version 0.8.8 and 0.3.4
825
  This code can be found on http://codex.wordpress.org/Plugin_API/Filter_Reference/pre_comment_user_ip
826
  ***/
827
 
828
- function yasr_get_ip() {
 
 
 
 
 
 
 
 
 
 
 
829
 
830
  $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
831
 
@@ -840,7 +841,7 @@ function yasr_get_ip() {
840
  }
841
 
842
  /*
843
- * Some php environments will use the $_SERVER['HTTP_X_FORWARDED_FOR']
844
  * variable to capture visitor address information.
845
  */
846
 
@@ -858,4 +859,4 @@ function yasr_get_ip() {
858
 
859
  }
860
 
861
- ?>
23
 
24
  /***** Adding javascript and css *****/
25
 
26
+ add_action( 'wp_enqueue_scripts', 'yasr_add_scripts' );
27
  add_action( 'admin_enqueue_scripts', 'yasr_add_admin_scripts' );
28
 
29
  function yasr_add_scripts () {
30
 
 
 
 
31
  wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', FALSE, NULL, 'all' );
32
 
33
+ //Run after yasrcss is loaded
34
+ do_action( 'yasr_add_front_script_css' );
35
+
36
  //If choosen is light or not dark (force to be default)
37
  if (YASR_SCHEME_COLOR === 'light' || YASR_SCHEME_COLOR != 'dark' ) {
38
  wp_enqueue_style( 'yasrcsslightscheme', YASR_CSS_DIR . 'yasr-table-light.css', array('yasrcss'), NULL, 'all' );
46
  wp_add_inline_style( 'yasrcss', YASR_CUSTOM_CSS_RULES );
47
  }
48
 
49
+ wp_enqueue_script( 'rateit', YASR_JS_DIR . 'jquery.rateit.min.js' , array('jquery'), '1.0.22', TRUE );
50
 
51
  wp_enqueue_script( 'yasrfront', YASR_JS_DIR . 'yasr-front.js' , array('jquery', 'rateit'), '1.0.0', TRUE );
52
 
62
  'postid' => get_the_ID(),
63
  'ajaxurl' => admin_url('admin-ajax.php'),
64
  'loggedUser' => is_user_logged_in(),
65
+ 'visitorStatsEnabled' => YASR_VISITORS_STATS,
66
  'tooltipValues' => $tooltip_values_exploded,
67
  'loaderHtml' => $yasr_visitor_votes_loader
68
 
97
  }
98
 
99
 
100
+ //Add the javascript needed for shortcode creator only when necessary
101
+ add_action('wp_enqueue_media', 'yasr_shortcode_creator_javascript');
102
+
103
+ function yasr_shortcode_creator_javascript () {
104
+
105
+ wp_enqueue_script('yasr_shortcode_creator', YASR_JS_DIR . 'yasr-shortcode-creator.js', array('jquery'), '1.0', TRUE);
106
+
107
+ }
108
+
109
+
110
 
111
  /****** Translating YASR ******/
112
+
113
  add_action('init', 'yasr_translate_option', 110);
114
 
115
  function yasr_translate_option() {
116
+ load_plugin_textdomain('yet-another-stars-rating', FALSE, YASR_LANG_DIR);
117
  }
118
 
119
 
137
  }
138
 
139
 
140
+ // Settings Page Content
141
  function yasr_settings_page_callback () {
142
 
143
  if ( ! current_user_can( 'manage_options' ) ) {
165
  if ($custom_post_types) {
166
 
167
  //First merge array then changes keys to int
168
+ $post_type_where_display_metabox = array_values(array_merge($post_type_where_display_metabox, $custom_post_types));
169
 
170
  }
171
 
174
  add_meta_box( 'yasr_metabox_overall_rating', 'YASR', 'yasr_metabox_overall_rating_content', $post_type, 'side', 'high' );
175
  }
176
 
177
+ $multi_set=yasr_get_multi_set();
178
  //If multiset are used then add the second metabox
179
  if ($multi_set) {
180
  foreach ($post_type_where_display_metabox as $post_type) {
201
  else {
202
  _e("You don't have enough privileges to insert a Multi Set");
203
  }
204
+
205
  }
206
 
207
 
224
  case 'top':
225
  $content_and_stars = $overall_rating_code . $content;
226
  break;
227
+
228
  case 'bottom':
229
  $content_and_stars = $content . $overall_rating_code;
230
  break;
236
  case 'top':
237
  $content_and_stars = $visitor_votes_code . $content;
238
  break;
239
+
240
  case 'bottom':
241
  $content_and_stars = $content . $visitor_votes_code;
242
  break;
248
  case 'top':
249
  $content_and_stars = $overall_rating_code . $visitor_votes_code . $content;
250
  break;
251
+
252
  case 'bottom':
253
  $content_and_stars = $content . $overall_rating_code . $visitor_votes_code;
254
  break;
304
  //Add buddypress compatibility
305
  if (function_exists('bp_is_active')) {
306
 
307
+ //Return content only if is page. This will disable schema for all page.
308
  //Dunno why, but if I try to return $content after if (YASR_SNIPPET == 'overall_rating')
309
  //or (YASR_SNIPPET == 'visitor_rating') $content will have only wp content, losing the buddypress one
310
  if (is_page()) {
332
  return $content . $filtered_schema;
333
 
334
  }
335
+
336
  if (YASR_SNIPPET == 'overall_rating') {
337
 
338
  $overall_rating=yasr_get_overall_rating();
382
  $schema = $div . $title . $date . $author . $rating . $end_div;
383
 
384
  }
385
+
386
 
387
  }
388
 
434
  }
435
 
436
  $author = __( ' written by ' , 'yet-another-stars-rating' ) . get_the_author();
437
+
438
  $span_1 = "<span itemprop=\"aggregateRating\" itemscope itemtype=\"http://schema.org/AggregateRating\">";
439
  $rating = __( ' average rating ' , 'yet-another-stars-rating' ) . "<span itemprop=\"ratingValue\">" . $average_rating . "</span>/<span itemprop=\"bestRating\">5</span>";
440
  $n_ratings = " - <span itemprop=\"ratingCount\"> " . $visitor_rating['votes_number'] . "</span>" . __(' user ratings', 'yet-another-stars-rating');
454
 
455
  else {
456
  return $content;
457
+ }
458
 
459
 
460
  } //End if(YASR_SCHEMA_FORMAT != 'jsonld'){
543
  $rich_snippet["image"] = wp_get_attachment_url(get_post_thumbnail_id());
544
 
545
  }
546
+
547
 
548
  }
549
 
582
 
583
  //name
584
  $rich_snippet["name"] = $review_name;
585
+
586
  $rich_snippet["aggregateRating"] = array (
587
  "@type" => "AggregateRating",
588
  "ratingValue" => "$average_rating",
631
 
632
  else {
633
  return $content;
634
+ }
635
 
636
  }
637
 
668
 
669
  ?>
670
 
671
+ <select id="yasr-choose-reviews-types-list">
672
 
673
+ <?php
674
 
675
  $i = 1;
676
 
700
  } //End function yasr_select_itemtype()
701
 
702
 
703
+ /******* Add a media content button ******/
 
704
 
705
+ add_action('media_buttons', 'yasr_shortcode_button_media', 99);
 
 
706
 
707
+ function yasr_shortcode_button_media() {
 
 
708
 
709
+ add_thickbox();
 
710
 
711
+ echo '<a href="#TB_inline?width=530&height=600&inlineId=yasr-tinypopup-form" id="yasr-shortcode-creator" class="button thickbox"><span class="dashicons dashicons-star-half" style="vertical-align: text-top;"></span> Yasr Shortcode</a>';
 
712
 
713
+ }
 
 
 
 
 
 
 
714
 
 
 
 
 
 
 
715
 
716
 
717
+ /****** Return the custom post type if exists
718
  Argument is to set what to return, if array or boolean value.
719
  Default: array******/
720
 
729
  $output = 'names'; // names or objects, note names is the default
730
  $operator = 'and'; // 'and' or 'or'
731
 
732
+ $post_types = get_post_types( $args, $output, $operator );
733
 
734
  if ($post_types) {
735
  if ($exit == 'array') {
755
  $stars_attribute = array();
756
 
757
  if ($size === 'small') {
758
+ $stars_attribute['class'] = 'rateit yasr_visitor_votes_stars_div';
759
  $stars_attribute['px_size'] = '16';
760
  }
761
 
762
  elseif ($size === 'medium') {
763
+ $stars_attribute['class'] = 'rateit medium yasr_visitor_votes_stars_div';
764
  $stars_attribute['px_size'] = '24';
765
  }
766
 
767
  //default values
768
  else {
769
+ $stars_attribute['class'] = 'rateit bigstars yasr_visitor_votes_stars_div';
770
  $stars_attribute['px_size'] = '32';
771
  }
772
 
778
 
779
  /*** Add support for wp super cache ***/
780
  function yasr_wp_super_cache_support($post_id) {
781
+
782
  if(function_exists('wp_cache_post_change')) {
783
  wp_cache_post_change($post_id);
784
  }
785
 
786
  }
787
 
788
+ /*** Add support for wp rocket, thanks to GeekPress
789
  https://wordpress.org/support/topic/compatibility-with-wp-rocket-2
790
  ***/
791
 
811
  }
812
 
813
 
814
+ /*** Function to get ip, since version 0.8.8
815
  This code can be found on http://codex.wordpress.org/Plugin_API/Filter_Reference/pre_comment_user_ip
816
  ***/
817
 
818
+ function yasr_get_ip() {
819
+
820
+ $ip = NULL;
821
+
822
+ $ip = apply_filters ('yasr_filter_ip', $ip);
823
+
824
+ if (isset($ip)) {
825
+
826
+ return $ip;
827
+
828
+ }
829
+
830
 
831
  $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
832
 
841
  }
842
 
843
  /*
844
+ * Some php environments will use the $_SERVER['HTTP_X_FORWARDED_FOR']
845
  * variable to capture visitor address information.
846
  */
847
 
859
 
860
  }
861
 
862
+ ?>
lib/yasr-settings-functions.php CHANGED
@@ -25,11 +25,12 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
25
  add_action( 'admin_init', 'yasr_general_options_init' ); //This is for general options
26
 
27
  function yasr_general_options_init() {
 
28
  register_setting(
29
  'yasr_general_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
30
  'yasr_general_options', //The name of an option to sanitize and save.
31
  'yasr_general_options_sanitize'
32
- );
33
 
34
  $option = get_option( 'yasr_general_options' );
35
 
@@ -77,13 +78,13 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
77
 
78
  <div class="yasr-indented-answer">
79
 
80
- <input type='radio' name='yasr_general_options[auto_insert_enabled]' value='1' id='yasr_auto_insert_radio_on' <?php if ($option['auto_insert_enabled']==1) echo " checked='checked' "; ?> />
81
  <?php _e('Yes', 'yet-another-stars-rating') ?>
82
  &nbsp;&nbsp;&nbsp;
83
 
84
-
85
- <input type='radio' name='yasr_general_options[auto_insert_enabled]' value='0' id='yasr_auto_insert_radio_off'
86
- <?php
87
  if ($option['auto_insert_enabled']==0) {
88
  echo " checked='checked' />";
89
  }
@@ -92,9 +93,9 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
92
  echo "/>";
93
  }
94
 
95
- _e('No', 'yet-another-stars-rating');
96
 
97
- ?>
98
 
99
  <p>&nbsp;</p>
100
 
@@ -174,7 +175,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
174
 
175
  </div>
176
 
177
- <?php
178
 
179
  $custom_post_types = yasr_get_custom_post_type('bool');
180
 
@@ -199,7 +200,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
199
 
200
  </div>
201
 
202
- <?php
203
  }
204
 
205
  else {
@@ -215,22 +216,22 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
215
  ?>
216
 
217
  <hr />
218
-
219
 
220
  <?php
221
  } //End yasr_auto_insert_callback
222
 
223
 
224
  function yasr_show_overall_in_loop_callback($option) {
225
-
226
  ?>
227
 
228
- <input type='radio' name='yasr_general_options[show_overall_in_loop]' value='enabled' class='yasr-general-option-show-overall-in-loop' <?php if ($option['show_overall_in_loop']==='enabled') echo " checked=\"checked\" "; ?> />
229
  <?php _e('Yes', 'yet-another-stars-rating')?>
230
 
231
  &nbsp;&nbsp;&nbsp;
232
 
233
- <input type='radio' name='yasr_general_options[show_overall_in_loop]' value='disabled' class='yasr-general-option-show-overall-in-loop' <?php if ($option['show_overall_in_loop']==='disabled') echo " checked=\"checked\" "; ?> />
234
  <?php _e('No', 'yet-another-stars-rating')?>
235
  <br />
236
  <br />
@@ -251,12 +252,12 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
251
 
252
  ?>
253
 
254
- <input type='radio' name='yasr_general_options[show_visitor_votes_in_loop]' value='enabled' class='yasr-general-option-show-visitor-votes-in-loop' <?php if ($option['show_visitor_votes_in_loop']==='enabled') echo " checked=\"checked\" "; ?> />
255
  <?php _e('Yes', 'yet-another-stars-rating')?>
256
 
257
  &nbsp;&nbsp;&nbsp;
258
 
259
- <input type='radio' name='yasr_general_options[show_visitor_votes_in_loop]' value='disabled' class='yasr-general-option-show-visitor-votes-in-loop' <?php if ($option['show_visitor_votes_in_loop']==='disabled') echo " checked=\"checked\" "; ?> />
260
  <?php _e('No', 'yet-another-stars-rating')?>
261
  <br />
262
  <br />
@@ -282,10 +283,10 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
282
  $text_after_visitor_rating = htmlspecialchars("$option[text_after_visitor_rating]");
283
 
284
  $custom_text_user_votes = htmlentities("$option[custom_text_user_voted]");
285
-
286
  ?>
287
 
288
- <input type='radio' name='yasr_general_options[text_before_stars]' value='1' id='yasr_text_before_star_on' <?php if ($option['text_before_stars']==1) echo " checked='checked' "; ?> />
289
  <?php _e('Yes', 'yet-another-stars-rating') ?>
290
  &nbsp;&nbsp;&nbsp;
291
 
@@ -294,24 +295,24 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
294
  <?php _e('No', 'yet-another-stars-rating'); ?>
295
 
296
  <br /> <br />
297
-
298
- <input type='text' name='yasr_general_options[text_before_overall]' id="yasr-general-options-custom-text-before-overall" class='yasr-general-options-text-before' <?php printf('value="%s"', $text_before_overall); ?> maxlength="40"/>
299
  <?php _e('Custom text to display before Overall Rating', 'yet-another-stars-rating')?>
300
 
301
  <br /> <br /> <br />
302
 
303
- <input type='text' name='yasr_general_options[text_before_visitor_rating]' id="yasr-general-options-custom-text-before-visitor" class='yasr-general-options-text-before' <?php printf('value="%s"', $text_before_visitor_rating); ?> maxlength="80"/>
304
- <?php _e('Custom text to display BEFORE Visitor Rating', 'yet-another-stars-rating')?>
305
 
306
  <br /> <br />
307
 
308
-
309
- <input type='text' name='yasr_general_options[text_after_visitor_rating]' id="yasr-general-options-custom-text-after-visitor" class='yasr-general-options-text-before' <?php printf('value="%s"', $text_after_visitor_rating); ?> maxlength="80"/>
310
  <?php _e('Custom text to display AFTER Visitor Rating', 'yet-another-stars-rating')?>
311
 
312
  <br /> <br /> <br />
313
 
314
- <input type='text' name='yasr_general_options[custom_text_user_voted]' id="yasr-general-options-custom-text-already-rated" class='yasr-general-options-text-before' <?php printf('value="%s"', $custom_text_user_votes); ?> maxlength="60"/>
315
  <?php _e('Custom text to display when a non logged user has already rated', 'yet-another-stars-rating')?>
316
 
317
 
@@ -340,12 +341,12 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
340
 
341
  ?>
342
 
343
- <input type='radio' name='yasr_general_options[visitors_stats]' value='yes' class='yasr-general-options-scheme-color' <?php if ($option['visitors_stats']==='yes') echo " checked=\"checked\" "; ?> />
344
  <?php _e('Yes', 'yet-another-stars-rating')?>
345
-
346
  &nbsp;&nbsp;&nbsp;
347
 
348
- <input type='radio' name='yasr_general_options[visitors_stats]' value='no' class='yasr-general-options-scheme-color' <?php if ($option['visitors_stats']==='no') echo " checked=\"checked\" "; ?> />
349
  <?php _e('No', 'yet-another-stars-rating')?>
350
  <br />
351
 
@@ -363,11 +364,11 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
363
 
364
  ?>
365
 
366
- <input type='radio' name='yasr_general_options[allowed_user]' value='logged_only' class='yasr_auto_insert_loggedonly' <?php if ($option['allowed_user']==='logged_only') echo " checked=\"checked\" "; ?> />
367
  <?php _e('Allow only logged-in users', 'yet-another-stars-rating')?>
368
  <br />
369
 
370
- <input type='radio' name='yasr_general_options[allowed_user]' value='allow_anonymous' class='yasr_auto_insert_loggedonly' <?php if ($option['allowed_user']==='allow_anonymous') echo " checked=\"checked\" "; ?> />
371
  <?php _e('Allow everybody (logged in and anonymous)', 'yet-another-stars-rating')?>
372
  <br />
373
 
@@ -400,7 +401,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
400
  <a href="#" id="yasr-snippet-explained-link"><?php _e("What is this?", 'yet-another-stars-rating') ?></a>
401
 
402
  <div id="yasr-snippet-explained" class="yasr-help-box-settings">
403
- <?php
404
 
405
  _e("If you select \"Review Rating\", your site will be indexed from search engines like this: ", 'yet-another-stars-rating');
406
  echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr_review.png>";
@@ -418,7 +419,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
418
 
419
  <br />
420
 
421
- <strong><?php _e('Select default item type for all post or pages', 'yet-another-stars-rating'); ?></strong>
422
 
423
  <div class="yasr-indented-answer">
424
 
@@ -498,20 +499,20 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
498
 
499
  //Array to return
500
  $output = array();
501
-
502
  // Loop through each of the incoming options
503
  foreach( $option as $key => $value ) {
504
-
505
  // Check to see if the current option has a value. If so, process it.
506
  if( isset( $option[$key] ) ) {
507
-
508
  // Strip all HTML and PHP tags and properly handle quoted strings
509
  $output[$key] = strip_tags( stripslashes( $option[ $key ] ) );
510
-
511
  } // end if
512
-
513
  } // end foreach
514
-
515
  // Return the array processing any additional functions filtered by this action
516
  //do not return $output but do apply_filter first,
517
 
@@ -532,12 +533,12 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
532
  register_setting(
533
  'yasr_multiset_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
534
  'yasr_multiset_options' //The name of an option to sanitize and save.
535
- );
536
 
537
  $option_multiset = get_option( 'yasr_multiset_options' );
538
 
539
  add_settings_section( 'yasr_multiset_options_section_id', '', 'yasr_multiset_section_callback', 'yasr_multiset_tab' );
540
-
541
  }
542
 
543
  function yasr_multiset_section_callback () {
@@ -546,18 +547,18 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
546
 
547
  }
548
 
549
-
550
 
551
 
552
  /****** Create a form for settings page to create new multi set ******/
553
  function yasr_display_multi_set_form() {
554
  ?>
555
-
556
  <h4 class="yasr-multi-set-form-headers"><?php _e("Add New Multiple Set", 'yet-another-stars-rating'); ?></h4>
557
  <em><?php _e('Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yet-another-stars-rating') ?></em>
558
  <p>
559
  <form action="<?php echo admin_url('options-general.php?page=yasr_settings_page&tab=manage_multi') ?>" id="form_add_multi_set" method="post">
560
- <strong><?php _e("Name", 'yet-another-stars-rating')?></strong>
561
  <input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
562
  <input type="hidden" name="action" value="yasr_new_multi_set_form" />
563
 
@@ -565,7 +566,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
565
  <?php _e("You can insert up to nine elements", 'yet-another-stars-rating') ?>
566
  <br />
567
 
568
- <?php for($i=1; $i<=9; $i++) {
569
 
570
  echo "<strong>" . __("Element ", 'yet-another-stars-rating') . "#$i" . "</strong>";
571
  ?>
@@ -580,7 +581,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
580
  <input type="submit" value="<?php _e("Create New Set", 'yet-another-stars-rating') ?>" class="button-primary"/>
581
  </form>
582
 
583
- <?php
584
  } //End function
585
 
586
 
@@ -610,7 +611,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
610
 
611
  <button href="#" class="button-delete" id="yasr-button-select-set-edit-form"><?php _e("Select"); ?></button>
612
 
613
-
614
  </div>
615
 
616
  <?php
@@ -620,7 +621,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
620
  elseif ($n_multi_set == 1) {
621
 
622
  $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id, parent_set_id AS set_id
623
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
624
  ORDER BY field_id ASC");
625
 
626
  foreach ($multi_set as $find_set_id) {
@@ -628,7 +629,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
628
  }
629
 
630
  ?>
631
-
632
  <div class="yasr-manage-multiset-single">
633
 
634
  <h4 class="yasr-multi-set-form-headers"><?php _e("Manage Multiple Set", 'yet-another-stars-rating'); ?></h4>
@@ -640,12 +641,12 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
640
  <table id="yasr-table-form-edit-multi-set">
641
  <tr>
642
 
643
- <td id="yasr-table-form-edit-multi-set-header">
644
  <?php _e('Field name', 'yet-another-stars-rating') ?>
645
  </td>
646
 
647
- <td id="yasr-table-form-edit-multi-set-remove">
648
- <?php _e('Remove', 'yet-another-stars-rating') ?>
649
  </td>
650
 
651
  </tr>
@@ -658,10 +659,10 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
658
 
659
  echo "
660
  <tr>
661
-
662
  <td width=\"80%\">
663
- Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$i\">
664
- <input type=\"hidden\" value=\"$name->id\" name=\"db-id-for-element-$i\">
665
  </td>
666
 
667
  <td width=\"20%\" style=\"text-align:center\">
@@ -670,7 +671,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
670
 
671
  </tr>
672
  ";
673
-
674
  $i++;
675
 
676
  }
@@ -703,15 +704,15 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
703
  _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , 'yet-another-stars-rating');
704
  echo "</p>";
705
 
706
- wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
707
 
708
  ?>
709
 
710
  <div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , 'yet-another-stars-rating') ?></div>
711
 
712
- <input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yet-another-stars-rating'); ?>">
713
 
714
- <input type="submit" value="<?php _e('Save changes', 'yet-another-stars-rating') ?>" class="button-primary" >
715
 
716
  </form>
717
 
@@ -743,11 +744,11 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
743
  global $wpdb;
744
 
745
  $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
746
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
747
- WHERE parent_set_id=%d
748
  ORDER BY field_id ASC", $set_type));
749
 
750
-
751
 
752
  ?>
753
 
@@ -758,16 +759,16 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
758
  <table id="yasr-table-form-edit-multi-set">
759
  <tr>
760
 
761
- <td id="yasr-table-form-edit-multi-set-header">
762
  <?php _e('Field name', 'yet-another-stars-rating') ?>
763
  </td>
764
 
765
- <td id="yasr-table-form-edit-multi-set-remove">
766
- <?php _e('Remove', 'yet-another-stars-rating') ?>
767
  </td>
768
 
769
  </tr>
770
-
771
  <?php
772
 
773
  $i=1;
@@ -776,9 +777,9 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
776
 
777
  echo "
778
  <tr>
779
-
780
  <td width=\"80%\">
781
- Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$i\">
782
  <input type=\"hidden\" value=\"$name->id\" name=\"db-id-for-element-$i\">
783
  </td>
784
 
@@ -821,13 +822,13 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
821
  _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , 'yet-another-stars-rating');
822
  echo "</p>";
823
 
824
- wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
825
 
826
  ?>
827
 
828
  <div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , 'yet-another-stars-rating') ?></div>
829
 
830
- <input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yet-another-stars-rating'); ?>">
831
 
832
  <input type="submit" value="<?php _e('Save changes', 'yet-another-stars-rating') ?>" class="button-primary" >
833
 
@@ -837,7 +838,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
837
 
838
  die();
839
 
840
- } //End function
841
 
842
 
843
 
@@ -848,7 +849,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
848
  if ( isset( $_POST['multi-set-name'])) {
849
 
850
  global $wpdb;
851
-
852
  if ( !current_user_can( 'manage_options' ) ) {
853
  wp_die( 'You are not allowed to be on this page.' );
854
  }
@@ -856,12 +857,12 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
856
  // Check nonce field
857
  check_admin_referer( 'add-multi-set', 'add-nonce-new-multi-set' );
858
 
859
- $array_errors = array();
860
  $error = FALSE;
861
 
862
  //IF thes fields are not empty go ahed
863
- if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
864
-
865
  $multi_set_name = ucfirst(strtolower($_POST['multi-set-name']));
866
 
867
  $multi_set_name_element_=array();
@@ -873,13 +874,13 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
873
  if (mb_strlen($multi_set_name) < 3 || mb_strlen($multi_set_name_element_[1]) <3 || mb_strlen($multi_set_name_element_[2]) < 3 ) {
874
  $array_errors[] = "Content field must be longer than 3 chars";
875
  $error=TRUE;
876
- }
877
 
878
 
879
  if (mb_strlen($multi_set_name) > 40 || mb_strlen($multi_set_name_element_[1]) > 40 || mb_strlen($multi_set_name_element_[2]) > 40 ) {
880
  $array_errors[] = "Content field must be shorter than 40 chars";
881
  $error=TRUE;
882
- }
883
 
884
  //Check if a set with that name already exists
885
  $check_name_exists=$wpdb->get_results("SELECT set_name FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
@@ -914,15 +915,15 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
914
 
915
  $element_filled++;
916
  }
917
-
918
  }
919
 
920
  //If there isnt any error write in the table
921
- if (!$error) {
922
 
923
  //get the highest id in table
924
  $highest_id=$wpdb->get_results("SELECT set_id FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id DESC LIMIT 1 ");
925
-
926
  if (!$highest_id) {
927
  $name_table_new_id=0;
928
  }
@@ -986,8 +987,8 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
986
 
987
  } //End if !$error
988
 
989
- } //End if $_POST['multi-set-name']!=''
990
-
991
  //Else multi set's name and first 2 elements are empty
992
  else {
993
  $array_errors[] = "Multi Set's name and first 2 elements can't be empty";
@@ -1016,8 +1017,8 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1016
 
1017
  global $wpdb;
1018
 
1019
- $array_errors = array();
1020
-
1021
  if ( !current_user_can( 'manage_options' ) ) {
1022
  wp_die( 'You are not allowed to be on this page.' );
1023
  }
@@ -1029,7 +1030,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1029
  //Check if user want to delete entire set
1030
 
1031
  if (isset($_POST["yasr-remove-multi-set"])) {
1032
-
1033
  $remove_set = $wpdb->delete (
1034
  YASR_MULTI_SET_NAME_TABLE,
1035
  array(
@@ -1055,21 +1056,21 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1055
  );
1056
 
1057
  if ($remove_set==FALSE) {
1058
- $error = TRUE;
1059
  $array_errors[] .= __("Something goes wrong trying to delete a Multi Set . Please report it", 'yet-another-stars-rating');
1060
  }
1061
 
1062
 
1063
  //Comment this out, if try to delete an empty set print error
1064
  /*if ($remove_set_values==FALSE) {
1065
- $error = TRUE;
1066
  $array_errors[] .= __("Something goes wrong trying to delete data fields for a set. Please report it", 'yet-another-stars-rating');
1067
  }
1068
  */
1069
 
1070
  //Comment this out, will echo error even if the value for that field it's just empty
1071
  /*if ($remove_set_votes==FALSE) {
1072
- $error = TRUE;
1073
  $array_errors[] .= __("Something goes wrong trying to delete data values for a set. Please report it", 'yet-another-stars-rating');
1074
  }*/
1075
 
@@ -1101,18 +1102,18 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1101
  );
1102
 
1103
  if ($remove_field == FALSE) {
1104
- $error = TRUE;
1105
  $array_errors[] = __("Something goes wrong trying to delete a Multi Set's element. Please report it", 'yet-another-stars-rating');
1106
  }
1107
 
1108
 
1109
  //Comment this out, will echo error even if the value for that field it's just empty
1110
  /*if ($remove_values == FALSE) {
1111
- $error = TRUE;
1112
  $array_errors[] = __("Something goes wrong trying to delete data value for an element. Please report it", 'yet-another-stars-rating');
1113
  }*/
1114
 
1115
-
1116
  } //End if isset $_POST['remove-element-$i']
1117
 
1118
 
@@ -1161,11 +1162,11 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1161
  array ('%s'),
1162
 
1163
  array ('%d', '%d')
1164
-
1165
  );
1166
 
1167
  if ($insert_field_name == FALSE) {
1168
- $error = TRUE;
1169
  $array_errors[] = __("Something goes wrong trying to update a Multi Set's element. Please report it", 'yet-another-stars-rating');
1170
  }
1171
 
@@ -1173,8 +1174,8 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1173
 
1174
  }
1175
 
1176
- } //End if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i<=$number_of_stored_elements )
1177
-
1178
 
1179
  //If $i > number of stored elements, user is adding new elements, so we're going to insert the new ones
1180
  if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) && !isset($_POST["remove-element-$i"]) && $i > $number_of_stored_elements ) {
@@ -1183,7 +1184,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1183
 
1184
  //if elements name is shorter than 3 chars return error. I use mb_strlen($field_name) > 1
1185
  //because I don't wont return error if an user add an empty field. An empty field will be
1186
- //just ignored
1187
  if (mb_strlen($field_name) > 1 && mb_strlen($field_name) < 3) {
1188
  $array_errors[] = __("Field # $i must be at least 3 characters", 'yet-another-stars-rating');
1189
  $error=TRUE;
@@ -1230,14 +1231,14 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1230
  }
1231
 
1232
  //get all the post id that are using this multiset
1233
- $array_post_id = $wpdb->get_results($wpdb->prepare("SELECT post_id
1234
- FROM " . YASR_MULTI_SET_VALUES_TABLE .
1235
  " WHERE set_type=%d
1236
  GROUP BY post_id", $set_id));
1237
 
1238
  //Insert the new fields
1239
  foreach ($array_post_id as $postid) {
1240
-
1241
  $insert_new_field_values_table = $wpdb->insert(
1242
  YASR_MULTI_SET_VALUES_TABLE,
1243
  array(
@@ -1254,11 +1255,11 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1254
  }
1255
 
1256
  if ($insert_set_value == FALSE) {
1257
- $error = TRUE;
1258
  $array_errors[] = __("Something goes wrong trying to insert set field name in edit form. Please report it", 'yet-another-stars-rating');
1259
  }
1260
 
1261
- } //end else
1262
  }
1263
 
1264
 
@@ -1277,7 +1278,7 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1277
 
1278
  } //End if isset( $_POST['yasr_edit_multi_set_form']
1279
 
1280
-
1281
  } //End yasr_process_edit_multi_set_form() function
1282
 
1283
 
@@ -1286,11 +1287,12 @@ add_action( 'admin_init', 'yasr_multiset_options_init' ); //This is for general
1286
  add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert options
1287
 
1288
  function yasr_style_options_init() {
 
1289
  register_setting(
1290
  'yasr_style_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
1291
  'yasr_style_options', //The name of an option to sanitize and save.
1292
  'yasr_style_options_sanitize'
1293
- );
1294
 
1295
  $style_options = get_option( 'yasr_style_options' );
1296
 
@@ -1304,7 +1306,7 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1304
 
1305
  add_settings_section( 'yasr_style_options_section_id', __('Style Options', 'yet-another-stars-rating'), 'yasr_style_section_callback', 'yasr_style_tab' );
1306
  add_settings_field( 'yasr_color_scheme_multiset', __('Which color scheme do you want to use?', 'yet-another-stars-rating') , 'yasr_color_scheme_multiset_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options);
1307
-
1308
  if (function_exists('yasr_st_upload_stars_callback')) {
1309
 
1310
  //If a default stars set was saved ...
@@ -1319,7 +1321,7 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1319
 
1320
  $style_options['stars_set'] = FALSE; //..avoid undefined index
1321
 
1322
- }
1323
 
1324
  add_settings_field( 'yasr_st_upload_stars', __('Select the set you\'ve uploaded', 'yet-another-stars-rating'), 'yasr_st_upload_stars_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options );
1325
  add_settings_field( 'yasr_st_choose_stars_radio', __('Choose Stars Set', 'yet-another-stars-rating'), 'yasr_st_choose_stars_radio_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options );
@@ -1331,21 +1333,21 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1331
  }
1332
 
1333
  function yasr_style_section_callback () {
1334
-
1335
  }
1336
 
1337
-
1338
 
1339
  function yasr_color_scheme_multiset_callback($style_options) {
1340
 
1341
  ?>
1342
 
1343
- <input type='radio' name='yasr_style_options[scheme_color_multiset]' value='light' class='yasr-general-options-scheme-color' <?php if ($style_options['scheme_color_multiset']==='light') echo " checked=\"checked\" "; ?> />
1344
  <?php _e('Light', 'yet-another-stars-rating')?>
1345
-
1346
  &nbsp;&nbsp;&nbsp;
1347
 
1348
- <input type='radio' name='yasr_style_options[scheme_color_multiset]' value='dark' class='yasr-general-options-scheme-color' <?php if ($style_options['scheme_color_multiset']==='dark') echo " checked=\"checked\" "; ?> />
1349
  <?php _e('Dark', 'yet-another-stars-rating')?>
1350
  <br />
1351
 
@@ -1354,7 +1356,7 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1354
  <a href="#" id="yasr-color-scheme-preview-link"><?php _e("Preview", 'yet-another-stars-rating') ?></a>
1355
 
1356
  <div id="yasr-color-scheme-preview" style="display:none">
1357
- <?php
1358
 
1359
  _e("Light theme", 'yet-another-stars-rating');
1360
  echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr-multi-set.png>";
@@ -1379,7 +1381,7 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1379
  echo "</strong><p>";
1380
 
1381
  echo ("
1382
- <textarea rows=\"20\" cols=\"50\" name=\"yasr_style_options[textarea]\" id=\"yasr_style_options_textarea\">$style_options[textarea]</textarea>
1383
  ");
1384
 
1385
  }
@@ -1388,7 +1390,7 @@ add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert
1388
  function yasr_style_options_sanitize ($style_options) {
1389
 
1390
  foreach ($style_options as $key => $value) {
1391
-
1392
  $output[$key] = strip_tags( stripslashes( $style_options[$key] ) );
1393
 
1394
  }
@@ -1453,14 +1455,14 @@ function yasr_fb_box ($position=FALSE) {
1453
  <blockquote cite="https://www.facebook.com/yetanotherstarsrating"><a href="https://www.facebook.com/yetanotherstarsrating">YASR - Yet Another Stars Rating</a></blockquote>
1454
  </div>
1455
  </div>
1456
-
1457
  </div>
1458
 
1459
  <?php
1460
 
1461
  }
1462
 
1463
- /** Add a box on the right for asking to rate 5 stars on Wordpress.org
1464
  * It must be appear after 10 logged rating, after 100 and after 1000
1465
  * Since version 0.9.0
1466
  */
@@ -1489,11 +1491,11 @@ function yasr_ask_rating ($position=FALSE) {
1489
 
1490
  if($n_stored_ratings > 20) {
1491
 
1492
- $text = sprintf( __('Hey, seems like you reached %s votes on your site throught YASR! That\'s cool!', 'yet-another-stars-rating'),'<strong>'.$n_stored_ratings.'</strong>');
1493
  $text .= "<br />";
1494
  $text .= __('Can I ask a favor?', 'yet-another-stars-rating');
1495
  $text .= "<br />";
1496
- $text .= __('Can you please rate YASR 5 stars on', 'yet-another-stars-rating');
1497
  $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">wordpress.org?</a>';
1498
  $text .= __(' It will require just 1 min but it\'s a HUGE help for me. Thank you.' , 'yet-another-stars-rating');
1499
  $text .= "<br /><br />";
@@ -1512,16 +1514,16 @@ function yasr_ask_rating ($position=FALSE) {
1512
 
1513
  echo $div_and_text;
1514
 
1515
- }
1516
 
1517
  } //End if (!transient)
1518
-
1519
 
1520
  }
1521
 
1522
 
1523
 
1524
- /** Change default admin footer on yasr settings pages
1525
  * $text is the default wordpress text
1526
  * Since 0.8.9
1527
  */
@@ -1592,9 +1594,9 @@ function yasr_search_gd_star_rating () {
1592
  /****** Import the following Gd Star Rating columns FROM gdsr_data_article
1593
  post_id
1594
  user_voters
1595
- user_votes
1596
  visitor_voters
1597
- visitor_votes
1598
  review
1599
  ******/
1600
 
@@ -1619,8 +1621,8 @@ function yasr_import_gdstar_data(){
1619
 
1620
  $gdsr_data_article=$wpdb->prefix . 'gdsr_data_article';
1621
 
1622
- $data=$wpdb->get_results(" SELECT gd.post_id, (gd.user_voters + gd.visitor_voters) AS voters,
1623
- (gd.user_votes + gd.visitor_votes) AS sum_votes,
1624
  gd.review,
1625
  p.ID
1626
  FROM $gdsr_data_article AS gd, $wpdb->posts AS p
@@ -1655,7 +1657,7 @@ function yasr_import_gdstar_data(){
1655
  function yasr_import_gdstar_multi_set(){
1656
  global $wpdb;
1657
 
1658
- $table_name = $wpdb->prefix . 'gdsr_multis';
1659
 
1660
  $multi_set = $wpdb->get_results (" SELECT multi_id, name, stars, object FROM $table_name");
1661
 
@@ -1680,8 +1682,8 @@ function yasr_import_gdstar_multi_value(){
1680
  $table_gdsr_multis_data=$wpdb->prefix . 'gdsr_multis_data';
1681
  $table_gdsr_multis=$wpdb->prefix . 'gdsr_multis';
1682
 
1683
- $multi_set_data=$wpdb->get_results (" SELECT d.post_id,
1684
- v.user_votes, v.item_id,
1685
  m.multi_id
1686
  FROM $table_gdsr_multis_values AS v, $table_gdsr_multis_data AS d, $wpdb->posts AS p, $table_gdsr_multis AS m
1687
  WHERE v.id = d.id
@@ -1692,20 +1694,20 @@ function yasr_import_gdstar_multi_value(){
1692
  AND p.ID = d.post_id
1693
  AND d.multi_id = m.multi_id
1694
  AND p.post_status = 'publish'
1695
- AND v.source = 'rvw'
1696
  ORDER BY d.post_id, m.multi_id, v.item_id ASC ");
1697
 
1698
 
1699
  //Import multi set name: if a multiset use != 5 stars,
1700
- //then i search wich vote has that set and convert
1701
- //the vote to fit 5 stars vote
1702
  $old_multi_set = yasr_import_gdstar_multi_set();
1703
 
1704
  foreach ($old_multi_set AS $multi_set) { //Search wich set not use 5 stars
1705
  if ($multi_set->stars != 5) {
1706
  //Search in the $multi_set_data if some vote use a set with !=5 stars
1707
- foreach ($multi_set_data as $data_row) {
1708
- if ($data_row->multi_id == $multi_set->multi_id) {
1709
  $data_row->user_votes=($data_row->user_votes/$multi_set->stars)*5; //Vote convertion
1710
  }
1711
  } //End foreach $multi_set_data
@@ -1724,7 +1726,7 @@ function yasr_import_gdstar_logs() {
1724
 
1725
  $gdsr_log_data = $wpdb->get_results (" SELECT id AS post_id, user_id, vote, voted AS date, ip
1726
  FROM $table_gdsr_logs
1727
- WHERE vote_type = 'article'
1728
  ORDER BY date DESC ");
1729
 
1730
  return $gdsr_log_data;
@@ -1737,9 +1739,9 @@ function yasr_insert_gdstar_data($votes){
1737
 
1738
  foreach ( $votes as $column ) {
1739
  $result=$wpdb->replace(
1740
- YASR_VOTES_TABLE,
1741
- array (
1742
- 'post_id' => $column->post_id,
1743
  'overall_rating' => $column->review,
1744
  'number_of_votes' => $column->voters,
1745
  'sum_votes' =>$column->sum_votes
@@ -1778,7 +1780,7 @@ function yasr_insert_gdstar_logs($logs) {
1778
 
1779
  }
1780
 
1781
- /****** Insert gd star rating multi set name
1782
 
1783
  Thanks to Alessandro Carlo Chirico for his help in regex!
1784
  ******/
@@ -1802,7 +1804,7 @@ function yasr_insert_gdstar_multi_set($multi_set_names) {
1802
 
1803
  if(preg_match_all('#".+?"#', $value->object, $matches)) {
1804
  $fields = $matches[0];
1805
- }
1806
 
1807
  $fields = str_replace('"', '', $fields);
1808
 
@@ -1829,9 +1831,9 @@ function yasr_insert_gdstar_multi_set($multi_set_names) {
1829
 
1830
  }
1831
 
1832
- /******
1833
  Check how many stars the existing set use, than convert the vote
1834
- into 5 stars. Last insert GD Star Rating multi values
1835
  ******/
1836
  function yasr_insert_gdstar_multi_value($multi_datas) {
1837
  global $wpdb;
@@ -1843,10 +1845,10 @@ function yasr_insert_gdstar_multi_value($multi_datas) {
1843
  array(
1844
  'id' =>$i,
1845
  'post_id' => $value->post_id,
1846
- 'votes' => $value->user_votes,
1847
- 'field_id' => $value->item_id,
1848
  'set_type' => $value->multi_id
1849
- ),
1850
  array('%d', '%d', '%s', '%d','%d')
1851
  );
1852
  $i++;
@@ -1859,4 +1861,4 @@ function yasr_insert_gdstar_multi_value($multi_datas) {
1859
  /************************************************END IMPORT FUNCTIONS****************************************************/
1860
 
1861
 
1862
- ?>
25
  add_action( 'admin_init', 'yasr_general_options_init' ); //This is for general options
26
 
27
  function yasr_general_options_init() {
28
+
29
  register_setting(
30
  'yasr_general_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
31
  'yasr_general_options', //The name of an option to sanitize and save.
32
  'yasr_general_options_sanitize'
33
+ );
34
 
35
  $option = get_option( 'yasr_general_options' );
36
 
78
 
79
  <div class="yasr-indented-answer">
80
 
81
+ <input type='radio' name='yasr_general_options[auto_insert_enabled]' value='1' id='yasr_auto_insert_radio_on' <?php if ($option['auto_insert_enabled']==1) echo " checked='checked' "; ?> />
82
  <?php _e('Yes', 'yet-another-stars-rating') ?>
83
  &nbsp;&nbsp;&nbsp;
84
 
85
+
86
+ <input type='radio' name='yasr_general_options[auto_insert_enabled]' value='0' id='yasr_auto_insert_radio_off'
87
+ <?php
88
  if ($option['auto_insert_enabled']==0) {
89
  echo " checked='checked' />";
90
  }
93
  echo "/>";
94
  }
95
 
96
+ _e('No', 'yet-another-stars-rating');
97
 
98
+ ?>
99
 
100
  <p>&nbsp;</p>
101
 
175
 
176
  </div>
177
 
178
+ <?php
179
 
180
  $custom_post_types = yasr_get_custom_post_type('bool');
181
 
200
 
201
  </div>
202
 
203
+ <?php
204
  }
205
 
206
  else {
216
  ?>
217
 
218
  <hr />
219
+
220
 
221
  <?php
222
  } //End yasr_auto_insert_callback
223
 
224
 
225
  function yasr_show_overall_in_loop_callback($option) {
226
+
227
  ?>
228
 
229
+ <input type='radio' name='yasr_general_options[show_overall_in_loop]' value='enabled' class='yasr-general-option-show-overall-in-loop' <?php if ($option['show_overall_in_loop']==='enabled') echo " checked=\"checked\" "; ?> />
230
  <?php _e('Yes', 'yet-another-stars-rating')?>
231
 
232
  &nbsp;&nbsp;&nbsp;
233
 
234
+ <input type='radio' name='yasr_general_options[show_overall_in_loop]' value='disabled' class='yasr-general-option-show-overall-in-loop' <?php if ($option['show_overall_in_loop']==='disabled') echo " checked=\"checked\" "; ?> />
235
  <?php _e('No', 'yet-another-stars-rating')?>
236
  <br />
237
  <br />
252
 
253
  ?>
254
 
255
+ <input type='radio' name='yasr_general_options[show_visitor_votes_in_loop]' value='enabled' class='yasr-general-option-show-visitor-votes-in-loop' <?php if ($option['show_visitor_votes_in_loop']==='enabled') echo " checked=\"checked\" "; ?> />
256
  <?php _e('Yes', 'yet-another-stars-rating')?>
257
 
258
  &nbsp;&nbsp;&nbsp;
259
 
260
+ <input type='radio' name='yasr_general_options[show_visitor_votes_in_loop]' value='disabled' class='yasr-general-option-show-visitor-votes-in-loop' <?php if ($option['show_visitor_votes_in_loop']==='disabled') echo " checked=\"checked\" "; ?> />
261
  <?php _e('No', 'yet-another-stars-rating')?>
262
  <br />
263
  <br />
283
  $text_after_visitor_rating = htmlspecialchars("$option[text_after_visitor_rating]");
284
 
285
  $custom_text_user_votes = htmlentities("$option[custom_text_user_voted]");
286
+
287
  ?>
288
 
289
+ <input type='radio' name='yasr_general_options[text_before_stars]' value='1' id='yasr_text_before_star_on' <?php if ($option['text_before_stars']==1) echo " checked='checked' "; ?> />
290
  <?php _e('Yes', 'yet-another-stars-rating') ?>
291
  &nbsp;&nbsp;&nbsp;
292
 
295
  <?php _e('No', 'yet-another-stars-rating'); ?>
296
 
297
  <br /> <br />
298
+
299
+ <input type='text' name='yasr_general_options[text_before_overall]' id="yasr-general-options-custom-text-before-overall" class='yasr-general-options-text-before' <?php printf('value="%s"', $text_before_overall); ?> maxlength="40"/>
300
  <?php _e('Custom text to display before Overall Rating', 'yet-another-stars-rating')?>
301
 
302
  <br /> <br /> <br />
303
 
304
+ <input type='text' name='yasr_general_options[text_before_visitor_rating]' id="yasr-general-options-custom-text-before-visitor" class='yasr-general-options-text-before' <?php printf('value="%s"', $text_before_visitor_rating); ?> maxlength="80"/>
305
+ <?php _e('Custom text to display BEFORE Visitor Rating', 'yet-another-stars-rating')?>
306
 
307
  <br /> <br />
308
 
309
+
310
+ <input type='text' name='yasr_general_options[text_after_visitor_rating]' id="yasr-general-options-custom-text-after-visitor" class='yasr-general-options-text-before' <?php printf('value="%s"', $text_after_visitor_rating); ?> maxlength="80"/>
311
  <?php _e('Custom text to display AFTER Visitor Rating', 'yet-another-stars-rating')?>
312
 
313
  <br /> <br /> <br />
314
 
315
+ <input type='text' name='yasr_general_options[custom_text_user_voted]' id="yasr-general-options-custom-text-already-rated" class='yasr-general-options-text-before' <?php printf('value="%s"', $custom_text_user_votes); ?> maxlength="60"/>
316
  <?php _e('Custom text to display when a non logged user has already rated', 'yet-another-stars-rating')?>
317
 
318
 
341
 
342
  ?>
343
 
344
+ <input type='radio' name='yasr_general_options[visitors_stats]' value='yes' class='yasr-general-options-scheme-color' <?php if ($option['visitors_stats']==='yes') echo " checked=\"checked\" "; ?> />
345
  <?php _e('Yes', 'yet-another-stars-rating')?>
346
+
347
  &nbsp;&nbsp;&nbsp;
348
 
349
+ <input type='radio' name='yasr_general_options[visitors_stats]' value='no' class='yasr-general-options-scheme-color' <?php if ($option['visitors_stats']==='no') echo " checked=\"checked\" "; ?> />
350
  <?php _e('No', 'yet-another-stars-rating')?>
351
  <br />
352
 
364
 
365
  ?>
366
 
367
+ <input type='radio' name='yasr_general_options[allowed_user]' value='logged_only' class='yasr_auto_insert_loggedonly' <?php if ($option['allowed_user']==='logged_only') echo " checked=\"checked\" "; ?> />
368
  <?php _e('Allow only logged-in users', 'yet-another-stars-rating')?>
369
  <br />
370
 
371
+ <input type='radio' name='yasr_general_options[allowed_user]' value='allow_anonymous' class='yasr_auto_insert_loggedonly' <?php if ($option['allowed_user']==='allow_anonymous') echo " checked=\"checked\" "; ?> />
372
  <?php _e('Allow everybody (logged in and anonymous)', 'yet-another-stars-rating')?>
373
  <br />
374
 
401
  <a href="#" id="yasr-snippet-explained-link"><?php _e("What is this?", 'yet-another-stars-rating') ?></a>
402
 
403
  <div id="yasr-snippet-explained" class="yasr-help-box-settings">
404
+ <?php
405
 
406
  _e("If you select \"Review Rating\", your site will be indexed from search engines like this: ", 'yet-another-stars-rating');
407
  echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr_review.png>";
419
 
420
  <br />
421
 
422
+ <strong><?php _e('Select default item type for all post or pages', 'yet-another-stars-rating'); ?></strong>
423
 
424
  <div class="yasr-indented-answer">
425
 
499
 
500
  //Array to return
501
  $output = array();
502
+
503
  // Loop through each of the incoming options
504
  foreach( $option as $key => $value ) {
505
+
506
  // Check to see if the current option has a value. If so, process it.
507
  if( isset( $option[$key] ) ) {
508
+
509
  // Strip all HTML and PHP tags and properly handle quoted strings
510
  $output[$key] = strip_tags( stripslashes( $option[ $key ] ) );
511
+
512
  } // end if
513
+
514
  } // end foreach
515
+
516
  // Return the array processing any additional functions filtered by this action
517
  //do not return $output but do apply_filter first,
518
 
533
  register_setting(
534
  'yasr_multiset_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
535
  'yasr_multiset_options' //The name of an option to sanitize and save.
536
+ );
537
 
538
  $option_multiset = get_option( 'yasr_multiset_options' );
539
 
540
  add_settings_section( 'yasr_multiset_options_section_id', '', 'yasr_multiset_section_callback', 'yasr_multiset_tab' );
541
+
542
  }
543
 
544
  function yasr_multiset_section_callback () {
547
 
548
  }
549
 
550
+
551
 
552
 
553
  /****** Create a form for settings page to create new multi set ******/
554
  function yasr_display_multi_set_form() {
555
  ?>
556
+
557
  <h4 class="yasr-multi-set-form-headers"><?php _e("Add New Multiple Set", 'yet-another-stars-rating'); ?></h4>
558
  <em><?php _e('Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yet-another-stars-rating') ?></em>
559
  <p>
560
  <form action="<?php echo admin_url('options-general.php?page=yasr_settings_page&tab=manage_multi') ?>" id="form_add_multi_set" method="post">
561
+ <strong><?php _e("Name", 'yet-another-stars-rating')?></strong>
562
  <input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
563
  <input type="hidden" name="action" value="yasr_new_multi_set_form" />
564
 
566
  <?php _e("You can insert up to nine elements", 'yet-another-stars-rating') ?>
567
  <br />
568
 
569
+ <?php for($i=1; $i<=9; $i++) {
570
 
571
  echo "<strong>" . __("Element ", 'yet-another-stars-rating') . "#$i" . "</strong>";
572
  ?>
581
  <input type="submit" value="<?php _e("Create New Set", 'yet-another-stars-rating') ?>" class="button-primary"/>
582
  </form>
583
 
584
+ <?php
585
  } //End function
586
 
587
 
611
 
612
  <button href="#" class="button-delete" id="yasr-button-select-set-edit-form"><?php _e("Select"); ?></button>
613
 
614
+
615
  </div>
616
 
617
  <?php
621
  elseif ($n_multi_set == 1) {
622
 
623
  $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id, parent_set_id AS set_id
624
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
625
  ORDER BY field_id ASC");
626
 
627
  foreach ($multi_set as $find_set_id) {
629
  }
630
 
631
  ?>
632
+
633
  <div class="yasr-manage-multiset-single">
634
 
635
  <h4 class="yasr-multi-set-form-headers"><?php _e("Manage Multiple Set", 'yet-another-stars-rating'); ?></h4>
641
  <table id="yasr-table-form-edit-multi-set">
642
  <tr>
643
 
644
+ <td id="yasr-table-form-edit-multi-set-header">
645
  <?php _e('Field name', 'yet-another-stars-rating') ?>
646
  </td>
647
 
648
+ <td id="yasr-table-form-edit-multi-set-remove">
649
+ <?php _e('Remove', 'yet-another-stars-rating') ?>
650
  </td>
651
 
652
  </tr>
659
 
660
  echo "
661
  <tr>
662
+
663
  <td width=\"80%\">
664
+ Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$i\">
665
+ <input type=\"hidden\" value=\"$name->id\" name=\"db-id-for-element-$i\">
666
  </td>
667
 
668
  <td width=\"20%\" style=\"text-align:center\">
671
 
672
  </tr>
673
  ";
674
+
675
  $i++;
676
 
677
  }
704
  _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , 'yet-another-stars-rating');
705
  echo "</p>";
706
 
707
+ wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
708
 
709
  ?>
710
 
711
  <div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , 'yet-another-stars-rating') ?></div>
712
 
713
+ <input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yet-another-stars-rating'); ?>">
714
 
715
+ <input type="submit" value="<?php _e('Save changes', 'yet-another-stars-rating') ?>" class="button-primary" >
716
 
717
  </form>
718
 
744
  global $wpdb;
745
 
746
  $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
747
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
748
+ WHERE parent_set_id=%d
749
  ORDER BY field_id ASC", $set_type));
750
 
751
+
752
 
753
  ?>
754
 
759
  <table id="yasr-table-form-edit-multi-set">
760
  <tr>
761
 
762
+ <td id="yasr-table-form-edit-multi-set-header">
763
  <?php _e('Field name', 'yet-another-stars-rating') ?>
764
  </td>
765
 
766
+ <td id="yasr-table-form-edit-multi-set-remove">
767
+ <?php _e('Remove', 'yet-another-stars-rating') ?>
768
  </td>
769
 
770
  </tr>
771
+
772
  <?php
773
 
774
  $i=1;
777
 
778
  echo "
779
  <tr>
780
+
781
  <td width=\"80%\">
782
+ Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$i\">
783
  <input type=\"hidden\" value=\"$name->id\" name=\"db-id-for-element-$i\">
784
  </td>
785
 
822
  _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , 'yet-another-stars-rating');
823
  echo "</p>";
824
 
825
+ wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
826
 
827
  ?>
828
 
829
  <div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , 'yet-another-stars-rating') ?></div>
830
 
831
+ <input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yet-another-stars-rating'); ?>">
832
 
833
  <input type="submit" value="<?php _e('Save changes', 'yet-another-stars-rating') ?>" class="button-primary" >
834
 
838
 
839
  die();
840
 
841
+ } //End function
842
 
843
 
844
 
849
  if ( isset( $_POST['multi-set-name'])) {
850
 
851
  global $wpdb;
852
+
853
  if ( !current_user_can( 'manage_options' ) ) {
854
  wp_die( 'You are not allowed to be on this page.' );
855
  }
857
  // Check nonce field
858
  check_admin_referer( 'add-multi-set', 'add-nonce-new-multi-set' );
859
 
860
+ $array_errors = array();
861
  $error = FALSE;
862
 
863
  //IF thes fields are not empty go ahed
864
+ if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
865
+
866
  $multi_set_name = ucfirst(strtolower($_POST['multi-set-name']));
867
 
868
  $multi_set_name_element_=array();
874
  if (mb_strlen($multi_set_name) < 3 || mb_strlen($multi_set_name_element_[1]) <3 || mb_strlen($multi_set_name_element_[2]) < 3 ) {
875
  $array_errors[] = "Content field must be longer than 3 chars";
876
  $error=TRUE;
877
+ }
878
 
879
 
880
  if (mb_strlen($multi_set_name) > 40 || mb_strlen($multi_set_name_element_[1]) > 40 || mb_strlen($multi_set_name_element_[2]) > 40 ) {
881
  $array_errors[] = "Content field must be shorter than 40 chars";
882
  $error=TRUE;
883
+ }
884
 
885
  //Check if a set with that name already exists
886
  $check_name_exists=$wpdb->get_results("SELECT set_name FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
915
 
916
  $element_filled++;
917
  }
918
+
919
  }
920
 
921
  //If there isnt any error write in the table
922
+ if (!$error) {
923
 
924
  //get the highest id in table
925
  $highest_id=$wpdb->get_results("SELECT set_id FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id DESC LIMIT 1 ");
926
+
927
  if (!$highest_id) {
928
  $name_table_new_id=0;
929
  }
987
 
988
  } //End if !$error
989
 
990
+ } //End if $_POST['multi-set-name']!=''
991
+
992
  //Else multi set's name and first 2 elements are empty
993
  else {
994
  $array_errors[] = "Multi Set's name and first 2 elements can't be empty";
1017
 
1018
  global $wpdb;
1019
 
1020
+ $array_errors = array();
1021
+
1022
  if ( !current_user_can( 'manage_options' ) ) {
1023
  wp_die( 'You are not allowed to be on this page.' );
1024
  }
1030
  //Check if user want to delete entire set
1031
 
1032
  if (isset($_POST["yasr-remove-multi-set"])) {
1033
+
1034
  $remove_set = $wpdb->delete (
1035
  YASR_MULTI_SET_NAME_TABLE,
1036
  array(
1056
  );
1057
 
1058
  if ($remove_set==FALSE) {
1059
+ $error = TRUE;
1060
  $array_errors[] .= __("Something goes wrong trying to delete a Multi Set . Please report it", 'yet-another-stars-rating');
1061
  }
1062
 
1063
 
1064
  //Comment this out, if try to delete an empty set print error
1065
  /*if ($remove_set_values==FALSE) {
1066
+ $error = TRUE;
1067
  $array_errors[] .= __("Something goes wrong trying to delete data fields for a set. Please report it", 'yet-another-stars-rating');
1068
  }
1069
  */
1070
 
1071
  //Comment this out, will echo error even if the value for that field it's just empty
1072
  /*if ($remove_set_votes==FALSE) {
1073
+ $error = TRUE;
1074
  $array_errors[] .= __("Something goes wrong trying to delete data values for a set. Please report it", 'yet-another-stars-rating');
1075
  }*/
1076
 
1102
  );
1103
 
1104
  if ($remove_field == FALSE) {
1105
+ $error = TRUE;
1106
  $array_errors[] = __("Something goes wrong trying to delete a Multi Set's element. Please report it", 'yet-another-stars-rating');
1107
  }
1108
 
1109
 
1110
  //Comment this out, will echo error even if the value for that field it's just empty
1111
  /*if ($remove_values == FALSE) {
1112
+ $error = TRUE;
1113
  $array_errors[] = __("Something goes wrong trying to delete data value for an element. Please report it", 'yet-another-stars-rating');
1114
  }*/
1115
 
1116
+
1117
  } //End if isset $_POST['remove-element-$i']
1118
 
1119
 
1162
  array ('%s'),
1163
 
1164
  array ('%d', '%d')
1165
+
1166
  );
1167
 
1168
  if ($insert_field_name == FALSE) {
1169
+ $error = TRUE;
1170
  $array_errors[] = __("Something goes wrong trying to update a Multi Set's element. Please report it", 'yet-another-stars-rating');
1171
  }
1172
 
1174
 
1175
  }
1176
 
1177
+ } //End if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i<=$number_of_stored_elements )
1178
+
1179
 
1180
  //If $i > number of stored elements, user is adding new elements, so we're going to insert the new ones
1181
  if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) && !isset($_POST["remove-element-$i"]) && $i > $number_of_stored_elements ) {
1184
 
1185
  //if elements name is shorter than 3 chars return error. I use mb_strlen($field_name) > 1
1186
  //because I don't wont return error if an user add an empty field. An empty field will be
1187
+ //just ignored
1188
  if (mb_strlen($field_name) > 1 && mb_strlen($field_name) < 3) {
1189
  $array_errors[] = __("Field # $i must be at least 3 characters", 'yet-another-stars-rating');
1190
  $error=TRUE;
1231
  }
1232
 
1233
  //get all the post id that are using this multiset
1234
+ $array_post_id = $wpdb->get_results($wpdb->prepare("SELECT post_id
1235
+ FROM " . YASR_MULTI_SET_VALUES_TABLE .
1236
  " WHERE set_type=%d
1237
  GROUP BY post_id", $set_id));
1238
 
1239
  //Insert the new fields
1240
  foreach ($array_post_id as $postid) {
1241
+
1242
  $insert_new_field_values_table = $wpdb->insert(
1243
  YASR_MULTI_SET_VALUES_TABLE,
1244
  array(
1255
  }
1256
 
1257
  if ($insert_set_value == FALSE) {
1258
+ $error = TRUE;
1259
  $array_errors[] = __("Something goes wrong trying to insert set field name in edit form. Please report it", 'yet-another-stars-rating');
1260
  }
1261
 
1262
+ } //end else
1263
  }
1264
 
1265
 
1278
 
1279
  } //End if isset( $_POST['yasr_edit_multi_set_form']
1280
 
1281
+
1282
  } //End yasr_process_edit_multi_set_form() function
1283
 
1284
 
1287
  add_action( 'admin_init', 'yasr_style_options_init' ); //This is for auto insert options
1288
 
1289
  function yasr_style_options_init() {
1290
+
1291
  register_setting(
1292
  'yasr_style_options_group', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
1293
  'yasr_style_options', //The name of an option to sanitize and save.
1294
  'yasr_style_options_sanitize'
1295
+ );
1296
 
1297
  $style_options = get_option( 'yasr_style_options' );
1298
 
1306
 
1307
  add_settings_section( 'yasr_style_options_section_id', __('Style Options', 'yet-another-stars-rating'), 'yasr_style_section_callback', 'yasr_style_tab' );
1308
  add_settings_field( 'yasr_color_scheme_multiset', __('Which color scheme do you want to use?', 'yet-another-stars-rating') , 'yasr_color_scheme_multiset_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options);
1309
+
1310
  if (function_exists('yasr_st_upload_stars_callback')) {
1311
 
1312
  //If a default stars set was saved ...
1321
 
1322
  $style_options['stars_set'] = FALSE; //..avoid undefined index
1323
 
1324
+ }
1325
 
1326
  add_settings_field( 'yasr_st_upload_stars', __('Select the set you\'ve uploaded', 'yet-another-stars-rating'), 'yasr_st_upload_stars_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options );
1327
  add_settings_field( 'yasr_st_choose_stars_radio', __('Choose Stars Set', 'yet-another-stars-rating'), 'yasr_st_choose_stars_radio_callback', 'yasr_style_tab', 'yasr_style_options_section_id', $style_options );
1333
  }
1334
 
1335
  function yasr_style_section_callback () {
1336
+
1337
  }
1338
 
1339
+
1340
 
1341
  function yasr_color_scheme_multiset_callback($style_options) {
1342
 
1343
  ?>
1344
 
1345
+ <input type='radio' name='yasr_style_options[scheme_color_multiset]' value='light' class='yasr-general-options-scheme-color' <?php if ($style_options['scheme_color_multiset']==='light') echo " checked=\"checked\" "; ?> />
1346
  <?php _e('Light', 'yet-another-stars-rating')?>
1347
+
1348
  &nbsp;&nbsp;&nbsp;
1349
 
1350
+ <input type='radio' name='yasr_style_options[scheme_color_multiset]' value='dark' class='yasr-general-options-scheme-color' <?php if ($style_options['scheme_color_multiset']==='dark') echo " checked=\"checked\" "; ?> />
1351
  <?php _e('Dark', 'yet-another-stars-rating')?>
1352
  <br />
1353
 
1356
  <a href="#" id="yasr-color-scheme-preview-link"><?php _e("Preview", 'yet-another-stars-rating') ?></a>
1357
 
1358
  <div id="yasr-color-scheme-preview" style="display:none">
1359
+ <?php
1360
 
1361
  _e("Light theme", 'yet-another-stars-rating');
1362
  echo "<br /><br /><img src=" . YASR_IMG_DIR . "yasr-multi-set.png>";
1381
  echo "</strong><p>";
1382
 
1383
  echo ("
1384
+ <textarea rows=\"20\" cols=\"50\" name=\"yasr_style_options[textarea]\" id=\"yasr_style_options_textarea\">$style_options[textarea]</textarea>
1385
  ");
1386
 
1387
  }
1390
  function yasr_style_options_sanitize ($style_options) {
1391
 
1392
  foreach ($style_options as $key => $value) {
1393
+
1394
  $output[$key] = strip_tags( stripslashes( $style_options[$key] ) );
1395
 
1396
  }
1455
  <blockquote cite="https://www.facebook.com/yetanotherstarsrating"><a href="https://www.facebook.com/yetanotherstarsrating">YASR - Yet Another Stars Rating</a></blockquote>
1456
  </div>
1457
  </div>
1458
+
1459
  </div>
1460
 
1461
  <?php
1462
 
1463
  }
1464
 
1465
+ /** Add a box on the right for asking to rate 5 stars on Wordpress.org
1466
  * It must be appear after 10 logged rating, after 100 and after 1000
1467
  * Since version 0.9.0
1468
  */
1491
 
1492
  if($n_stored_ratings > 20) {
1493
 
1494
+ $text = sprintf( __('Hey, seems like you reached %s votes on your site throught YASR! That\'s cool!', 'yet-another-stars-rating'),'<strong>'.$n_stored_ratings.'</strong>');
1495
  $text .= "<br />";
1496
  $text .= __('Can I ask a favor?', 'yet-another-stars-rating');
1497
  $text .= "<br />";
1498
+ $text .= __('Can you please rate YASR 5 stars on', 'yet-another-stars-rating');
1499
  $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">wordpress.org?</a>';
1500
  $text .= __(' It will require just 1 min but it\'s a HUGE help for me. Thank you.' , 'yet-another-stars-rating');
1501
  $text .= "<br /><br />";
1514
 
1515
  echo $div_and_text;
1516
 
1517
+ }
1518
 
1519
  } //End if (!transient)
1520
+
1521
 
1522
  }
1523
 
1524
 
1525
 
1526
+ /** Change default admin footer on yasr settings pages
1527
  * $text is the default wordpress text
1528
  * Since 0.8.9
1529
  */
1594
  /****** Import the following Gd Star Rating columns FROM gdsr_data_article
1595
  post_id
1596
  user_voters
1597
+ user_votes
1598
  visitor_voters
1599
+ visitor_votes
1600
  review
1601
  ******/
1602
 
1621
 
1622
  $gdsr_data_article=$wpdb->prefix . 'gdsr_data_article';
1623
 
1624
+ $data=$wpdb->get_results(" SELECT gd.post_id, (gd.user_voters + gd.visitor_voters) AS voters,
1625
+ (gd.user_votes + gd.visitor_votes) AS sum_votes,
1626
  gd.review,
1627
  p.ID
1628
  FROM $gdsr_data_article AS gd, $wpdb->posts AS p
1657
  function yasr_import_gdstar_multi_set(){
1658
  global $wpdb;
1659
 
1660
+ $table_name = $wpdb->prefix . 'gdsr_multis';
1661
 
1662
  $multi_set = $wpdb->get_results (" SELECT multi_id, name, stars, object FROM $table_name");
1663
 
1682
  $table_gdsr_multis_data=$wpdb->prefix . 'gdsr_multis_data';
1683
  $table_gdsr_multis=$wpdb->prefix . 'gdsr_multis';
1684
 
1685
+ $multi_set_data=$wpdb->get_results (" SELECT d.post_id,
1686
+ v.user_votes, v.item_id,
1687
  m.multi_id
1688
  FROM $table_gdsr_multis_values AS v, $table_gdsr_multis_data AS d, $wpdb->posts AS p, $table_gdsr_multis AS m
1689
  WHERE v.id = d.id
1694
  AND p.ID = d.post_id
1695
  AND d.multi_id = m.multi_id
1696
  AND p.post_status = 'publish'
1697
+ AND v.source = 'rvw'
1698
  ORDER BY d.post_id, m.multi_id, v.item_id ASC ");
1699
 
1700
 
1701
  //Import multi set name: if a multiset use != 5 stars,
1702
+ //then i search wich vote has that set and convert
1703
+ //the vote to fit 5 stars vote
1704
  $old_multi_set = yasr_import_gdstar_multi_set();
1705
 
1706
  foreach ($old_multi_set AS $multi_set) { //Search wich set not use 5 stars
1707
  if ($multi_set->stars != 5) {
1708
  //Search in the $multi_set_data if some vote use a set with !=5 stars
1709
+ foreach ($multi_set_data as $data_row) {
1710
+ if ($data_row->multi_id == $multi_set->multi_id) {
1711
  $data_row->user_votes=($data_row->user_votes/$multi_set->stars)*5; //Vote convertion
1712
  }
1713
  } //End foreach $multi_set_data
1726
 
1727
  $gdsr_log_data = $wpdb->get_results (" SELECT id AS post_id, user_id, vote, voted AS date, ip
1728
  FROM $table_gdsr_logs
1729
+ WHERE vote_type = 'article'
1730
  ORDER BY date DESC ");
1731
 
1732
  return $gdsr_log_data;
1739
 
1740
  foreach ( $votes as $column ) {
1741
  $result=$wpdb->replace(
1742
+ YASR_VOTES_TABLE,
1743
+ array (
1744
+ 'post_id' => $column->post_id,
1745
  'overall_rating' => $column->review,
1746
  'number_of_votes' => $column->voters,
1747
  'sum_votes' =>$column->sum_votes
1780
 
1781
  }
1782
 
1783
+ /****** Insert gd star rating multi set name
1784
 
1785
  Thanks to Alessandro Carlo Chirico for his help in regex!
1786
  ******/
1804
 
1805
  if(preg_match_all('#".+?"#', $value->object, $matches)) {
1806
  $fields = $matches[0];
1807
+ }
1808
 
1809
  $fields = str_replace('"', '', $fields);
1810
 
1831
 
1832
  }
1833
 
1834
+ /******
1835
  Check how many stars the existing set use, than convert the vote
1836
+ into 5 stars. Last insert GD Star Rating multi values
1837
  ******/
1838
  function yasr_insert_gdstar_multi_value($multi_datas) {
1839
  global $wpdb;
1845
  array(
1846
  'id' =>$i,
1847
  'post_id' => $value->post_id,
1848
+ 'votes' => $value->user_votes,
1849
+ 'field_id' => $value->item_id,
1850
  'set_type' => $value->multi_id
1851
+ ),
1852
  array('%d', '%d', '%s', '%d','%d')
1853
  );
1854
  $i++;
1861
  /************************************************END IMPORT FUNCTIONS****************************************************/
1862
 
1863
 
1864
+ ?>
lib/yasr-shortcode-functions.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
 
3
  /*
4
 
@@ -23,174 +23,165 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
23
  /****** Add shortcode for overall rating ******/
24
  add_shortcode ('yasr_overall_rating', 'shortcode_overall_rating_callback');
25
 
26
- function shortcode_overall_rating_callback ($atts) {
27
 
28
- extract( shortcode_atts (
29
- array(
30
- 'size' => 'large',
31
- 'postid' => FALSE
32
- ), $atts )
33
  );
34
 
35
- if(!$postid) {
36
 
37
- $overall_rating=yasr_get_overall_rating();
 
 
 
38
 
39
- }
40
 
41
- else {
42
 
43
- $overall_rating=yasr_get_overall_rating($postid);
44
 
45
- }
 
46
 
47
- if (!$overall_rating) {
48
- $overall_rating = "-1";
49
- }
50
 
51
- $shortcode_html = '';
52
 
53
- if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
54
 
55
- $text_before_star = str_replace('%overall_rating%', $overall_rating, YASR_TEXT_BEFORE_OVERALL);
56
 
57
- $shortcode_html = "<div class=\"yasr-container-custom-text-and-overall\">
58
- <span id=\"yasr-custom-text-before-overall\">" . $text_before_star . "</span>";
59
 
60
- }
61
 
62
- $stars_attribute = yasr_stars_size($size);
63
 
64
- $shortcode_html .= "<div class=\"$stars_attribute[class]\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"$stars_attribute[px_size]\" data-rateit-starheight=\"$stars_attribute[px_size]\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
 
65
 
 
66
 
67
- if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
68
 
69
- $shortcode_html .= "</div>";
70
-
71
- }
72
 
73
- //IF show overall rating in loop is disabled use is_singular && is_main query
74
- if ( YASR_SHOW_OVERALL_IN_LOOP === 'disabled' ) {
75
 
76
- if( is_singular() && is_main_query() ) {
 
77
 
78
  return $shortcode_html;
79
 
80
  }
81
 
82
- } // End if YASR_SHOW_OVERALL_IN_LOOP === 'disabled') {
83
-
84
- //If overall rating in loop is enabled don't use is_singular && is main_query
85
- elseif ( YASR_SHOW_OVERALL_IN_LOOP === 'enabled' ) {
86
-
87
- return $shortcode_html;
88
-
89
- }
90
-
91
- } //end function
92
 
93
 
94
  /****** Add shortcode for user vote ******/
95
 
96
  add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
97
 
98
- function shortcode_visitor_votes_callback ($atts) {
99
 
100
- $shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
101
 
102
- extract( shortcode_atts (
103
- array(
104
- 'size' => 'large',
105
- 'postid' => FALSE
106
- ), $atts )
107
- );
108
 
109
- //If it's not specified use get_the_id
110
- if (!$postid) {
111
 
112
- $post_id = get_the_ID();
113
 
114
- }
115
 
116
- else {
117
 
118
- $post_id = $postid;
119
 
120
- }
121
 
122
- $ajax_nonce_visitor = wp_create_nonce( "yasr_nonce_insert_visitor_rating" );
123
 
124
- $votes=yasr_get_visitor_votes($post_id); //always reference it
125
 
126
- $medium_rating=0; //Avoid undefined variable
127
 
128
- if (!$votes) {
129
- $votes=0; //Avoid undefined variable if there is not overall rating
130
- $votes_number=0; //Avoid undefined variable
131
- }
132
 
133
- else {
134
- foreach ($votes as $user_votes) {
135
- $votes_number = $user_votes->number_of_votes;
136
- if ($votes_number != 0 ) {
137
- $medium_rating = ($user_votes->sum_votes/$votes_number);
138
- }
139
- else {
140
- $medium_rating = 0;
 
141
  }
142
  }
143
- }
144
 
145
- $medium_rating=round($medium_rating, 1);
146
 
147
- $stars_attribute = yasr_stars_size($size);
148
 
149
- $yasr_cookiename = 'yasr_visitor_vote_' . $post_id;
150
 
151
- if (isset($_COOKIE[$yasr_cookiename])) {
152
 
153
- $cookie_value = $_COOKIE[$yasr_cookiename];
154
 
155
- $cookie_value = (int)$cookie_value;
156
 
157
- if ($cookie_value > 5) {
158
 
159
- $cookie_value = 5;
160
-
161
- }
162
 
163
- elseif ($cookie_value < 1) {
164
 
165
- $cookie_value = 1;
166
 
167
- }
168
 
169
- }
170
 
171
- else {
172
 
173
- $cookie_value = FALSE;
174
 
175
- }
176
 
177
- $vote_if_user_already_rated = FALSE;
178
 
179
- $shortcode_html = "<div id=\"yasr_visitor_votes_$post_id\" class=\"yasr-visitor-votes\">";
180
- $span_after_rate_it = "";
181
 
182
- //if anonymous are allowed to vote
183
- if (YASR_ALLOWED_USER === 'allow_anonymous') {
184
 
185
- //I've to checl a logged in user that has already rated
186
  if ( is_user_logged_in() ) {
187
 
188
- $readonly = 'false';
 
 
189
 
190
  //Chek if a logged in user has already rated for this post
191
  $vote_if_user_already_rated = yasr_check_if_user_already_voted($post_id);
192
 
193
- //If user has already rated
 
 
194
  if ($vote_if_user_already_rated) {
195
 
196
  $span_after_rate_it="<span class=\"yasr-small-block-bold yasr-already-voted-text \" id=\"yasr-user-vote-$post_id\" data-yasr-already-voted=\"$vote_if_user_already_rated\">" . __("You've already voted this article with", 'yet-another-stars-rating') . " $vote_if_user_already_rated </span>";
@@ -199,496 +190,502 @@ function shortcode_visitor_votes_callback ($atts) {
199
 
200
  } //End if user is logged
201
 
202
- else {
 
 
 
 
 
 
 
 
 
203
 
204
- //if cookie exists
205
- if($cookie_value) {
206
 
207
- $readonly = 'true';
208
 
209
- if (YASR_TEXT_BEFORE_STARS == 1 && YASR_CUSTOM_TEXT_USER_VOTED!='') {
210
 
211
- $span_after_rate_it = $span_after_rate_it="<span class=\"yasr-small-block-bold yasr-already-voted-text\">" . YASR_CUSTOM_TEXT_USER_VOTED . " </span>";;
 
 
 
 
212
 
213
  }
214
 
215
  else {
216
 
217
- $span_after_rate_it="<span class=\"yasr-small-block-bold yasr-already-voted-text \">" . __("You've already voted this article with", 'yet-another-stars-rating') . " $cookie_value </span>";
218
 
219
  }
220
 
221
  }
222
 
223
- else {
224
 
225
- $readonly = 'false';
226
 
227
- }
 
228
 
229
- }
230
-
231
- } //end if ($allow_logged_option['allowed_user']==='allow_anonymous') {
232
 
 
233
 
234
- //If only logged in users can vote
235
- elseif (YASR_ALLOWED_USER === 'logged_only') {
236
 
237
- //If user is logged in and can vote
238
- if ( is_user_logged_in() ) {
239
 
240
- $readonly = 'false'; //REadonly is false if user is logged
241
 
242
- //Chek if a logged in user has already rated for this post
243
- $vote_if_user_already_rated = yasr_check_if_user_already_voted($post_id);
244
 
245
- if ($vote_if_user_already_rated) {
246
 
247
- $span_after_rate_it="<span class=\"yasr-small-block-bold yasr-already-voted-text \" id=\"yasr-user-vote-$post_id\" data-yasr-already-voted=\"$vote_if_user_already_rated\">" . __("You've already voted this article with", 'yet-another-stars-rating') . " $vote_if_user_already_rated </span>";
248
 
249
- }
250
 
251
- } //End if user is logged in
252
 
253
- //Else mean user is not logged in and can't vote
254
- else {
255
 
256
- $readonly = 'true'; //readonly is true if user isn't logged
257
 
258
- $span_after_rate_it = __("You must sign in to vote", 'yet-another-stars-rating');
 
 
 
 
 
259
 
260
  }
261
 
262
- }
263
 
264
- if (YASR_VISITORS_STATS === 'yes') {
265
 
266
- $span_dashicon = "<span class=\"dashicons dashicons-chart-bar yasr-dashicons-visitor-stats \" id=\"yasr-total-average-dashicon-$post_id\" title=\"yasr-stats-dashicon\"></span>";
267
 
268
- }
269
 
270
- else {
271
 
272
- $span_dashicon = "";
273
 
274
- }
 
 
275
 
276
- if(YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_VISITOR_RATING != '') {
277
 
278
- $text_before_star = str_replace('%total_count%', $votes_number, YASR_TEXT_BEFORE_VISITOR_RATING);
279
 
280
- $text_before_star = str_replace('%average%', $medium_rating, $text_before_star);
281
 
282
- $shortcode_html .= "<div class=\"yasr-container-custom-text-and-visitor-rating\">
283
- <span id=\"yasr-custom-text-before-visitor-rating\">" . $text_before_star . "</span></div>";
284
 
285
- }
286
 
287
- if(YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_AFTER_VISITOR_RATING != '') {
 
 
 
 
 
288
 
289
- $text_after_star = str_replace('%total_count%', $votes_number, YASR_TEXT_AFTER_VISITOR_RATING);
290
 
291
- $text_after_star = str_replace('%average%', $medium_rating, $text_after_star);
 
292
 
293
- $span_text_after_star = "<span class=\"yasr-total-average-container\" id=\"yasr-total-average-text_$post_id\">" . $text_after_star . "</span>";
294
 
295
- }
296
 
297
- else {
298
 
299
- $span_text_after_star = "<span class=\"yasr-total-average-container\" id=\"yasr-total-average-text_$post_id\">
300
- [" . __("Total: ", 'yet-another-stars-rating') . "$votes_number &nbsp; &nbsp;" . __("Average: ",'yet-another-stars-rating') . "$medium_rating/5]
301
- </span>";
302
 
303
- }
 
304
 
305
- $shortcode_html .= "<div class=\"$stars_attribute[class]\" id=\"yasr_rateit_visitor_votes_$post_id\" data-postid=\"$post_id\" data-rateit-starwidth=\"$stars_attribute[px_size]\" data-rateit-starheight=\"$stars_attribute[px_size]\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"$readonly\"></div>";
306
 
307
- $shortcode_html .= $span_dashicon;
308
 
309
- $shortcode_html .= $span_text_after_star;
310
 
311
- $shortcode_html .= $span_after_rate_it;
312
 
313
- $shortcode_html .= "</div>";
 
314
 
315
- wp_localize_script( 'yasrfront', "yasrVisitorsVotesData", array(
316
- 'nonceVisitor' => $ajax_nonce_visitor
317
- )
318
- );
319
 
 
320
 
321
- //IF show visitor votes in loop is disabled use is_singular && is_main query
322
- if ( YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'disabled' ) {
 
 
 
 
323
 
324
- if( is_singular() && is_main_query() ) {
 
325
 
326
- return $shortcode_html;
327
 
328
  }
329
 
330
- } // End if YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'disabled') {
331
 
332
- //If overall rating in loop is enabled don't use is_singular && is main_query
333
- elseif ( YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'enabled' ) {
334
 
335
- return $shortcode_html;
336
 
337
- }
338
 
339
- } //End function shortcode_visitor_votes_callback
340
 
 
 
 
 
341
 
342
- /****** Show visitor votes average, READ ONLY ******/
343
- add_shortcode ('yasr_visitor_votes_readonly', 'yasr_visitor_votes_readonly_callback');
 
 
 
 
 
 
 
 
 
344
 
345
- function yasr_visitor_votes_readonly_callback ($atts) {
346
 
347
- $shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
348
 
349
- extract( shortcode_atts (
350
- array(
351
- 'size' => 'small',
352
- 'postid' => FALSE
353
- ), $atts )
354
- );
355
 
356
- //If it's not specified use get_the_id
357
- if (!$postid) {
358
 
359
- $post_id = get_the_ID();
360
 
361
- }
362
 
363
- else {
 
364
 
365
- $post_id = $postid;
366
 
367
- }
368
 
369
- $votes=yasr_get_visitor_votes($post_id);
370
 
371
- $medium_rating=0; //Avoid undefined variable
372
 
373
- if (!$votes) {
374
- $votes=0; //Avoid undefined variable if there is not overall rating
375
- $votes_number=0; //Avoid undefined variable
376
- }
377
 
378
- else {
379
- foreach ($votes as $user_votes) {
380
- $votes_number = $user_votes->number_of_votes;
381
- if ($votes_number != 0 ) {
382
- $medium_rating = ($user_votes->sum_votes/$votes_number);
383
- }
384
- else {
385
- $medium_rating = 0;
386
  }
387
- }
388
- }
389
 
390
- $medium_rating=round($medium_rating, 1);
391
 
392
- $stars_attribute = yasr_stars_size($size);
393
 
394
- $shortcode_html = "<div id=\"yasr_visitor_votes_readonly_$post_id\" class=\"yasr-visitor-votes_readonly\">";
395
- $span_after_rate_it = "";
396
 
397
- $shortcode_html .= "<div class=\"$stars_attribute[class]\" id=\"yasr_rateit_visitor_votes_readonly_$post_id\" data-rateit-starwidth=\"$stars_attribute[px_size]\" data-rateit-starheight=\"$stars_attribute[px_size]\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
398
 
399
- $shortcode_html .= "</div>";
400
 
 
401
 
402
- //IF show visitor votes in loop is disabled use is_singular && is_main query
403
- if ( YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'disabled' ) {
404
 
405
- if( is_singular() && is_main_query() ) {
 
 
 
 
 
 
406
 
407
- return $shortcode_html;
 
408
 
409
- }
410
 
411
- } // End if YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'disabled') {
412
 
413
- //If overall rating in loop is enabled don't use is_singular && is main_query
414
- elseif ( YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'enabled' ) {
415
 
416
- return $shortcode_html;
417
 
418
  }
419
 
420
- // } //End (!is_feed)
421
 
422
- } //End function shortcode_visitor_votes_only_stars_callback
423
 
 
 
 
 
 
 
 
 
 
424
 
425
- /****** Add shortcode for multiple set ******/
 
 
 
 
426
 
427
- add_shortcode ('yasr_multiset', 'shortcode_multi_set_callback');
 
 
 
 
 
 
 
428
 
429
- function shortcode_multi_set_callback( $atts ) {
430
 
431
- global $wpdb;
432
-
433
- // Attributes
434
- extract( shortcode_atts(
435
- array(
436
- 'setid' => '0',
437
- 'postid' => FALSE
438
- ), $atts )
439
- );
440
 
441
- //If it's not specified use get_the_id
442
- if (!$postid) {
443
 
444
- $post_id = get_the_ID();
445
 
446
- }
447
 
448
- else {
449
 
450
- $post_id = $postid;
451
 
452
- }
 
 
 
 
 
 
 
 
 
 
453
 
454
- $shortcode_html = ""; //Avoid undefined variable if used a missing setid
 
455
 
456
- $set_name_content=yasr_get_multi_set_values_and_field ($post_id, $setid);
457
 
458
- if ($set_name_content) {
459
- $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
460
- foreach ($set_name_content as $set_content) {
461
- $shortcode_html .= "<tr> <td><span class=\"yasr-multi-set-name-field\">$set_content->name </span></td>
462
- <td><div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
463
- </tr>";
464
  }
465
- $shortcode_html.="</table>";
466
- }
467
 
468
- else {
469
- $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
470
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
471
- WHERE parent_set_id=%f
472
- ORDER BY field_id ASC", $setid));
473
 
474
- $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
475
 
476
- foreach ($set_name as $set_content) {
477
- $shortcode_html .= "<tr> <td><span class=\"yasr-multi-set-name-field\">$set_content->name </span></td>
478
- <td><div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"0\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
479
- </tr>";
480
  }
481
- $shortcode_html.="</table>";
482
-
483
- }
484
 
485
- return $shortcode_html;
486
- } //End function
487
 
 
488
 
489
- /****** Add shortcode for multiset writable by users ******/
490
 
491
- add_shortcode ('yasr_visitor_multiset', 'yasr_visitor_multiset_callback');
492
 
493
- function yasr_visitor_multiset_callback ( $atts ) {
494
 
495
- $ajax_nonce_visitor_multiset = wp_create_nonce( "yasr_nonce_insert_visitor_rating_multiset" );
 
 
496
 
497
- global $wpdb;
498
-
499
- // Attributes
500
- extract( shortcode_atts(
501
- array(
502
- 'setid' => '0',
503
- 'postid' => FALSE
504
- ), $atts )
505
- );
506
 
507
- //If it's not specified use get_the_id
508
- if (!$postid) {
509
 
510
- $post_id = get_the_ID();
 
511
 
512
- }
513
 
514
- else {
 
 
515
 
516
- $post_id = $postid;
517
 
518
- }
519
 
520
- $cookiename = 'yasr_multi_visitor_cookie_' . $post_id . '_' . $setid;
 
 
521
 
522
- $image = YASR_IMG_DIR . "/loader.gif";
523
 
524
- $loader_html = "<span class=\"yasr-loader-multiset-visitor\" id=\"yasr-loader-multiset-visitor-$post_id-$setid\" >&nbsp; " . __("Loading, please wait",'yet-another-stars-rating') . ' <img src=' . "$image" .' title="yasr-loader" alt="yasr-loader"></span>';
525
 
 
526
 
527
- if (isset($_COOKIE[$cookiename])) {
 
528
 
529
- $button = "";
530
- $star_readonly = 'true';
531
- $span_message_content = __('Thank you for voting! ', 'yet-another-stars-rating');
 
 
532
 
533
  }
534
 
535
- else {
536
 
537
- //If user is not logged in
538
- if (!is_user_logged_in()) {
539
 
540
- if (YASR_ALLOWED_USER === 'allow_anonymous') {
541
 
542
- $button = "<input type=\"submit\" name=\"submit\" id=\"yasr-send-visitor-multiset-$post_id-$setid\" class=\"button button-primary\" value=\"". __('Submit!', 'yet-another-stars-rating') . " \" />";
543
- $star_readonly = 'false';
544
- $span_message_content = "";
545
 
546
- }
547
 
548
- elseif (YASR_ALLOWED_USER === 'logged_only') {
549
 
550
- $button = "<input type=\"submit\" name=\"submit\" id=\"yasr-send-visitor-multiset-$post_id-$setid\" class=\"button button-primary\" value=\"". __('Submit!', 'yet-another-stars-rating') . " \" />";
551
- $star_readonly = 'true';
552
- $span_message_content = __("You must sign in to vote", 'yet-another-stars-rating');;
553
 
554
- }
555
 
 
556
 
557
- } //End if user logged in
558
 
559
- //Is user is logged in
560
- else {
561
 
562
- $button = "<input type=\"submit\" name=\"submit\" id=\"yasr-send-visitor-multiset-$post_id-$setid\" class=\"button button-primary\" value=\"" . __('Submit!', 'yet-another-stars-rating') . " \" />";
563
- $star_readonly = 'false';
564
- $span_message_content = "";
565
-
 
 
 
 
 
566
  }
567
 
568
- }
 
 
 
 
 
 
 
 
569
 
570
- $set_name_content = yasr_get_multi_set_visitor ($post_id, $setid);
571
 
572
- if ($set_name_content) {
 
 
 
573
 
574
- $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
575
 
576
- foreach ($set_name_content as $set_content) {
577
 
578
- if($set_content->number_of_votes > 0) {
579
 
580
- $average_rating = $set_content->sum_votes / $set_content->number_of_votes;
 
 
 
 
 
 
 
 
581
 
582
- $average_rating = round($average_rating, 1);
583
 
584
- }
585
 
586
- else {
587
 
588
- $average_rating = 0;
 
589
 
590
- }
 
 
 
591
 
592
- $shortcode_html .= "<tr>
593
- <td>
594
- <span class=\"yasr-multi-set-name-field\">$set_content->name </span>
595
- </td>
596
- <td>
597
- <div class=\"rateit yasr-visitor-multi-$post_id-$setid\" id=\"$set_content->id \" data-rateit-value=\"$average_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"$star_readonly\"></div>
598
- <span class=\"yasr-visitor-multiset-vote-count\">$set_content->number_of_votes</span>
599
- </td>
600
- </tr>";
601
- }
602
-
603
- $shortcode_html.="<tr>
604
- <td colspan=\"2\">
605
- $button
606
- $loader_html
607
- <span class=\"yasr-visitor-multiset-message\">$span_message_content</span>
608
- </td>
609
- </tr>
610
- </table>";
611
- }
612
 
613
- else {
 
 
 
 
 
 
 
 
 
 
 
614
 
615
- $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
616
- FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
617
- WHERE parent_set_id=%d
618
- ORDER BY field_id ASC", $setid));
619
 
 
620
 
621
- $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
 
 
 
 
 
 
 
622
 
623
- foreach ($set_name as $set_content) {
624
 
625
- $shortcode_html .= "<tr>
626
- <td>
627
- <span class=\"yasr-multi-set-name-field\">$set_content->name </span>
628
- </td>
629
- <td>
630
- <div class=\"rateit yasr-visitor-multi-$post_id-$setid\" id=\"$set_content->id\" data-rateit-value=\"0\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
631
- <span class=\"yasr-visitor-multiset-vote-count\"> 0 </span>
632
- </td>
633
- </tr>";
634
 
635
 
 
 
 
 
636
 
637
- //First time, initialize all fields to 0
638
 
639
- //Find the highest_id (it's not auto increment on db due to gd star compatibility)
640
- $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
641
-
642
- //highest id is 0 in data is empty
643
- if (!$highest_id) {
644
- $new_id=0;
645
- }
646
 
647
- //or is n+1
648
- foreach ($highest_id as $id) {
649
- $new_id=$id->id + 1;
650
- }
651
 
652
- $wpdb->replace(
653
- YASR_MULTI_SET_VALUES_TABLE,
654
- array (
655
- 'id'=>$new_id,
656
- 'post_id'=>$post_id,
657
- 'field_id'=>$set_content->id,
658
- 'set_type'=>$setid,
659
- 'number_of_votes' => 0,
660
- 'sum_votes' => 0
661
- ),
662
- array ("%d", "%d", "%d", "%d", "%d", "%d")
663
- );
664
-
665
-
666
- } //end foreach ($set_name as $set_content)
667
-
668
- $shortcode_html.="<tr>
669
- <td colspan=\"2\">
670
- $button
671
- $loader_html
672
- <span class=\"yasr-visitor-multiset-message\">$span_message_content</span>
673
- </td>
674
- </tr>
675
- </table>";
676
 
677
- $shortcode_html.="</table>";
678
 
679
- }
680
 
681
- wp_localize_script( 'yasrfront', 'yasrMultiSetData', array(
682
- 'setType' => $setid,
683
- 'nonce' => $ajax_nonce_visitor_multiset,
684
- 'postid' => $post_id
685
- )
686
- );
687
 
 
688
 
689
- return $shortcode_html;
690
 
691
- }
 
 
692
 
693
 
694
 
@@ -696,238 +693,238 @@ function yasr_visitor_multiset_callback ( $atts ) {
696
 
697
  add_shortcode ('yasr_top_ten_highest_rated', 'yasr_top_ten_highest_rated_callback');
698
 
699
- function yasr_top_ten_highest_rated_callback () {
700
 
701
- global $wpdb;
702
 
703
- $query_result = $wpdb->get_results("SELECT v.overall_rating, v.post_id
704
- FROM " . YASR_VOTES_TABLE . " AS v, $wpdb->posts AS p
705
- WHERE v.post_id = p.ID
706
- AND p.post_status = 'publish'
707
- AND v.overall_rating > 0
708
- ORDER BY v.overall_rating DESC, v.id ASC LIMIT 10");
709
 
710
- if ($query_result) {
711
 
712
- $shortcode_html = "<table class=\"yasr-table-chart\">";
713
 
714
- foreach ($query_result as $result) {
715
 
716
- $post_title = get_the_title($result->post_id);
717
 
718
- $link = get_permalink($result->post_id); //Get permalink from post it
719
 
720
- $shortcode_html .= "<tr>
721
- <td width=\"60%\" class=\"yasr-top-10-overall-left\"><a href=\"$link\">$post_title</a></td>
722
- <td width=\"40%\" class=\"yasr-top-10-overall-right\">
723
- <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>
724
- <span class=\"yasr-highest-rated-text\">" . __("Rating", 'yet-another-stars-rating') . " $result->overall_rating </span>
725
- </td>
726
- </tr>";
727
 
728
 
729
- } //End foreach
730
 
731
- $shortcode_html .= "</table>";
732
 
733
- return $shortcode_html;
734
 
735
- } //end if $query_result
736
 
737
- else {
738
- _e("You don't have any votes stored", 'yet-another-stars-rating');
739
- }
740
 
741
- } //End function
742
 
743
 
744
  /****** Add top 10 most rated / highest rated post *****/
745
 
746
  add_shortcode ('yasr_most_or_highest_rated_posts', 'yasr_most_or_highest_rated_posts_callback');
747
 
748
- function yasr_most_or_highest_rated_posts_callback () {
749
 
750
 
751
- $shortcode_html = "";
752
 
753
- global $wpdb;
754
 
755
- $query_result_most_rated = $wpdb->get_results("SELECT post_id, number_of_votes, sum_votes
756
- FROM " . YASR_VOTES_TABLE . ", $wpdb->posts AS p
757
- WHERE post_id = p.ID
758
- AND number_of_votes >= 1
759
- AND p.post_status = 'publish'
760
- ORDER BY number_of_votes DESC, sum_votes DESC LIMIT 10");
761
 
762
- $query_result_highest = $wpdb->get_results("SELECT (sum_votes / number_of_votes) as result, post_id, number_of_votes
763
- FROM " . YASR_VOTES_TABLE . ", $wpdb->posts AS p
764
- WHERE post_id = p.ID
765
- AND number_of_votes >= 2
766
- AND p.post_status = 'publish'
767
- ORDER BY result DESC, number_of_votes DESC LIMIT 10
768
- ");
769
 
770
- if ($query_result_most_rated) {
771
 
772
- $shortcode_html .= "<table class=\"yasr-table-chart\" id=\"yasr-most-rated-posts\">
773
- <tr class=\"yasr-visitor-votes-title\">
774
- <th>" . __("Post / Page" , 'yet-another-stars-rating') ." </th>
775
- <th>". __("Order By" , 'yet-another-stars-rating') .":&nbsp;&nbsp;<span id=\"yasr_multi_chart_link_to_nothing\">" . __("Most Rated" , 'yet-another-stars-rating') ."</span> | <a href=\"#\" id=\"yasr_multi_chart_highest\">" . __("Highest Rated" , 'yet-another-stars-rating') ."</a></th>
776
- </tr>"
777
- ;
778
 
779
- foreach ($query_result_most_rated as $result) {
780
 
781
- $rating = $result->sum_votes / $result->number_of_votes;
782
 
783
- $rating = round($rating, 1);
784
 
785
- $post_title = get_the_title($result->post_id);
786
 
787
- $link = get_permalink($result->post_id); //Get permalink from post it
788
 
789
- $shortcode_html .= "<tr>
790
- <td width=\"60%\" class=\"yasr-top-10-most-highest-left\"><a href=\"$link\">$post_title</a></td>
791
- <td width=\"40%\" class=\"yasr-top-10-most-highest-right\"><div id=\"yasr_visitor_votes\">
792
- <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>
793
- <br /> [" . __("Total:" , 'yet-another-stars-rating') . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , 'yet-another-stars-rating') . " $rating]
794
- </td>
795
- </tr>";
796
 
797
 
798
- } //End foreach
799
 
800
- $shortcode_html .= "</table>" ;
801
 
802
- } //End if $query_result_most_rated)
803
 
804
- else {
805
- $shortcode_html = __("You've not enough data",'yet-another-stars-rating') . "<br />";
806
- }
807
 
808
-
809
- if ($query_result_highest) {
810
 
811
- $shortcode_html .= "<table class=\"yasr-table-chart\" id=\"yasr-highest-rated-posts\">
812
- <tr class=\"yasr-visitor-votes-title\">
813
- <th>" . __("Post / Page" , 'yet-another-stars-rating') ." </th>
814
- <th>". __("Order By" , 'yet-another-stars-rating') .":&nbsp;&nbsp; <a href=\"#\" id=\"yasr_multi_chart_most\">". __("Most Rated" , 'yet-another-stars-rating') ."</a> | <span id=\"yasr_multi_chart_link_to_nothing\">". __("Highest Rated" , 'yet-another-stars-rating') ."</span></th>
815
- </tr>";
816
 
817
- foreach ($query_result_highest as $result) {
 
 
 
 
818
 
819
- $rating = round($result->result, 1);
820
 
821
- $post_title = get_the_title($result->post_id);
822
 
823
- $link = get_permalink($result->post_id); //Get permalink from post it
824
 
825
- $shortcode_html .= "<tr>
826
- <td width=\"60%\" class=\"yasr-top-10-most-highest-left\"><a href=\"$link\">$post_title</a></td>
827
- <td width=\"40%\" class=\"yasr-top-10-most-highest-right\"><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>
828
- <br /> [" . __("Total:" , 'yet-another-stars-rating') . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , 'yet-another-stars-rating') . " $rating]
829
- </td>
830
- </tr>";
831
 
 
 
 
 
 
 
832
 
833
- } //End foreach
834
 
835
- $shortcode_html .= "</table>";
836
 
837
- } //end if $query_result
838
 
839
- else {
840
- $shortcode_html = __("You've not enought data",'yet-another-stars-rating') . "<br />";
841
- }
842
 
843
- ?>
 
 
844
 
845
- <script type="text/javascript">
846
 
847
- document.addEventListener('DOMContentLoaded', function(event) {
848
 
849
- yasrMostOrHighestRatedChart ();
850
 
851
- });
852
 
 
853
 
854
- </script>
855
 
856
- <?php
857
 
858
- return $shortcode_html;
 
 
859
 
860
 
861
- } //End function
862
 
863
 
864
  /****** Add top 5 most active reviewer ******/
865
 
866
  add_shortcode ('yasr_top_5_reviewers', 'yasr_top_5_reviewers_callback');
867
 
868
- function yasr_top_5_reviewers_callback () {
869
 
870
- global $wpdb;
871
 
872
- $query_result = $wpdb->get_results("SELECT COUNT( post_author ) as total_count, post_author as reviewer
873
- FROM $wpdb->posts AS p, " . YASR_VOTES_TABLE . "
874
- WHERE post_id = p.ID
875
- AND p.post_status = 'publish'
876
- GROUP BY post_author
877
- ORDER BY (total_count) DESC
878
- LIMIT 5");
879
 
880
 
881
- if ($query_result) {
882
 
883
- $shortcode_html = "
884
- <table class=\"yasr-table-chart\">
885
- <tr>
886
- <th>Author</th>
887
- <th>Reviews</th>
888
- </tr>
889
- ";
890
 
891
- foreach ($query_result as $result) {
892
 
893
- $user_data = get_userdata($result->reviewer);
894
 
895
- if ($user_data) {
896
 
897
- $user_profile = get_author_posts_url($result->reviewer);
898
 
899
- }
900
 
901
- else {
902
 
903
- $user_profile = '#';
904
- $user_data = new stdClass;
905
- $user_data->user_login = 'Anonymous';
906
-
907
- }
908
 
 
909
 
910
- $shortcode_html .= "<tr>
911
- <td><a href=\"$user_profile\">$user_data->user_login</a></td>
912
- <td>$result->total_count</td>
913
- </tr>";
914
-
915
- }
916
 
917
- $shortcode_html .= "</table>";
 
 
 
918
 
919
- return $shortcode_html;
920
 
921
- }
922
 
923
- else {
924
 
925
- _e("Problem while retrieving the top 5 most active reviewers. Did you publish any review?");
926
 
927
- }
928
 
 
 
 
929
 
930
- } //End top 5 reviewers function
 
931
 
932
 
933
 
@@ -937,63 +934,107 @@ function yasr_top_5_reviewers_callback () {
937
 
938
  add_shortcode ('yasr_top_ten_active_users', 'yasr_top_ten_active_users_callback');
939
 
940
- function yasr_top_ten_active_users_callback () {
941
 
942
- global $wpdb;
943
 
944
- $query_result = $wpdb->get_results("SELECT COUNT( user_id ) as total_count, user_id as user
945
- FROM " . YASR_LOG_TABLE . ", $wpdb->posts AS p
946
- WHERE post_id = p.ID
947
- AND p.post_status = 'publish'
948
- GROUP BY user_id
949
- ORDER BY ( total_count ) DESC
950
- LIMIT 10");
951
 
952
- if ($query_result) {
953
 
954
- $shortcode_html = "
955
- <table class=\"yasr-table-chart\">
956
- <tr>
957
- <th>UserName</th>
958
- <th>Number of votes</th>
959
- </tr>
960
- ";
961
 
962
- foreach ($query_result as $result) {
963
 
964
- $user_data = get_userdata($result->user);
965
 
966
- if ($user_data) {
967
 
968
- $user_profile = get_author_posts_url($result->user);
969
 
970
- }
 
 
 
 
 
 
 
 
 
 
 
971
 
972
- else {
973
- $user_profile = '#';
974
- $user_data = new stdClass;
975
- $user_data->user_login = 'Anonymous';
976
  }
977
 
978
- $shortcode_html .= "<tr>
979
- <td><a href=\"$user_profile\">$user_data->user_login</a></td>
980
- <td>$result->total_count</td>
981
- </tr>";
982
 
983
  }
984
 
 
 
 
985
 
986
- $shortcode_html .= "</table>";
987
 
988
- return $shortcode_html;
989
 
990
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
991
 
992
- else {
993
- _e("Problem while retrieving the top 10 active users chart. Are you sure you have votes to show?");
994
  }
995
 
996
 
997
- } //End function
 
 
 
998
 
999
  ?>
1
+ <?php
2
 
3
  /*
4
 
23
  /****** Add shortcode for overall rating ******/
24
  add_shortcode ('yasr_overall_rating', 'shortcode_overall_rating_callback');
25
 
26
+ function shortcode_overall_rating_callback ($atts) {
27
 
28
+ extract( shortcode_atts (
29
+ array(
30
+ 'size' => 'large',
31
+ 'postid' => FALSE
32
+ ), $atts )
33
  );
34
 
35
+ $overall_rating=yasr_get_overall_rating($postid);
36
 
37
+ //if still false
38
+ if (!$overall_rating) {
39
+ $overall_rating = "-1";
40
+ }
41
 
42
+ $shortcode_html = '';
43
 
44
+ if (YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_OVERALL != '') {
45
 
46
+ $text_before_star = str_replace('%overall_rating%', $overall_rating, YASR_TEXT_BEFORE_OVERALL);
47
 
48
+ $shortcode_html = "<div class=\"yasr-container-custom-text-and-overall\">
49
+ <span id=\"yasr-custom-text-before-overall\">" . $text_before_star . "</span>";
50
 
51
+ }
 
 
52
 
53
+ $stars_attribute = yasr_stars_size($size);
54
 
55
+ $shortcode_html .= "<div class=\"$stars_attribute[class]\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"$stars_attribute[px_size]\" data-rateit-starheight=\"$stars_attribute[px_size]\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
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
 
69
+ return $shortcode_html;
70
 
71
+ }
 
 
72
 
73
+ } // End if YASR_SHOW_OVERALL_IN_LOOP === 'disabled') {
 
74
 
75
+ //If overall rating in loop is enabled don't use is_singular && is main_query
76
+ elseif ( YASR_SHOW_OVERALL_IN_LOOP === 'enabled' ) {
77
 
78
  return $shortcode_html;
79
 
80
  }
81
 
82
+ } //end function
 
 
 
 
 
 
 
 
 
83
 
84
 
85
  /****** Add shortcode for user vote ******/
86
 
87
  add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
88
 
89
+ function shortcode_visitor_votes_callback ($atts) {
90
 
91
+ $shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
92
 
93
+ extract( shortcode_atts (
94
+ array(
95
+ 'size' => 'large',
96
+ 'postid' => FALSE
97
+ ), $atts )
98
+ );
99
 
100
+ //If it's not specified use get_the_id
101
+ if (!$postid) {
102
 
103
+ $post_id = get_the_ID();
104
 
105
+ }
106
 
107
+ else {
108
 
109
+ $post_id = $postid;
110
 
111
+ }
112
 
113
+ $ajax_nonce_visitor = wp_create_nonce( "yasr_nonce_insert_visitor_rating" );
114
 
115
+ $votes=yasr_get_visitor_votes($post_id); //always reference it
116
 
117
+ $medium_rating=0; //Avoid undefined variable
118
 
119
+ if (!$votes) {
120
+ $votes=0; //Avoid undefined variable if there is not overall rating
121
+ $votes_number=0; //Avoid undefined variable
122
+ }
123
 
124
+ else {
125
+ foreach ($votes as $user_votes) {
126
+ $votes_number = $user_votes->number_of_votes;
127
+ if ($votes_number != 0 ) {
128
+ $medium_rating = ($user_votes->sum_votes/$votes_number);
129
+ }
130
+ else {
131
+ $medium_rating = 0;
132
+ }
133
  }
134
  }
 
135
 
136
+ $medium_rating=round($medium_rating, 1);
137
 
138
+ $stars_attribute = yasr_stars_size($size);
139
 
140
+ $yasr_cookiename = 'yasr_visitor_vote_' . $post_id;
141
 
142
+ if (isset($_COOKIE[$yasr_cookiename])) {
143
 
144
+ $cookie_value = $_COOKIE[$yasr_cookiename];
145
 
146
+ $cookie_value = (int)$cookie_value;
147
 
148
+ if ($cookie_value > 5) {
149
 
150
+ $cookie_value = 5;
 
 
151
 
152
+ }
153
 
154
+ elseif ($cookie_value < 1) {
155
 
156
+ $cookie_value = 1;
157
 
158
+ }
159
 
160
+ }
161
 
162
+ else {
163
 
164
+ $cookie_value = FALSE;
165
 
166
+ }
167
 
 
 
168
 
169
+ $shortcode_html = "<div id=\"yasr_visitor_votes_$post_id\" class=\"yasr-visitor-votes\">";
170
+ $span_after_rate_it = "";
171
 
172
+ //I've to check a logged in user that has already rated
173
  if ( is_user_logged_in() ) {
174
 
175
+ $readonly = 'false'; //Always false if user is logged in
176
+
177
+ //$vote_if_user_already_rated = FALSE;
178
 
179
  //Chek if a logged in user has already rated for this post
180
  $vote_if_user_already_rated = yasr_check_if_user_already_voted($post_id);
181
 
182
+ //var_dump($vote_if_user_already_rated);
183
+
184
+ //If user has already rated
185
  if ($vote_if_user_already_rated) {
186
 
187
  $span_after_rate_it="<span class=\"yasr-small-block-bold yasr-already-voted-text \" id=\"yasr-user-vote-$post_id\" data-yasr-already-voted=\"$vote_if_user_already_rated\">" . __("You've already voted this article with", 'yet-another-stars-rating') . " $vote_if_user_already_rated </span>";
190
 
191
  } //End if user is logged
192
 
193
+ //if anonymous are allowed to vote
194
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
195
+
196
+ //IF user is not logged in
197
+ if(!is_user_logged_in()) {
198
+
199
+ //if cookie exists
200
+ if($cookie_value) {
201
+
202
+ $readonly = 'true';
203
 
204
+ if (YASR_TEXT_BEFORE_STARS == 1 && YASR_CUSTOM_TEXT_USER_VOTED!='') {
 
205
 
206
+ $span_after_rate_it = $span_after_rate_it="<span class=\"yasr-small-block-bold yasr-already-voted-text\">" . YASR_CUSTOM_TEXT_USER_VOTED . " </span>";;
207
 
208
+ }
209
 
210
+ else {
211
+
212
+ $span_after_rate_it="<span class=\"yasr-small-block-bold yasr-already-voted-text \">" . __("You've already voted this article with", 'yet-another-stars-rating') . " $cookie_value </span>";
213
+
214
+ }
215
 
216
  }
217
 
218
  else {
219
 
220
+ $readonly = 'false';
221
 
222
  }
223
 
224
  }
225
 
226
+ } //end if YASR_ALLOWED_USER === 'allow_anonymous' {
227
 
 
228
 
229
+ //If only logged in users can vote
230
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
231
 
232
+ //IF user is not logged in
233
+ if(!is_user_logged_in()) {
 
234
 
235
+ $readonly = 'true'; //readonly is true if user isn't logged
236
 
237
+ $span_after_rate_it = __("You must sign in to vote", 'yet-another-stars-rating');
 
238
 
239
+ }
 
240
 
241
+ }
242
 
243
+ if (YASR_VISITORS_STATS === 'yes') {
 
244
 
245
+ $span_dashicon = "<span class=\"dashicons dashicons-chart-bar yasr-dashicons-visitor-stats \" id=\"yasr-total-average-dashicon-$post_id\" title=\"yasr-stats-dashicon\"></span>";
246
 
247
+ }
248
 
249
+ else {
250
 
251
+ $span_dashicon = "";
252
 
253
+ }
 
254
 
255
+ if(YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_BEFORE_VISITOR_RATING != '') {
256
 
257
+ $text_before_star = str_replace('%total_count%', $votes_number, YASR_TEXT_BEFORE_VISITOR_RATING);
258
+
259
+ $text_before_star = str_replace('%average%', $medium_rating, $text_before_star);
260
+
261
+ $shortcode_html .= "<div class=\"yasr-container-custom-text-and-visitor-rating\">
262
+ <span id=\"yasr-custom-text-before-visitor-rating\">" . $text_before_star . "</span></div>";
263
 
264
  }
265
 
266
+ if(YASR_TEXT_BEFORE_STARS == 1 && YASR_TEXT_AFTER_VISITOR_RATING != '') {
267
 
268
+ $text_after_star = str_replace('%total_count%', $votes_number, YASR_TEXT_AFTER_VISITOR_RATING);
269
 
270
+ $text_after_star = str_replace('%average%', $medium_rating, $text_after_star);
271
 
272
+ $span_text_after_star = "<span class=\"yasr-total-average-container\" id=\"yasr-total-average-text_$post_id\">" . $text_after_star . "</span>";
273
 
274
+ }
275
 
276
+ else {
277
 
278
+ $span_text_after_star = "<span class=\"yasr-total-average-container\" id=\"yasr-total-average-text_$post_id\">
279
+ [" . __("Total: ", 'yet-another-stars-rating') . "$votes_number &nbsp; &nbsp;" . __("Average: ",'yet-another-stars-rating') . "$medium_rating/5]
280
+ </span>";
281
 
282
+ }
283
 
284
+ $shortcode_html .= "<div class=\"$stars_attribute[class]\" id=\"yasr_rateit_visitor_votes_$post_id\" data-postid=\"$post_id\" data-rateit-starwidth=\"$stars_attribute[px_size]\" data-rateit-starheight=\"$stars_attribute[px_size]\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"$readonly\"></div>";
285
 
286
+ $shortcode_html .= $span_dashicon;
287
 
288
+ $shortcode_html .= $span_text_after_star;
 
289
 
290
+ $shortcode_html .= $span_after_rate_it;
291
 
292
+ $shortcode_html .= "</div>";
293
+
294
+ wp_localize_script( 'yasrfront', "yasrVisitorsVotesData", array(
295
+ 'nonceVisitor' => $ajax_nonce_visitor
296
+ )
297
+ );
298
 
 
299
 
300
+ //IF show visitor votes in loop is disabled use is_singular && is_main query
301
+ if ( YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'disabled' ) {
302
 
303
+ if( is_singular() && is_main_query() ) {
304
 
305
+ return $shortcode_html;
306
 
307
+ }
308
 
309
+ } // End if YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'disabled') {
 
 
310
 
311
+ //If overall rating in loop is enabled don't use is_singular && is main_query
312
+ elseif ( YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'enabled' ) {
313
 
314
+ return $shortcode_html;
315
 
316
+ }
317
 
318
+ } //End function shortcode_visitor_votes_callback
319
 
 
320
 
321
+ /****** Show visitor votes average, READ ONLY ******/
322
+ add_shortcode ('yasr_visitor_votes_readonly', 'yasr_visitor_votes_readonly_callback');
323
 
324
+ function yasr_visitor_votes_readonly_callback ($atts) {
 
 
 
325
 
326
+ $shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
327
 
328
+ extract( shortcode_atts (
329
+ array(
330
+ 'size' => 'small',
331
+ 'postid' => FALSE
332
+ ), $atts )
333
+ );
334
 
335
+ //If it's not specified use get_the_id
336
+ if (!$postid) {
337
 
338
+ $post_id = get_the_ID();
339
 
340
  }
341
 
342
+ else {
343
 
344
+ $post_id = $postid;
 
345
 
346
+ }
347
 
348
+ $votes=yasr_get_visitor_votes($post_id);
349
 
350
+ $medium_rating=0; //Avoid undefined variable
351
 
352
+ if (!$votes) {
353
+ $votes=0; //Avoid undefined variable if there is not overall rating
354
+ $votes_number=0; //Avoid undefined variable
355
+ }
356
 
357
+ else {
358
+ foreach ($votes as $user_votes) {
359
+ $votes_number = $user_votes->number_of_votes;
360
+ if ($votes_number != 0 ) {
361
+ $medium_rating = ($user_votes->sum_votes/$votes_number);
362
+ }
363
+ else {
364
+ $medium_rating = 0;
365
+ }
366
+ }
367
+ }
368
 
369
+ $medium_rating=round($medium_rating, 1);
370
 
371
+ $stars_attribute = yasr_stars_size($size);
372
 
373
+ $shortcode_html = "<div id=\"yasr_visitor_votes_readonly_$post_id\" class=\"yasr-visitor-votes_readonly\">";
374
+ $span_after_rate_it = "";
 
 
 
 
375
 
376
+ $shortcode_html .= "<div class=\"$stars_attribute[class]\" id=\"yasr_rateit_visitor_votes_readonly_$post_id\" data-rateit-starwidth=\"$stars_attribute[px_size]\" data-rateit-starheight=\"$stars_attribute[px_size]\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>";
 
377
 
378
+ $shortcode_html .= "</div>";
379
 
 
380
 
381
+ //IF show visitor votes in loop is disabled use is_singular && is_main query
382
+ if ( YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'disabled' ) {
383
 
384
+ if( is_singular() && is_main_query() ) {
385
 
386
+ return $shortcode_html;
387
 
388
+ }
389
 
390
+ } // End if YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'disabled') {
391
 
392
+ //If overall rating in loop is enabled don't use is_singular && is main_query
393
+ elseif ( YASR_SHOW_VISITOR_VOTES_IN_LOOP === 'enabled' ) {
394
+
395
+ return $shortcode_html;
396
 
 
 
 
 
 
 
 
 
397
  }
 
 
398
 
399
+ // } //End (!is_feed)
400
 
401
+ } //End function shortcode_visitor_votes_only_stars_callback
402
 
 
 
403
 
404
+ /****** Add shortcode for multiple set ******/
405
 
406
+ add_shortcode ('yasr_multiset', 'shortcode_multi_set_callback');
407
 
408
+ function shortcode_multi_set_callback( $atts ) {
409
 
410
+ global $wpdb;
 
411
 
412
+ // Attributes
413
+ extract( shortcode_atts(
414
+ array(
415
+ 'setid' => '0',
416
+ 'postid' => FALSE
417
+ ), $atts )
418
+ );
419
 
420
+ //If it's not specified use get_the_id
421
+ if (!$postid) {
422
 
423
+ $post_id = get_the_ID();
424
 
425
+ }
426
 
427
+ else {
 
428
 
429
+ $post_id = $postid;
430
 
431
  }
432
 
433
+ $shortcode_html = ""; //Avoid undefined variable if used a missing setid
434
 
435
+ $set_name_content=yasr_get_multi_set_values_and_field ($post_id, $setid);
436
 
437
+ if ($set_name_content) {
438
+ $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
439
+ foreach ($set_name_content as $set_content) {
440
+ $shortcode_html .= "<tr> <td><span class=\"yasr-multi-set-name-field\">$set_content->name </span></td>
441
+ <td><div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
442
+ </tr>";
443
+ }
444
+ $shortcode_html.="</table>";
445
+ }
446
 
447
+ else {
448
+ $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
449
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
450
+ WHERE parent_set_id=%f
451
+ ORDER BY field_id ASC", $setid));
452
 
453
+ $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
454
+
455
+ foreach ($set_name as $set_content) {
456
+ $shortcode_html .= "<tr> <td><span class=\"yasr-multi-set-name-field\">$set_content->name </span></td>
457
+ <td><div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"0\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
458
+ </tr>";
459
+ }
460
+ $shortcode_html.="</table>";
461
 
462
+ }
463
 
464
+ return $shortcode_html;
 
 
 
 
 
 
 
 
465
 
466
+ } //End function
 
467
 
 
468
 
469
+ /****** Add shortcode for multiset writable by users ******/
470
 
471
+ add_shortcode ('yasr_visitor_multiset', 'yasr_visitor_multiset_callback');
472
 
473
+ function yasr_visitor_multiset_callback ( $atts ) {
474
 
475
+ $ajax_nonce_visitor_multiset = wp_create_nonce( "yasr_nonce_insert_visitor_rating_multiset" );
476
+
477
+ global $wpdb;
478
+
479
+ // Attributes
480
+ extract( shortcode_atts(
481
+ array(
482
+ 'setid' => '0',
483
+ 'postid' => FALSE
484
+ ), $atts )
485
+ );
486
 
487
+ //If it's not specified use get_the_id
488
+ if (!$postid) {
489
 
490
+ $post_id = get_the_ID();
491
 
 
 
 
 
 
 
492
  }
 
 
493
 
494
+ else {
 
 
 
 
495
 
496
+ $post_id = $postid;
497
 
 
 
 
 
498
  }
 
 
 
499
 
500
+ $cookiename = 'yasr_multi_visitor_cookie_' . $post_id . '_' . $setid;
 
501
 
502
+ $image = YASR_IMG_DIR . "/loader.gif";
503
 
504
+ $loader_html = "<span class=\"yasr-loader-multiset-visitor\" id=\"yasr-loader-multiset-visitor-$post_id-$setid\" >&nbsp; " . __("Loading, please wait",'yet-another-stars-rating') . ' <img src=' . "$image" .' title="yasr-loader" alt="yasr-loader"></span>';
505
 
506
+ $button_html = "<input type=\"submit\" name=\"submit\" id=\"yasr-send-visitor-multiset-$post_id-$setid\" class=\"button button-primary\" value=\"" . __('Submit!', 'yet-another-stars-rating') . " \" />";
507
 
508
+ if (isset($_COOKIE[$cookiename])) {
509
 
510
+ $button = "";
511
+ $star_readonly = 'true';
512
+ $span_message_content = __('Thank you for voting! ', 'yet-another-stars-rating');
513
 
514
+ }
 
 
 
 
 
 
 
 
515
 
516
+ else {
 
517
 
518
+ //If user is not logged in
519
+ if (!is_user_logged_in()) {
520
 
521
+ if (YASR_ALLOWED_USER === 'allow_anonymous') {
522
 
523
+ $button = $button_html;
524
+ $star_readonly = 'false';
525
+ $span_message_content = "";
526
 
527
+ }
528
 
529
+ elseif (YASR_ALLOWED_USER === 'logged_only') {
530
 
531
+ $button = $button_html;
532
+ $star_readonly = 'true';
533
+ $span_message_content = __("You must sign in to vote", 'yet-another-stars-rating');;
534
 
535
+ }
536
 
 
537
 
538
+ } //End if user logged in
539
 
540
+ //Is user is logged in
541
+ else {
542
 
543
+ $button = $button_html;
544
+ $star_readonly = 'false';
545
+ $span_message_content = "";
546
+
547
+ }
548
 
549
  }
550
 
551
+ $set_name_content = yasr_get_multi_set_visitor ($post_id, $setid);
552
 
553
+ if ($set_name_content) {
 
554
 
555
+ $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
556
 
557
+ foreach ($set_name_content as $set_content) {
 
 
558
 
559
+ if($set_content->number_of_votes > 0) {
560
 
561
+ $average_rating = $set_content->sum_votes / $set_content->number_of_votes;
562
 
563
+ $average_rating = round($average_rating, 1);
 
 
564
 
565
+ }
566
 
567
+ else {
568
 
569
+ $average_rating = 0;
570
 
571
+ }
 
572
 
573
+ $shortcode_html .= "<tr>
574
+ <td>
575
+ <span class=\"yasr-multi-set-name-field\">$set_content->name </span>
576
+ </td>
577
+ <td>
578
+ <div class=\"rateit yasr-visitor-multi-$post_id-$setid\" id=\"$set_content->id \" data-rateit-value=\"$average_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"$star_readonly\"></div>
579
+ <span class=\"yasr-visitor-multiset-vote-count\">$set_content->number_of_votes</span>
580
+ </td>
581
+ </tr>";
582
  }
583
 
584
+ $shortcode_html.="<tr>
585
+ <td colspan=\"2\">
586
+ $button
587
+ $loader_html
588
+ <span class=\"yasr-visitor-multiset-message\">$span_message_content</span>
589
+ </td>
590
+ </tr>
591
+ </table>";
592
+ }
593
 
594
+ else {
595
 
596
+ $set_name=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
597
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
598
+ WHERE parent_set_id=%d
599
+ ORDER BY field_id ASC", $setid));
600
 
 
601
 
602
+ $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
603
 
604
+ foreach ($set_name as $set_content) {
605
 
606
+ $shortcode_html .= "<tr>
607
+ <td>
608
+ <span class=\"yasr-multi-set-name-field\">$set_content->name </span>
609
+ </td>
610
+ <td>
611
+ <div class=\"rateit yasr-visitor-multi-$post_id-$setid\" id=\"$set_content->id\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\"></div>
612
+ <span class=\"yasr-visitor-multiset-vote-count\"> 0 </span>
613
+ </td>
614
+ </tr>";
615
 
 
616
 
 
617
 
618
+ //First time, initialize all fields to 0
619
 
620
+ //Find the highest_id (it's not auto increment on db due to gd star compatibility)
621
+ $highest_id=$wpdb->get_var("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
622
 
623
+ //highest id is 0 if data is empty
624
+ if (!$highest_id) {
625
+ $new_id=0;
626
+ }
627
 
628
+ $new_id=$highest_id + 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
 
630
+ $wpdb->replace(
631
+ YASR_MULTI_SET_VALUES_TABLE,
632
+ array (
633
+ 'id'=>$new_id,
634
+ 'post_id'=>$post_id,
635
+ 'field_id'=>$set_content->id,
636
+ 'set_type'=>$setid,
637
+ 'number_of_votes' => 0,
638
+ 'sum_votes' => 0
639
+ ),
640
+ array ("%d", "%d", "%d", "%d", "%d", "%d")
641
+ );
642
 
 
 
 
 
643
 
644
+ } //end foreach ($set_name as $set_content)
645
 
646
+ $shortcode_html.="<tr>
647
+ <td colspan=\"2\">
648
+ $button
649
+ $loader_html
650
+ <span class=\"yasr-visitor-multiset-message\">$span_message_content</span>
651
+ </td>
652
+ </tr>
653
+ </table>";
654
 
655
+ $shortcode_html.="</table>";
656
 
657
+ }
 
 
 
 
 
 
 
 
658
 
659
 
660
+ $var_post_id = json_encode($post_id);
661
+ $var_set_id = json_encode($setid);
662
+ $var_ajax_url = json_encode(admin_url('admin-ajax.php'));
663
+ $var_ajax_nonce_visitor_multiset = json_encode($ajax_nonce_visitor_multiset);
664
 
665
+ $javascript = "
666
 
667
+ <script type=\"text/javascript\">
 
 
 
 
 
 
668
 
669
+ document.addEventListener('DOMContentLoaded', function(event) {
 
 
 
670
 
671
+ var postId = $var_post_id;
672
+ var setType = $setid;
673
+ var ajaxurl = $var_ajax_url;
674
+ var nonce = $var_ajax_nonce_visitor_multiset;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
675
 
676
+ yasrVisitorsMultiSet (postId, setType, ajaxurl, nonce);
677
 
678
+ });
679
 
680
+ </script>
681
+ ";
 
 
 
 
682
 
683
+ return $shortcode_html . $javascript;
684
 
 
685
 
686
+ return $shortcode_html;
687
+
688
+ }
689
 
690
 
691
 
693
 
694
  add_shortcode ('yasr_top_ten_highest_rated', 'yasr_top_ten_highest_rated_callback');
695
 
696
+ function yasr_top_ten_highest_rated_callback () {
697
 
698
+ global $wpdb;
699
 
700
+ $query_result = $wpdb->get_results("SELECT v.overall_rating, v.post_id
701
+ FROM " . YASR_VOTES_TABLE . " AS v, $wpdb->posts AS p
702
+ WHERE v.post_id = p.ID
703
+ AND p.post_status = 'publish'
704
+ AND v.overall_rating > 0
705
+ ORDER BY v.overall_rating DESC, v.id ASC LIMIT 10");
706
 
707
+ if ($query_result) {
708
 
709
+ $shortcode_html = "<table class=\"yasr-table-chart\">";
710
 
711
+ foreach ($query_result as $result) {
712
 
713
+ $post_title = get_the_title($result->post_id);
714
 
715
+ $link = get_permalink($result->post_id); //Get permalink from post it
716
 
717
+ $shortcode_html .= "<tr>
718
+ <td width=\"60%\" class=\"yasr-top-10-overall-left\"><a href=\"$link\">$post_title</a></td>
719
+ <td width=\"40%\" class=\"yasr-top-10-overall-right\">
720
+ <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>
721
+ <span class=\"yasr-highest-rated-text\">" . __("Rating", 'yet-another-stars-rating') . " $result->overall_rating </span>
722
+ </td>
723
+ </tr>";
724
 
725
 
726
+ } //End foreach
727
 
728
+ $shortcode_html .= "</table>";
729
 
730
+ return $shortcode_html;
731
 
732
+ } //end if $query_result
733
 
734
+ else {
735
+ _e("You don't have any votes stored", 'yet-another-stars-rating');
736
+ }
737
 
738
+ } //End function
739
 
740
 
741
  /****** Add top 10 most rated / highest rated post *****/
742
 
743
  add_shortcode ('yasr_most_or_highest_rated_posts', 'yasr_most_or_highest_rated_posts_callback');
744
 
745
+ function yasr_most_or_highest_rated_posts_callback () {
746
 
747
 
748
+ $shortcode_html = "";
749
 
750
+ global $wpdb;
751
 
752
+ $query_result_most_rated = $wpdb->get_results("SELECT post_id, number_of_votes, sum_votes
753
+ FROM " . YASR_VOTES_TABLE . ", $wpdb->posts AS p
754
+ WHERE post_id = p.ID
755
+ AND number_of_votes >= 1
756
+ AND p.post_status = 'publish'
757
+ ORDER BY number_of_votes DESC, sum_votes DESC LIMIT 10");
758
 
759
+ $query_result_highest = $wpdb->get_results("SELECT (sum_votes / number_of_votes) as result, post_id, number_of_votes
760
+ FROM " . YASR_VOTES_TABLE . ", $wpdb->posts AS p
761
+ WHERE post_id = p.ID
762
+ AND number_of_votes >= 2
763
+ AND p.post_status = 'publish'
764
+ ORDER BY result DESC, number_of_votes DESC LIMIT 10
765
+ ");
766
 
767
+ if ($query_result_most_rated) {
768
 
769
+ $shortcode_html .= "<table class=\"yasr-table-chart\" id=\"yasr-most-rated-posts\">
770
+ <tr class=\"yasr-visitor-votes-title\">
771
+ <th>" . __("Post / Page" , 'yet-another-stars-rating') ." </th>
772
+ <th>". __("Order By" , 'yet-another-stars-rating') .":&nbsp;&nbsp;<span id=\"yasr_multi_chart_link_to_nothing\">" . __("Most Rated" , 'yet-another-stars-rating') ."</span> | <a href=\"#\" id=\"yasr_multi_chart_highest\">" . __("Highest Rated" , 'yet-another-stars-rating') ."</a></th>
773
+ </tr>"
774
+ ;
775
 
776
+ foreach ($query_result_most_rated as $result) {
777
 
778
+ $rating = $result->sum_votes / $result->number_of_votes;
779
 
780
+ $rating = round($rating, 1);
781
 
782
+ $post_title = get_the_title($result->post_id);
783
 
784
+ $link = get_permalink($result->post_id); //Get permalink from post it
785
 
786
+ $shortcode_html .= "<tr>
787
+ <td width=\"60%\" class=\"yasr-top-10-most-highest-left\"><a href=\"$link\">$post_title</a></td>
788
+ <td width=\"40%\" class=\"yasr-top-10-most-highest-right\"><div id=\"yasr_visitor_votes\">
789
+ <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>
790
+ <br /> [" . __("Total:" , 'yet-another-stars-rating') . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , 'yet-another-stars-rating') . " $rating]
791
+ </td>
792
+ </tr>";
793
 
794
 
795
+ } //End foreach
796
 
797
+ $shortcode_html .= "</table>" ;
798
 
799
+ } //End if $query_result_most_rated)
800
 
801
+ else {
802
+ $shortcode_html = __("You've not enough data",'yet-another-stars-rating') . "<br />";
803
+ }
804
 
 
 
805
 
806
+ if ($query_result_highest) {
 
 
 
 
807
 
808
+ $shortcode_html .= "<table class=\"yasr-table-chart\" id=\"yasr-highest-rated-posts\">
809
+ <tr class=\"yasr-visitor-votes-title\">
810
+ <th>" . __("Post / Page" , 'yet-another-stars-rating') ." </th>
811
+ <th>". __("Order By" , 'yet-another-stars-rating') .":&nbsp;&nbsp; <a href=\"#\" id=\"yasr_multi_chart_most\">". __("Most Rated" , 'yet-another-stars-rating') ."</a> | <span id=\"yasr_multi_chart_link_to_nothing\">". __("Highest Rated" , 'yet-another-stars-rating') ."</span></th>
812
+ </tr>";
813
 
814
+ foreach ($query_result_highest as $result) {
815
 
816
+ $rating = round($result->result, 1);
817
 
818
+ $post_title = get_the_title($result->post_id);
819
 
820
+ $link = get_permalink($result->post_id); //Get permalink from post it
 
 
 
 
 
821
 
822
+ $shortcode_html .= "<tr>
823
+ <td width=\"60%\" class=\"yasr-top-10-most-highest-left\"><a href=\"$link\">$post_title</a></td>
824
+ <td width=\"40%\" class=\"yasr-top-10-most-highest-right\"><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>
825
+ <br /> [" . __("Total:" , 'yet-another-stars-rating') . "$result->number_of_votes &nbsp;&nbsp;&nbsp;" . __("Average" , 'yet-another-stars-rating') . " $rating]
826
+ </td>
827
+ </tr>";
828
 
 
829
 
830
+ } //End foreach
831
 
832
+ $shortcode_html .= "</table>";
833
 
834
+ } //end if $query_result
 
 
835
 
836
+ else {
837
+ $shortcode_html = __("You've not enought data",'yet-another-stars-rating') . "<br />";
838
+ }
839
 
840
+ ?>
841
 
842
+ <script type="text/javascript">
843
 
844
+ document.addEventListener('DOMContentLoaded', function(event) {
845
 
846
+ yasrMostOrHighestRatedChart ();
847
 
848
+ });
849
 
 
850
 
851
+ </script>
852
 
853
+ <?php
854
+
855
+ return $shortcode_html;
856
 
857
 
858
+ } //End function
859
 
860
 
861
  /****** Add top 5 most active reviewer ******/
862
 
863
  add_shortcode ('yasr_top_5_reviewers', 'yasr_top_5_reviewers_callback');
864
 
865
+ function yasr_top_5_reviewers_callback () {
866
 
867
+ global $wpdb;
868
 
869
+ $query_result = $wpdb->get_results("SELECT COUNT( post_author ) as total_count, post_author as reviewer
870
+ FROM $wpdb->posts AS p, " . YASR_VOTES_TABLE . "
871
+ WHERE post_id = p.ID
872
+ AND p.post_status = 'publish'
873
+ GROUP BY post_author
874
+ ORDER BY (total_count) DESC
875
+ LIMIT 5");
876
 
877
 
878
+ if ($query_result) {
879
 
880
+ $shortcode_html = "
881
+ <table class=\"yasr-table-chart\">
882
+ <tr>
883
+ <th>Author</th>
884
+ <th>Reviews</th>
885
+ </tr>
886
+ ";
887
 
888
+ foreach ($query_result as $result) {
889
 
890
+ $user_data = get_userdata($result->reviewer);
891
 
892
+ if ($user_data) {
893
 
894
+ $user_profile = get_author_posts_url($result->reviewer);
895
 
896
+ }
897
 
898
+ else {
899
 
900
+ $user_profile = '#';
901
+ $user_data = new stdClass;
902
+ $user_data->user_login = 'Anonymous';
 
 
903
 
904
+ }
905
 
 
 
 
 
 
 
906
 
907
+ $shortcode_html .= "<tr>
908
+ <td><a href=\"$user_profile\">$user_data->user_login</a></td>
909
+ <td>$result->total_count</td>
910
+ </tr>";
911
 
912
+ }
913
 
914
+ $shortcode_html .= "</table>";
915
 
916
+ return $shortcode_html;
917
 
918
+ }
919
 
920
+ else {
921
 
922
+ _e("Problem while retrieving the top 5 most active reviewers. Did you publish any review?");
923
+
924
+ }
925
 
926
+
927
+ } //End top 5 reviewers function
928
 
929
 
930
 
934
 
935
  add_shortcode ('yasr_top_ten_active_users', 'yasr_top_ten_active_users_callback');
936
 
937
+ function yasr_top_ten_active_users_callback () {
938
 
939
+ global $wpdb;
940
 
941
+ $query_result = $wpdb->get_results("SELECT COUNT( user_id ) as total_count, user_id as user
942
+ FROM " . YASR_LOG_TABLE . ", $wpdb->posts AS p
943
+ WHERE post_id = p.ID
944
+ AND p.post_status = 'publish'
945
+ GROUP BY user_id
946
+ ORDER BY ( total_count ) DESC
947
+ LIMIT 10");
948
 
949
+ if ($query_result) {
950
 
951
+ $shortcode_html = "
952
+ <table class=\"yasr-table-chart\">
953
+ <tr>
954
+ <th>UserName</th>
955
+ <th>Number of votes</th>
956
+ </tr>
957
+ ";
958
 
959
+ foreach ($query_result as $result) {
960
 
961
+ $user_data = get_userdata($result->user);
962
 
963
+ if ($user_data) {
964
 
965
+ $user_profile = get_author_posts_url($result->user);
966
 
967
+ }
968
+
969
+ else {
970
+ $user_profile = '#';
971
+ $user_data = new stdClass;
972
+ $user_data->user_login = 'Anonymous';
973
+ }
974
+
975
+ $shortcode_html .= "<tr>
976
+ <td><a href=\"$user_profile\">$user_data->user_login</a></td>
977
+ <td>$result->total_count</td>
978
+ </tr>";
979
 
 
 
 
 
980
  }
981
 
982
+
983
+ $shortcode_html .= "</table>";
984
+
985
+ return $shortcode_html;
986
 
987
  }
988
 
989
+ else {
990
+ _e("Problem while retrieving the top 10 active users chart. Are you sure you have votes to show?");
991
+ }
992
 
 
993
 
994
+ } //End function
995
 
996
+ add_shortcode ('yasr_highest_rated_visitor_multi_set', 'yasr_highest_rated_visitor_multi_set_callback');
997
+
998
+ function yasr_highest_rated_visitor_multi_set_callback () {
999
+
1000
+ global $wpdb;
1001
+
1002
+ $shortcode_html = '';
1003
+
1004
+ $set_fields=$wpdb->get_results("SELECT v.post_id, v.sum_votes / v.number_of_votes AS average, v.number_of_votes, f.field_name
1005
+ FROM " . YASR_MULTI_SET_VALUES_TABLE . " AS v, " . YASR_MULTI_SET_FIELDS_TABLE . " AS f
1006
+ WHERE v.set_type = f.parent_set_id
1007
+ AND v.field_id = f.field_id
1008
+ AND v.number_of_votes > 0
1009
+ AND v.sum_votes > 0
1010
+ ORDER BY f.parent_set_id ASC, f.field_id ASC, v.post_id ASC"
1011
+ );
1012
+
1013
+ foreach ($set_fields as $results) {
1014
+
1015
+ if (!isset($field_name) || $field_name != $results->field_name ) {
1016
+
1017
+ $shortcode_html .= "<h3> $results->field_name </h3>";
1018
+
1019
+ }
1020
+
1021
+ $link = get_permalink($results->post_id);
1022
+ $title = get_the_title($results->post_id);
1023
+
1024
+ $average = round($results->average, 1);
1025
+
1026
+ $shortcode_html .= "<a href=\"$link\">$title</a> ";
1027
+ $shortcode_html .= $average . ", " . sprintf(__('based on %d votes', 'yet-another-stars-rating'), $results->number_of_votes);
1028
+ $shortcode_html .= "<br />";
1029
+
1030
+ $field_name = $results->field_name;
1031
 
 
 
1032
  }
1033
 
1034
 
1035
+
1036
+ return $shortcode_html;
1037
+
1038
+ }
1039
 
1040
  ?>
readme.txt CHANGED
@@ -2,15 +2,15 @@
2
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
3
  Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post rating, posts, rate, rating, rating platform, rating system, ratings, review, reviews, rich snippets, seo, star, star rating, stars, vote, Votes, voting, voting contest, schema, serp
4
  Requires at least: 3.5
5
- Contributors: Dudo
6
- Tested up to: 4.4.1
7
- Stable tag: 1.1.9
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
11
 
12
  == Description ==
13
- Yet Another Stars Rating (YASR) is a new system review based on jquery plugin RateIT.
14
  With YASR you can make your own review or let your visitors vote, and you can even create multiple sets (a set of stars for each aspect to
15
  rate). Review scores or visitor ratings will be indexed by search engines through snippets .
16
 
@@ -21,7 +21,7 @@ Once YASR is installed, when you create or update a page or a post, a box (metab
21
  be able to insert the overall rating. You can either place the overall rating automatically at the beginning or the end of a post (look in "Settings"
22
  -> "Yet Another Stars Rating: Settings"), or wherever you want in the page using the shortcode [yasr_overall_rating] (easily added through the visual editor).
23
 
24
- = Visitor Votes =
25
  You can give your users the ability to vote, pasting the shortcode [yasr_visitor_votes] where you want the stars to appear.
26
  Again, this can be placed automatically at the beginning or the end of each post; the option is in "Settings" -> "Yet Another Stars Rating: Settings".
27
  This may not works if you use a caching plugin.
@@ -76,7 +76,7 @@ It is the vote that allows your visitors to vote: just paste this shortcode **[y
76
 
77
 
78
  = What is "Multi Set"? =
79
- It is the feature that makes YASR awesome. Multisets give the opportunity to score different aspects for each review: for example, if you're reviewing a videogame, you can create the aspects "Graphics", "Gameplay", "Story", etc. and give a vote for each one. To create a set, just go in "Settings" -> "Yet Another Stars Rating: Settings" and click on the "Multi Sets" tab. To insert it into a post, just paste the shortcode that YASR will create for you.
80
 
81
  [Demo page for Multi Sets](https://yetanotherstarsrating.com/yasr-multi-sets/)
82
 
@@ -84,7 +84,7 @@ It is the feature that makes YASR awesome. Multisets give the opportunity to sco
84
  It is the 10 highest rated item chart by reviewer. In order to insert it into a post or page, just paste this shortcode **[yasr_top_ten_highest_rated]**
85
 
86
  = What is "Users' ranking" ? =
87
- This is 2 charts in 1. Infact, this chart shows both the most rated posts/pages or the highest rated posts/pages.
88
  For an item to appear in this chart, it has to be rated twice at least.
89
  Paste this shortcode to make it appear where you want **[yasr_most_or_highest_rated_posts]**
90
 
@@ -110,6 +110,13 @@ Of course not: you can easily add it on the visual editor just by clicking on th
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
 
113
  = 1.1.9 =
114
  * FIXED: yasr_visitor_votes doesn't get vote on mobile
115
 
@@ -120,7 +127,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
120
  * FIXED: filters on yasr_add_schema() functions
121
  * TWEAKED: disabled right click on rating
122
  * TWEAKED: install function is wrapped on register_activation_hook
123
-
124
 
125
  = 1.1.6 =
126
  * FIXED: Rich snippet non added in some cases
@@ -145,13 +152,13 @@ Of course not: you can easily add it on the visual editor just by clicking on th
145
 
146
  = 1.1.1 =
147
  * FIXED: Yasr Stylish compatibility
148
- * TWEAKED: changed extensions images
149
 
150
  = 1.1.0 =
151
  * Yasr is not anymore a freemium plugin: it works now with extensions that you can be installed through the settings panel
152
 
153
  = 1.0.7 =
154
- * FIXED: minor bugfix in settings page
155
 
156
  = 1.0.6 =
157
  * Added a new filter hook on microdata and jsonld info
@@ -220,8 +227,8 @@ Of course not: you can easily add it on the visual editor just by clicking on th
220
  = 0.9.2 =
221
  * FIXED: bugfix on yasr_visitor_multiset
222
  * FIXED: wrong review type showed in editing screen
223
- * FIXED: could vote > 5 in overall rating if use digits instead of stars
224
- * FIXED: double voting in visitor multi set if "submit" button is pressed more than once
225
  * FIXED: progressbar in tooltips (thanks to Harry Milatz )
226
  * FIXED: minor security fix
227
 
@@ -230,7 +237,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
230
 
231
  = 0.9.0 =
232
  * FIXED: Fixed bug in multisets (here https://wordpress.org/support/topic/half-stars-not-saving more info)
233
- * TWEAKED: Minor changes
234
 
235
  = 0.8.9 =
236
  * FIXED: Minor bugfixes for multisets and visitor multisets
@@ -252,7 +259,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
252
  * Fixed bug on new installation if multi set are used
253
 
254
  = 0.8.5 =
255
- * TWEAKED: code changes and bug fixes on Multi Set shortcodes
256
 
257
  = 0.8.4 =
258
  * NEW FEATURE: User can customize text after Visitor Votes.
@@ -269,7 +276,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
269
  * NEW FEATURE: added support for wp super cache
270
  * TWIKED: color settings for multi sets was moved from general settings to multi sets tab
271
  * TWIKED: log widget is now fully translatable
272
- * TWIKED: added brasilian language
273
  * TWIKED: minor fixes for translation
274
 
275
  = 0.8.1 =
@@ -356,7 +363,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
356
  = 0.6.1 =
357
  * Bugfix: fixed mysql error if inserted the overall rating vote if post wasn't saved yet
358
  * Fixed schema info when overall rating is used
359
- * Language fix on [yasr_most_or_highest_rated_posts]
360
 
361
  = 0.6.0 =
362
  * Bugfix: now it's not possible to vote 0
@@ -369,7 +376,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
369
 
370
  = 0.5.8 =
371
  * Changed description in yasr shortcode generator (transaltor please take a look to the .po file) and other languages fix.
372
- * Added the author info in the aggregate rating snippet
373
  * Minor bugfixes
374
 
375
  = 0.5.7 =
@@ -377,7 +384,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
377
 
378
  = 0.5.6 =
379
  * Code cleanup and speed improvement on the [yasr_most_or_highest_rated_posts] chart
380
- * Bug fixes in setting page
381
 
382
  = 0.5.5 =
383
  * All the javascript have been moved from inline to external. It can be minimized so it's faster. DELETE ALL YOUR CACHES
@@ -385,11 +392,11 @@ Of course not: you can easily add it on the visual editor just by clicking on th
385
 
386
  = 0.5.4 =
387
  * New feature: you can used numbers instead stars to insert the "overall rating" value. Just go in the setting and choose what you want to use
388
- * Fixed a division by 0 warning while using [yasr_most_or_highest_rated_posts] : this happened when there wan't enought data to shows
389
  * Many bux fix in [yasr_visitor_rating] : further this now it is faster
390
 
391
  = 0.5.3 =
392
- * Fixed a non closing div. This can cause problem when used in old template
393
 
394
  = 0.5.2 =
395
  * Bugfixes
@@ -423,7 +430,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
423
  * Popup shortcode creator use the built-in wordpress style, fresher and lighter
424
  * Fixed many bugs in shortcode [yasr_visitor_votes] : if you've had problem with a size that was not "large", try it now!
425
  * Swiched color for all stars set: yellow by default, red only when is active
426
- * Changed file name jquery.cookie.min.js in jquery-cookie.min.js, to avoid conflict with apache mod_security (thank's SubZeroD)
427
  * Many code changes
428
 
429
  = 0.4.5 =
@@ -455,7 +462,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
455
  = 0.3.9 =
456
  * Fixed page exclusion
457
 
458
- = 0.3.8 =
459
  * Added new chart: Top 10 most rated / highest rated posts from visitors (show up only posts rated at least twice)
460
  * New setting: it's possibile now to explude pages from auto insert
461
  * Css changes
@@ -487,7 +494,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
487
  * Under the hood changes
488
 
489
  = 0.3.3 =
490
- * Created a new shortcode that will allow to insert Top 10 highest rated product by author
491
  * When a post or page is permanently deleted, yasr will delete every votes for that post or page
492
  * Overall Rating is now avaible in home page and archive pages
493
  * Fixed "add element button" when only 1 multi set is used
@@ -508,7 +515,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
508
 
509
  = 0.2.10 =
510
  * Added loading image when ajax is called
511
- * Added "select button" when choosing a multi set
512
 
513
  = 0.2.9 =
514
  * Settings page has been rewritten: now it use multi tab navigation
@@ -518,12 +525,12 @@ Of course not: you can easily add it on the visual editor just by clicking on th
518
  * Minor change and code cleanup
519
 
520
  = 0.2.5 =
521
- * Bug fix on multi set
522
 
523
  = 0.2.4 =
524
- * Now user can choose what kind of snippet use, if AggregateRating or Review
525
 
526
- = 0.2.3 =
527
  * [yasr_visitor_votes] it's now disabled outside a post or a page
528
  * Security fixes on ajax functions
529
  * Various fixes on multi-set settings
@@ -534,7 +541,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
534
  * Many other minor bug fixes
535
 
536
  = 0.2.1 =
537
- * Fixed insert rating on multi set if only 1 is used
538
 
539
  = 0.2.0 =
540
  * Fixed Table installation
@@ -551,7 +558,7 @@ Of course not: you can easily add it on the visual editor just by clicking on th
551
 
552
  = 0.1.0 =
553
  * Added in admin dashboard votes log viewer
554
- * .Po file updated
555
  * Updated rateit to version 1.0.22
556
 
557
  = 0.0.4 =
@@ -560,11 +567,11 @@ Of course not: you can easily add it on the visual editor just by clicking on th
560
  * Code cleanup
561
 
562
  = 0.0.3 =
563
- * Fixed bug describe if
564
  * Code Cleanup
565
 
566
  = 0.0.2 =
567
- * Using input type radio when select a multi set instead select / option
568
  * Added css style for table showing multiset
569
  * Added yasr.css file
570
  * Some code cleanup
2
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXE284FYMNWDC
3
  Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post rating, posts, rate, rating, rating platform, rating system, ratings, review, reviews, rich snippets, seo, star, star rating, stars, vote, Votes, voting, voting contest, schema, serp
4
  Requires at least: 3.5
5
+ Contributors: Dudo
6
+ Tested up to: 4.4.2
7
+ Stable tag: 1.2.0
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
11
 
12
  == Description ==
13
+ Yet Another Stars Rating (YASR) is a new system review based on jquery plugin RateIT.
14
  With YASR you can make your own review or let your visitors vote, and you can even create multiple sets (a set of stars for each aspect to
15
  rate). Review scores or visitor ratings will be indexed by search engines through snippets .
16
 
21
  be able to insert the overall rating. You can either place the overall rating automatically at the beginning or the end of a post (look in "Settings"
22
  -> "Yet Another Stars Rating: Settings"), or wherever you want in the page using the shortcode [yasr_overall_rating] (easily added through the visual editor).
23
 
24
+ = Visitor Votes =
25
  You can give your users the ability to vote, pasting the shortcode [yasr_visitor_votes] where you want the stars to appear.
26
  Again, this can be placed automatically at the beginning or the end of each post; the option is in "Settings" -> "Yet Another Stars Rating: Settings".
27
  This may not works if you use a caching plugin.
76
 
77
 
78
  = What is "Multi Set"? =
79
+ It is the feature that makes YASR awesome. Multisets give the opportunity to score different aspects for each review: for example, if you're reviewing a videogame, you can create the aspects "Graphics", "Gameplay", "Story", etc. and give a vote for each one. To create a set, just go in "Settings" -> "Yet Another Stars Rating: Settings" and click on the "Multi Sets" tab. To insert it into a post, just paste the shortcode that YASR will create for you.
80
 
81
  [Demo page for Multi Sets](https://yetanotherstarsrating.com/yasr-multi-sets/)
82
 
84
  It is the 10 highest rated item chart by reviewer. In order to insert it into a post or page, just paste this shortcode **[yasr_top_ten_highest_rated]**
85
 
86
  = What is "Users' ranking" ? =
87
+ This is 2 charts in 1. Infact, this chart shows both the most rated posts/pages or the highest rated posts/pages.
88
  For an item to appear in this chart, it has to be rated twice at least.
89
  Paste this shortcode to make it appear where you want **[yasr_most_or_highest_rated_posts]**
90
 
110
 
111
  == Changelog ==
112
 
113
+ = 1.2.0 =
114
+ * FIXED: if more then one visitor multiset for page were used only the last use to work
115
+ * TWEAKED: transient are used to cache ratings: this means that Yasr is faster then ever
116
+ * TWEAKED: shortcode creator is now above of tinymce. It now uses thickbox
117
+ * TWEAKED: added filter 'yasr_filter_ip' to filter stored ip address
118
+ * TWEAKED: code cleanup
119
+
120
  = 1.1.9 =
121
  * FIXED: yasr_visitor_votes doesn't get vote on mobile
122
 
127
  * FIXED: filters on yasr_add_schema() functions
128
  * TWEAKED: disabled right click on rating
129
  * TWEAKED: install function is wrapped on register_activation_hook
130
+
131
 
132
  = 1.1.6 =
133
  * FIXED: Rich snippet non added in some cases
152
 
153
  = 1.1.1 =
154
  * FIXED: Yasr Stylish compatibility
155
+ * TWEAKED: changed extensions images
156
 
157
  = 1.1.0 =
158
  * Yasr is not anymore a freemium plugin: it works now with extensions that you can be installed through the settings panel
159
 
160
  = 1.0.7 =
161
+ * FIXED: minor bugfix in settings page
162
 
163
  = 1.0.6 =
164
  * Added a new filter hook on microdata and jsonld info
227
  = 0.9.2 =
228
  * FIXED: bugfix on yasr_visitor_multiset
229
  * FIXED: wrong review type showed in editing screen
230
+ * FIXED: could vote > 5 in overall rating if use digits instead of stars
231
+ * FIXED: double voting in visitor multi set if "submit" button is pressed more than once
232
  * FIXED: progressbar in tooltips (thanks to Harry Milatz )
233
  * FIXED: minor security fix
234
 
237
 
238
  = 0.9.0 =
239
  * FIXED: Fixed bug in multisets (here https://wordpress.org/support/topic/half-stars-not-saving more info)
240
+ * TWEAKED: Minor changes
241
 
242
  = 0.8.9 =
243
  * FIXED: Minor bugfixes for multisets and visitor multisets
259
  * Fixed bug on new installation if multi set are used
260
 
261
  = 0.8.5 =
262
+ * TWEAKED: code changes and bug fixes on Multi Set shortcodes
263
 
264
  = 0.8.4 =
265
  * NEW FEATURE: User can customize text after Visitor Votes.
276
  * NEW FEATURE: added support for wp super cache
277
  * TWIKED: color settings for multi sets was moved from general settings to multi sets tab
278
  * TWIKED: log widget is now fully translatable
279
+ * TWIKED: added brasilian language
280
  * TWIKED: minor fixes for translation
281
 
282
  = 0.8.1 =
363
  = 0.6.1 =
364
  * Bugfix: fixed mysql error if inserted the overall rating vote if post wasn't saved yet
365
  * Fixed schema info when overall rating is used
366
+ * Language fix on [yasr_most_or_highest_rated_posts]
367
 
368
  = 0.6.0 =
369
  * Bugfix: now it's not possible to vote 0
376
 
377
  = 0.5.8 =
378
  * Changed description in yasr shortcode generator (transaltor please take a look to the .po file) and other languages fix.
379
+ * Added the author info in the aggregate rating snippet
380
  * Minor bugfixes
381
 
382
  = 0.5.7 =
384
 
385
  = 0.5.6 =
386
  * Code cleanup and speed improvement on the [yasr_most_or_highest_rated_posts] chart
387
+ * Bug fixes in setting page
388
 
389
  = 0.5.5 =
390
  * All the javascript have been moved from inline to external. It can be minimized so it's faster. DELETE ALL YOUR CACHES
392
 
393
  = 0.5.4 =
394
  * New feature: you can used numbers instead stars to insert the "overall rating" value. Just go in the setting and choose what you want to use
395
+ * Fixed a division by 0 warning while using [yasr_most_or_highest_rated_posts] : this happened when there wan't enought data to shows
396
  * Many bux fix in [yasr_visitor_rating] : further this now it is faster
397
 
398
  = 0.5.3 =
399
+ * Fixed a non closing div. This can cause problem when used in old template
400
 
401
  = 0.5.2 =
402
  * Bugfixes
430
  * Popup shortcode creator use the built-in wordpress style, fresher and lighter
431
  * Fixed many bugs in shortcode [yasr_visitor_votes] : if you've had problem with a size that was not "large", try it now!
432
  * Swiched color for all stars set: yellow by default, red only when is active
433
+ * Changed file name jquery.cookie.min.js in jquery-cookie.min.js, to avoid conflict with apache mod_security (thank's SubZeroD)
434
  * Many code changes
435
 
436
  = 0.4.5 =
462
  = 0.3.9 =
463
  * Fixed page exclusion
464
 
465
+ = 0.3.8 =
466
  * Added new chart: Top 10 most rated / highest rated posts from visitors (show up only posts rated at least twice)
467
  * New setting: it's possibile now to explude pages from auto insert
468
  * Css changes
494
  * Under the hood changes
495
 
496
  = 0.3.3 =
497
+ * Created a new shortcode that will allow to insert Top 10 highest rated product by author
498
  * When a post or page is permanently deleted, yasr will delete every votes for that post or page
499
  * Overall Rating is now avaible in home page and archive pages
500
  * Fixed "add element button" when only 1 multi set is used
515
 
516
  = 0.2.10 =
517
  * Added loading image when ajax is called
518
+ * Added "select button" when choosing a multi set
519
 
520
  = 0.2.9 =
521
  * Settings page has been rewritten: now it use multi tab navigation
525
  * Minor change and code cleanup
526
 
527
  = 0.2.5 =
528
+ * Bug fix on multi set
529
 
530
  = 0.2.4 =
531
+ * Now user can choose what kind of snippet use, if AggregateRating or Review
532
 
533
+ = 0.2.3 =
534
  * [yasr_visitor_votes] it's now disabled outside a post or a page
535
  * Security fixes on ajax functions
536
  * Various fixes on multi-set settings
541
  * Many other minor bug fixes
542
 
543
  = 0.2.1 =
544
+ * Fixed insert rating on multi set if only 1 is used
545
 
546
  = 0.2.0 =
547
  * Fixed Table installation
558
 
559
  = 0.1.0 =
560
  * Added in admin dashboard votes log viewer
561
+ * .Po file updated
562
  * Updated rateit to version 1.0.22
563
 
564
  = 0.0.4 =
567
  * Code cleanup
568
 
569
  = 0.0.3 =
570
+ * Fixed bug describe if
571
  * Code Cleanup
572
 
573
  = 0.0.2 =
574
+ * Using input type radio when select a multi set instead select / option
575
  * Added css style for table showing multiset
576
  * Added yasr.css file
577
  * Some code cleanup
yet-another-stars-rating.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Yet Another Stars Rating turn your WordPress into a complete review website.
6
- * Version: 1.1.9
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
@@ -31,8 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
31
 
32
  if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
 
34
-
35
- define('YASR_VERSION_NUM', '1.1.9');
36
 
37
  //Plugin relative path
38
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
@@ -99,15 +99,17 @@ define ("YASR_ALLOWED_USER", $stored_options['allowed_user']);
99
  define ("YASR_SNIPPET", $stored_options['snippet']);
100
  define ("YASR_ITEMTYPE", $stored_options['snippet_itemtype']);
101
  define ("YASR_SCHEMA_FORMAT", $stored_options['snippet_format']);
102
- define ("YASR_METABOX_OVERALL_RATING", $stored_options['metabox_overall_rating']);
103
 
104
 
105
  // this is the URL our updater / license checker pings. This should be the URL of the site with EDD installed
106
- define( 'YASR_EDD_SL_STORE_URL', 'https://yetanotherstarsrating.com' );
 
107
 
108
- //Get stored style options
109
  $style_options = get_option ('yasr_style_options');
110
 
 
111
  if ($style_options) {
112
 
113
  if(isset($style_options['textarea'])) {
@@ -131,7 +133,7 @@ if ($style_options) {
131
  else {
132
 
133
  define ("YASR_SCHEME_COLOR", NULL);
134
-
135
  }
136
 
137
 
@@ -146,46 +148,13 @@ else {
146
  }
147
 
148
 
149
-
150
- //Needed for yasr stylish extension
151
-
152
- if (function_exists('yasr_stylish')) {
153
-
154
- if(isset($style_options['stars_set'])) {
155
-
156
- define("YASR_ST_STARS_DIR", $style_options['stars_set']);
157
-
158
- }
159
-
160
- else {
161
-
162
- define("YASR_ST_STARS_DIR", NULL);
163
-
164
- }
165
-
166
-
167
- //Needed for yasr stylish extension
168
- if(isset($style_options['custom_stars_set'])) {
169
-
170
- define("YASR_ST_CUSTOM_STARS_DIR", $style_options['custom_stars_set']);
171
-
172
- }
173
-
174
- else {
175
-
176
- define("YASR_ST_CUSTOM_STARS_DIR", NULL);
177
-
178
- }
179
-
180
- }
181
-
182
  //do_action('yasr_define_style_options', $style_options);
183
 
184
  /****** End Getting options ******/
185
 
186
 
187
 
188
- // Include function file
189
  require (YASR_ABSOLUTE_PATH . '/lib/yasr-functions.php');
190
 
191
  require (YASR_ABSOLUTE_PATH . '/lib/yasr-admin-actions.php');
@@ -219,8 +188,6 @@ $version_installed = get_option('yasr-version');
219
 
220
  global $version_installed;
221
 
222
- //TODO use transient for version installed
223
-
224
 
225
  //Run this only on plugin activation (doesn't work on update)
226
  register_activation_hook( __FILE__, 'yasr_on_activation' );
@@ -244,10 +211,10 @@ add_action('plugins_loaded', 'yasr_update_version' );
244
 
245
  function yasr_update_version() {
246
 
247
- global $version_installed;
248
-
249
  global $wpdb;
250
 
 
 
251
  //Remove july 2016
252
  if ($version_installed && $version_installed < '1.0.5') {
253
 
@@ -272,7 +239,7 @@ function yasr_update_version() {
272
  //remove end may 2016
273
  if ($version_installed && $version_installed < '1.0.2') {
274
 
275
- $wpdb->query("ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " CHANGE field_name field_name VARCHAR( 40 )
276
  CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;");
277
 
278
  }
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Yet Another Stars Rating turn your WordPress into a complete review website.
6
+ * Version: 1.2.0
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
31
 
32
  if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
33
 
34
+
35
+ define('YASR_VERSION_NUM', '1.2.0');
36
 
37
  //Plugin relative path
38
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
99
  define ("YASR_SNIPPET", $stored_options['snippet']);
100
  define ("YASR_ITEMTYPE", $stored_options['snippet_itemtype']);
101
  define ("YASR_SCHEMA_FORMAT", $stored_options['snippet_format']);
102
+ define ("YASR_METABOX_OVERALL_RATING", $stored_options['metabox_overall_rating']);
103
 
104
 
105
  // this is the URL our updater / license checker pings. This should be the URL of the site with EDD installed
106
+ define( 'YASR_EDD_SL_STORE_URL', 'https://yetanotherstarsrating.com' );
107
+
108
 
109
+ //Get stored style options
110
  $style_options = get_option ('yasr_style_options');
111
 
112
+
113
  if ($style_options) {
114
 
115
  if(isset($style_options['textarea'])) {
133
  else {
134
 
135
  define ("YASR_SCHEME_COLOR", NULL);
136
+
137
  }
138
 
139
 
148
  }
149
 
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  //do_action('yasr_define_style_options', $style_options);
152
 
153
  /****** End Getting options ******/
154
 
155
 
156
 
157
+ // Include function file
158
  require (YASR_ABSOLUTE_PATH . '/lib/yasr-functions.php');
159
 
160
  require (YASR_ABSOLUTE_PATH . '/lib/yasr-admin-actions.php');
188
 
189
  global $version_installed;
190
 
 
 
191
 
192
  //Run this only on plugin activation (doesn't work on update)
193
  register_activation_hook( __FILE__, 'yasr_on_activation' );
211
 
212
  function yasr_update_version() {
213
 
 
 
214
  global $wpdb;
215
 
216
+ global $version_installed;
217
+
218
  //Remove july 2016
219
  if ($version_installed && $version_installed < '1.0.5') {
220
 
239
  //remove end may 2016
240
  if ($version_installed && $version_installed < '1.0.2') {
241
 
242
+ $wpdb->query("ALTER TABLE " . YASR_MULTI_SET_FIELDS_TABLE . " CHANGE field_name field_name VARCHAR( 40 )
243
  CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;");
244
 
245
  }