Yasr – Yet Another Stars Rating - Version 0.7.0

Version Description

  • Fixed bug for yasr_visitor_votes shortcode
Download this release

Release Info

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

Code changes from version 0.6.9 to 0.7.0

js/yasr-front.js CHANGED
@@ -1,6 +1,6 @@
1
  /****** Yasr shortcode page ******/
2
 
3
- function yasrVisitorsVotes (tooltipValues, postid, ajaxurl, size, loggedUser, voteIfUserAlredyRated, votes, votesNumber, loaderHtml, nonceVisitor) {
4
 
5
  jQuery('#yasr_rateit_visitor_votes_' + postid).bind('over', function (event, value) { jQuery(this).attr('title', tooltipValues[value-1]); });
6
 
@@ -22,8 +22,6 @@
22
  action: 'yasr_readonly_visitor_shortcode',
23
  size: size,
24
  rating: cookievote,
25
- votes: votes,
26
- votes_number: votesNumber,
27
  post_id: postid
28
  }
29
 
1
  /****** Yasr shortcode page ******/
2
 
3
+ function yasrVisitorsVotes (tooltipValues, postid, ajaxurl, size, loggedUser, voteIfUserAlredyRated, loaderHtml, nonceVisitor) {
4
 
5
  jQuery('#yasr_rateit_visitor_votes_' + postid).bind('over', function (event, value) { jQuery(this).attr('title', tooltipValues[value-1]); });
6
 
22
  action: 'yasr_readonly_visitor_shortcode',
23
  size: size,
24
  rating: cookievote,
 
 
25
  post_id: postid
26
  }
27
 
lib/yasr-ajax-functions.php CHANGED
@@ -1137,12 +1137,10 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
1137
  add_action( 'wp_ajax_nopriv_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
1138
 
1139
  function yasr_readonly_visitor_shortcode_callback() {
1140
- if(isset($_POST['rating']) && isset($_POST['post_id']) && isset($_POST['votes']) && isset($_POST['votes_number'])) {
1141
  $rating = $_POST['rating'];
1142
  $post_id = $_POST['post_id'];
1143
  $size = $_POST['size'];
1144
- $average_rating = $_POST['votes'];
1145
- $votes_number = $_POST['votes_number'];
1146
  }
1147
  else {
1148
  exit();
@@ -1167,7 +1165,7 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
1167
  global $wpdb;
1168
 
1169
  //I've to pass post_id here cause get_the_id doesn't work if called with ajax
1170
- /*$array_votes=yasr_get_visitor_votes($post_id);
1171
 
1172
  foreach ($array_votes as $vote) {
1173
  $number_of_votes = $vote->number_of_votes;
@@ -1179,9 +1177,9 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
1179
  $number_of_votes = 1;
1180
  }
1181
 
1182
- $average_rating = $vote/$votes_number;
1183
 
1184
- $average_rating = round ($average_rating, 1);*/
1185
 
1186
 
1187
  //Check if user specifyed a custom text to display when a vistor har rated
@@ -1189,7 +1187,7 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
1189
  if( YASR_TEXT_BEFORE_STARS == 1 && YASR_CUSTOM_TEXT_USER_VOTED != '' ) {
1190
 
1191
  echo "<div class=\"$rateit_class\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1192
- <span class=\"yasr-total-average-text\" id=\"yasr-total-average-text_$post_id\" title=\"yasr-stats\">[" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average " , "yasr") . "$average_rating/5 ]</span>
1193
  <span class=\"yasr-small-block-bold\" id=\"yasr-already-voted-text\">" . YASR_CUSTOM_TEXT_USER_VOTED . " </span>";
1194
 
1195
  }
@@ -1197,7 +1195,7 @@ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
1197
  else {
1198
 
1199
  echo "<div class=\"$rateit_class\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1200
- <span class=\"yasr-total-average-text\" id=\"yasr-total-average-text_$post_id\" title=\"yasr-stats\">[" . __("Total: ", "yasr") . "$votes_number &nbsp; &nbsp;" . __("Average " , "yasr") . "$average_rating/5 ]</span>
1201
  <span class=\"yasr-small-block-bold\" id=\"yasr-already-voted-text\">" . __("You've already voted this article with", "yasr") . " $rating </span>";
1202
 
1203
  }
1137
  add_action( 'wp_ajax_nopriv_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
1138
 
1139
  function yasr_readonly_visitor_shortcode_callback() {
1140
+ if(isset($_POST['rating']) && isset($_POST['post_id']) && isset($_POST['size'])) {
1141
  $rating = $_POST['rating'];
1142
  $post_id = $_POST['post_id'];
1143
  $size = $_POST['size'];
 
 
1144
  }
1145
  else {
1146
  exit();
1165
  global $wpdb;
1166
 
1167
  //I've to pass post_id here cause get_the_id doesn't work if called with ajax
1168
+ $array_votes=yasr_get_visitor_votes($post_id);
1169
 
1170
  foreach ($array_votes as $vote) {
1171
  $number_of_votes = $vote->number_of_votes;
1177
  $number_of_votes = 1;
1178
  }
1179
 
1180
+ $average_rating = $sum_votes/$number_of_votes;
1181
 
1182
+ $average_rating = round ($average_rating, 1);
1183
 
1184
 
1185
  //Check if user specifyed a custom text to display when a vistor har rated
1187
  if( YASR_TEXT_BEFORE_STARS == 1 && YASR_CUSTOM_TEXT_USER_VOTED != '' ) {
1188
 
1189
  echo "<div class=\"$rateit_class\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1190
+ <span class=\"yasr-total-average-text\" id=\"yasr-total-average-text_$post_id\" title=\"yasr-stats\">[" . __("Total: ", "yasr") . "$number_of_votes &nbsp; &nbsp;" . __("Average " , "yasr") . "$average_rating/5 ]</span>
1191
  <span class=\"yasr-small-block-bold\" id=\"yasr-already-voted-text\">" . YASR_CUSTOM_TEXT_USER_VOTED . " </span>";
1192
 
1193
  }
1195
  else {
1196
 
1197
  echo "<div class=\"$rateit_class\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1198
+ <span class=\"yasr-total-average-text\" id=\"yasr-total-average-text_$post_id\" title=\"yasr-stats\">[" . __("Total: ", "yasr") . "$number_of_votes &nbsp; &nbsp;" . __("Average " , "yasr") . "$average_rating/5 ]</span>
1199
  <span class=\"yasr-small-block-bold\" id=\"yasr-already-voted-text\">" . __("You've already voted this article with", "yasr") . " $rating </span>";
1200
 
1201
  }
lib/yasr-shortcode-functions.php CHANGED
@@ -304,12 +304,10 @@ function shortcode_visitor_votes_callback ($atts) {
304
  var size = <?php echo (json_encode($size)) ?>;
305
  var loggedUser = <?php echo (json_encode(is_user_logged_in())); ?>;
306
  var voteIfUserAlredyRated = <?php echo (json_encode($vote_if_user_already_rated)) ?>;
307
- var votes = <?php echo (json_encode($medium_rating)) ?>;
308
- var votesNumber = <?php echo (json_encode($votes_number)) ?>;
309
  var loaderHtml = <?php echo (json_encode("$loader_html")); ?>;
310
  var nonceVisitor = <?php echo (json_encode("$ajax_nonce_visitor")); ?>;
311
 
312
- yasrVisitorsVotes(tooltipValues, postid, ajaxurl, size, loggedUser, voteIfUserAlredyRated, votes, votesNumber, loaderHtml, nonceVisitor);
313
 
314
  var visitorStatsEnabled = <?php echo (json_encode(YASR_VISITORS_STATS)); ?>;
315
 
304
  var size = <?php echo (json_encode($size)) ?>;
305
  var loggedUser = <?php echo (json_encode(is_user_logged_in())); ?>;
306
  var voteIfUserAlredyRated = <?php echo (json_encode($vote_if_user_already_rated)) ?>;
 
 
307
  var loaderHtml = <?php echo (json_encode("$loader_html")); ?>;
308
  var nonceVisitor = <?php echo (json_encode("$ajax_nonce_visitor")); ?>;
309
 
310
+ yasrVisitorsVotes(tooltipValues, postid, ajaxurl, size, loggedUser, voteIfUserAlredyRated, loaderHtml, nonceVisitor);
311
 
312
  var visitorStatsEnabled = <?php echo (json_encode(YASR_VISITORS_STATS)); ?>;
313
 
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.0
7
- Stable tag: 0.6.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
@@ -91,6 +91,9 @@ Of course not: you can easily add it on the visual editor just by clicking on th
91
 
92
  == Changelog ==
93
 
 
 
 
94
  = 0.6.9 =
95
  * Yasr Visitor Votes shortag is finally avaible in archive pages!
96
  * Code cleanup on yasr visitor votes shortag
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.0.1
7
+ Stable tag: 0.7.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
91
 
92
  == Changelog ==
93
 
94
+ = 0.7.0 =
95
+ * Fixed bug for yasr_visitor_votes shortcode
96
+
97
  = 0.6.9 =
98
  * Yasr Visitor Votes shortag is finally avaible in archive pages!
99
  * Code cleanup on yasr visitor votes shortag
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.6.9
7
  * Author: Dario Curvino
8
  * Author URI: http://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.6.9');
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.7.0
7
  * Author: Dario Curvino
8
  * Author URI: http://yetanotherstarsrating.com/
9
  * License: GPL2
28
  */
29
 
30
 
31
+ define('YASR_VERSION_NUM', '0.7.0');
32
 
33
  //Plugin relative path
34
  define( "YASR_RELATIVE_PATH", dirname(__FILE__) );