Yasr – Yet Another Stars Rating - Version 0.9.2

Version Description

  • FIXED: bugfix on yasr_visitor_multiset
  • FIXED: wrong review type showed in editing screen
  • FIXED: could vote > 5 in overall rating if use digits instead of stars
  • FIXED: double voting in visitor multi set if "submit" button is pressed more than once
  • FIXED: progressbar in tooltips (thanks to Harry Milatz )
  • FIXED: minor security fix
Download this release

Release Info

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

Code changes from version 0.9.1 to 0.9.2

css/yasr-admin.css CHANGED
@@ -272,6 +272,7 @@ div.bigstars .rateit-selected
272
  padding: 10px;
273
  font-size: 12px;
274
  }
 
275
  }
276
 
277
  .yasr-option-size {
272
  padding: 10px;
273
  font-size: 12px;
274
  }
275
+
276
  }
277
 
278
  .yasr-option-size {
js/yasr-admin.js CHANGED
@@ -85,6 +85,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
85
 
86
  //This is for the numbers
87
  function yasrPrintEventSendOverallWithNumbers(postid, nonce) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
  jQuery('#yasr-send-overall-numbers').on('click', function() {
90
 
85
 
86
  //This is for the numbers
87
  function yasrPrintEventSendOverallWithNumbers(postid, nonce) {
88
+
89
+ var integer = jQuery('#yasr-vote-overall-numbers-int').val();
90
+
91
+ if (integer == 5) {
92
+
93
+ jQuery("#yasr-comma-between-select").hide();
94
+ jQuery("#yasr-vote-overall-numbers-dec").hide();
95
+
96
+ }
97
+
98
+ jQuery('#yasr-vote-overall-numbers-int').on('change', function() {
99
+
100
+ var integer = (this.value);
101
+
102
+ if (integer == 5) {
103
+
104
+ jQuery("#yasr-comma-between-select").hide();
105
+ jQuery("#yasr-vote-overall-numbers-dec").hide();
106
+
107
+ }
108
+
109
+ });
110
 
111
  jQuery('#yasr-send-overall-numbers').on('click', function() {
112
 
js/yasr-front.js CHANGED
@@ -92,6 +92,8 @@
92
 
93
  jQuery('#yasr-send-visitor-multiset-'+postId+'-'+setType).on('click', function() {
94
 
 
 
95
  var cookiename = "yasr_multi_visitor_vote_" + postId+'_'+setType;
96
 
97
  jQuery('#yasr-loader-multiset-visitor-'+postId+'-'+setType).show();
@@ -207,8 +209,10 @@
207
 
208
  });
209
 
210
- jQuery('#yasr-total-average-dashicon-' + postid).on("click", function(){
211
  jQuery(this).tooltip('enable').tooltip('open');
 
 
212
  });
213
 
214
  }
92
 
93
  jQuery('#yasr-send-visitor-multiset-'+postId+'-'+setType).on('click', function() {
94
 
95
+ jQuery('#yasr-send-visitor-multiset-'+postId+'-'+setType).hide();
96
+
97
  var cookiename = "yasr_multi_visitor_vote_" + postId+'_'+setType;
98
 
99
  jQuery('#yasr-loader-multiset-visitor-'+postId+'-'+setType).show();
209
 
210
  });
211
 
212
+ jQuery('#yasr-total-average-dashicon-' + postid).on("hover", function(){
213
  jQuery(this).tooltip('enable').tooltip('open');
214
+ jQuery('.ui-helper-hidden-accessible').children(':first').removeAttr('style');
215
+ jQuery('.ui-helper-hidden-accessible').children(':last', this).remove();
216
  });
217
 
218
  }
lib/yasr-ajax-functions.php CHANGED
@@ -48,6 +48,12 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
48
  die( 'Security check' );
49
  }
50
 
 
 
 
 
 
 
51
  global $wpdb;
52
 
53
  //If update works means that visitor already rated this post
48
  die( 'Security check' );
49
  }
50
 
51
+ if ($rating > 5) {
52
+
53
+ $rating = 5;
54
+
55
+ }
56
+
57
  global $wpdb;
58
 
59
  //If update works means that visitor already rated this post
lib/yasr-db-functions.php CHANGED
@@ -26,11 +26,11 @@ function yasr_install() {
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';
32
- $yasr_multi_values_table=$prefix . 'multi_values';
33
- $yasr_log_table=$prefix . 'log';
34
 
35
  $sql_yasr_votes_table = "CREATE TABLE IF NOT EXISTS $yasr_votes_table (
36
  id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -230,12 +230,12 @@ function yasr_get_multi_set_visitor ($post_id, $set_type) {
230
 
231
  $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
232
  FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f, " . YASR_MULTI_SET_VALUES_TABLE . " AS v
233
- WHERE f.parent_set_id=$set_type
234
  AND f.field_id = v.field_id
235
  AND v.post_id = %d
236
  AND v.set_type = %d
237
  AND f.parent_set_id=v.set_type
238
- ORDER BY f.field_id ASC", $post_id, $set_type));
239
 
240
  return $result;
241
 
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';
32
+ $yasr_multi_values_table = $prefix . 'multi_values';
33
+ $yasr_log_table = $prefix . 'log';
34
 
35
  $sql_yasr_votes_table = "CREATE TABLE IF NOT EXISTS $yasr_votes_table (
36
  id bigint(20) NOT NULL AUTO_INCREMENT,
230
 
231
  $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
232
  FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f, " . YASR_MULTI_SET_VALUES_TABLE . " AS v
233
+ WHERE f.parent_set_id=%d
234
  AND f.field_id = v.field_id
235
  AND v.post_id = %d
236
  AND v.set_type = %d
237
  AND f.parent_set_id=v.set_type
238
+ ORDER BY f.field_id ASC", $set_type, $post_id, $set_type));
239
 
240
  return $result;
241
 
lib/yasr-shortcode-functions.php CHANGED
@@ -611,8 +611,6 @@ function yasr_visitor_multiset_callback ( $atts ) {
611
 
612
  }
613
 
614
- //$unique_div_id = $setid . "_" . $set_content->id;
615
-
616
  $shortcode_html .= "<tr>
617
  <td>
618
  <span class=\"yasr-multi-set-name-field\">$set_content->name </span>
@@ -641,9 +639,11 @@ function yasr_visitor_multiset_callback ( $atts ) {
641
  WHERE parent_set_id=%d
642
  ORDER BY field_id ASC", $setid));
643
 
 
644
  $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
645
 
646
  foreach ($set_name as $set_content) {
 
647
  $shortcode_html .= "<tr>
648
  <td>
649
  <span class=\"yasr-multi-set-name-field\">$set_content->name </span>
@@ -653,7 +653,39 @@ function yasr_visitor_multiset_callback ( $atts ) {
653
  <span class=\"yasr-visitor-multiset-vote-count\"> 0 </span>
654
  </td>
655
  </tr>";
656
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
657
 
658
  $shortcode_html.="<tr>
659
  <td colspan=\"2\">
611
 
612
  }
613
 
 
 
614
  $shortcode_html .= "<tr>
615
  <td>
616
  <span class=\"yasr-multi-set-name-field\">$set_content->name </span>
639
  WHERE parent_set_id=%d
640
  ORDER BY field_id ASC", $setid));
641
 
642
+
643
  $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
644
 
645
  foreach ($set_name as $set_content) {
646
+
647
  $shortcode_html .= "<tr>
648
  <td>
649
  <span class=\"yasr-multi-set-name-field\">$set_content->name </span>
653
  <span class=\"yasr-visitor-multiset-vote-count\"> 0 </span>
654
  </td>
655
  </tr>";
656
+
657
+
658
+
659
+ //First time, initialize all fields to 0
660
+
661
+ //Find the highest_id (it's not auto increment on db due to gd star compatibility)
662
+ $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
663
+
664
+ //highest id is 0 in data is empty
665
+ if (!$highest_id) {
666
+ $new_id=0;
667
+ }
668
+
669
+ //or is n+1
670
+ foreach ($highest_id as $id) {
671
+ $new_id=$id->id + 1;
672
+ }
673
+
674
+ $wpdb->replace(
675
+ YASR_MULTI_SET_VALUES_TABLE,
676
+ array (
677
+ 'id'=>$new_id,
678
+ 'post_id'=>$post_id,
679
+ 'field_id'=>$set_content->id,
680
+ 'set_type'=>$setid,
681
+ 'number_of_votes' => 0,
682
+ 'sum_votes' => 0
683
+ ),
684
+ array ("%d", "%d", "%d", "%d", "%d", "%d")
685
+ );
686
+
687
+
688
+ } //end foreach ($set_name as $set_content)
689
 
690
  $shortcode_html.="<tr>
691
  <td colspan=\"2\">
readme.txt CHANGED
@@ -3,8 +3,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
3
  Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post rating, posts, rate, rating, rating platform, rating system, ratings, review, reviews, rich snippets, seo, star, star rating, stars, vote, Votes, voting, voting contest, schema, serp
4
  Requires at least: 3.5
5
  Contributors: Dudo
6
- Tested up to: 4.2.2
7
- Stable tag: 0.9.1
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
@@ -123,6 +123,14 @@ Of course not: you can easily add it on the visual editor just by clicking on th
123
 
124
  == Changelog ==
125
 
 
 
 
 
 
 
 
 
126
  = 0.9.1 =
127
  * Security fix
128
 
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.2.3
7
+ Stable tag: 0.9.2
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
123
 
124
  == Changelog ==
125
 
126
+ = 0.9.2 =
127
+ * FIXED: bugfix on yasr_visitor_multiset
128
+ * FIXED: wrong review type showed in editing screen
129
+ * FIXED: could vote > 5 in overall rating if use digits instead of stars
130
+ * FIXED: double voting in visitor multi set if "submit" button is pressed more than once
131
+ * FIXED: progressbar in tooltips (thanks to Harry Milatz )
132
+ * FIXED: minor security fix
133
+
134
  = 0.9.1 =
135
  * Security fix
136
 
yasr-metabox-top-right.php CHANGED
@@ -33,7 +33,17 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
33
  if($overall_rating != '-1') {
34
  $overall_rating_array = explode(".", $overall_rating);
35
  $int = $overall_rating_array[0];
36
- $dec = $overall_rating_array[1];
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
  else {
@@ -122,23 +132,23 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
122
 
123
  <span id="yasr-comma-between-select">,</span>
124
 
125
- <select name="yasr-vote-overall-numbers-dec" id="yasr-vote-overall-numbers-dec" class="yasr-vote-overall-numbers">
126
 
127
- <?php
128
 
129
- for ($i=0; $i<=9; $i++) {
130
- if ($i == $dec) {
131
- echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
132
- }
133
 
134
- else {
135
- echo "<option value=\"$i\">$i</option>\n";
 
136
  }
137
- }
138
 
139
- ?>
140
 
141
- </select>
142
 
143
  </div>
144
 
@@ -172,7 +182,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
172
 
173
  $array_review_type = explode(',', $i18n_array_review);
174
 
175
- $review_type = $array_review_type;
 
176
  $review_type_choosen = yasr_get_snippet_type();
177
 
178
  ?>
@@ -190,6 +201,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
190
  else {
191
  echo "<option value=\"$type\">$type</option>";
192
  }
 
193
  }
194
 
195
  ?>
33
  if($overall_rating != '-1') {
34
  $overall_rating_array = explode(".", $overall_rating);
35
  $int = $overall_rating_array[0];
36
+
37
+ if($int != 5) {
38
+ $dec = $overall_rating_array[1];
39
+ }
40
+
41
+ else {
42
+
43
+ $dec = 0;
44
+
45
+ }
46
+
47
  }
48
 
49
  else {
132
 
133
  <span id="yasr-comma-between-select">,</span>
134
 
135
+ <select name="yasr-vote-overall-numbers-dec" id="yasr-vote-overall-numbers-dec" class="yasr-vote-overall-numbers">
136
 
137
+ <?php
138
 
139
+ for ($i=0; $i<=9; $i++) {
140
+ if ($i == $dec) {
141
+ echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
142
+ }
143
 
144
+ else {
145
+ echo "<option value=\"$i\">$i</option>\n";
146
+ }
147
  }
 
148
 
149
+ ?>
150
 
151
+ </select>
152
 
153
  </div>
154
 
182
 
183
  $array_review_type = explode(',', $i18n_array_review);
184
 
185
+ $review_type = array_map('trim', $array_review_type);
186
+
187
  $review_type_choosen = yasr_get_snippet_type();
188
 
189
  ?>
201
  else {
202
  echo "<option value=\"$type\">$type</option>";
203
  }
204
+
205
  }
206
 
207
  ?>
yet-another-stars-rating.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Rating system with rich snippets
6
- * Version: 0.9.1
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * License: GPL2
@@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
28
  */
29
 
30
 
31
- define('YASR_VERSION_NUM', '0.9.1');
32
 
33
  //Plugin relative path
34
  define( "YASR_RELATIVE_PATH", dirname(__FILE__) );
3
  * Plugin Name: Yet Another Stars Rating
4
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
  * Description: Rating system with rich snippets
6
+ * Version: 0.9.2
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * License: GPL2
28
  */
29
 
30
 
31
+ define('YASR_VERSION_NUM', '0.9.2');
32
 
33
  //Plugin relative path
34
  define( "YASR_RELATIVE_PATH", dirname(__FILE__) );