Yasr – Yet Another Stars Rating - Version 1.5.2

Version Description

  • TWEAKED: smaller number of queries when Yasr is called in archive pages
  • FIXED: css problem with "small" and "medium" size
Download this release

Release Info

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

Code changes from version 1.5.1 to 1.5.2

css/yasr.css CHANGED
@@ -290,4 +290,4 @@ yasr_pro_comment_reviews_stats shortcode too***/
290
  text-align: center;
291
  }
292
 
293
- /*** Tooltip ***/
290
  text-align: center;
291
  }
292
 
293
+ /*** Tooltip ***/
lib/yasr-ajax-functions.php CHANGED
@@ -1007,6 +1007,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1007
  exit();
1008
  }
1009
 
 
 
1010
  do_action('yasr_action_on_visitor_vote', $post_id, $rating);
1011
 
1012
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
@@ -1022,11 +1024,11 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1022
  $rating = 5;
1023
  }
1024
 
1025
- if ($rateit_class == 'rateit yasr_visitor_votes_stars_div') {
1026
  $px_size = '16';
1027
  }
1028
 
1029
- elseif ($rateit_class == 'rateit medium yasr_visitor_votes_stars_div') {
1030
  $px_size = '24';
1031
  }
1032
 
@@ -1071,7 +1073,7 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1071
  );
1072
 
1073
  //insert the new row
1074
- if (!$result_update_log) {
1075
 
1076
  $result_insert_log = $wpdb->insert (
1077
  YASR_LOG_TABLE,
@@ -1088,7 +1090,6 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1088
 
1089
  }
1090
 
1091
-
1092
  }
1093
 
1094
  //if user is not logged in insert
@@ -1132,6 +1133,8 @@ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // E
1132
  $total_rating = ($user_votes_sum / $number_of_votes);
1133
  $medium_rating = round ($total_rating, 1);
1134
 
 
 
1135
  echo "<div class=\"$rateit_class\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$total_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1136
  <span class=\"yasr-total-average-text\" title=\"yasr-stats\"> [" . __("Total: ", 'yet-another-stars-rating') . "$number_of_votes &nbsp; &nbsp;" . __("Average:", 'yet-another-stars-rating') . " $medium_rating/5 ]</span>
1137
  <span class=\"yasr-small-block-bold\" id=\"yasr-vote-saved\">" . __("Vote Saved" , 'yet-another-stars-rating') . "</span>";
1007
  exit();
1008
  }
1009
 
1010
+ //var_dump($rateit_class);
1011
+
1012
  do_action('yasr_action_on_visitor_vote', $post_id, $rating);
1013
 
1014
  if ( ! wp_verify_nonce( $nonce_visitor, 'yasr_nonce_insert_visitor_rating' ) ) {
1024
  $rating = 5;
1025
  }
1026
 
1027
+ if ($rateit_class == 'rateit yasr_visitor_votes_stars_div rateit-bg') {
1028
  $px_size = '16';
1029
  }
1030
 
1031
+ elseif ($rateit_class == 'rateit medium yasr_visitor_votes_stars_div rateit-bg') {
1032
  $px_size = '24';
1033
  }
1034
 
1073
  );
1074
 
1075
  //insert the new row
1076
+ if ($result_update_log===FALSE) {
1077
 
1078
  $result_insert_log = $wpdb->insert (
1079
  YASR_LOG_TABLE,
1090
 
1091
  }
1092
 
 
1093
  }
1094
 
1095
  //if user is not logged in insert
1133
  $total_rating = ($user_votes_sum / $number_of_votes);
1134
  $medium_rating = round ($total_rating, 1);
1135
 
1136
+ var_dump($px_size);
1137
+
1138
  echo "<div class=\"$rateit_class\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"$px_size\" data-rateit-starheight=\"$px_size\" data-rateit-value=\"$total_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
1139
  <span class=\"yasr-total-average-text\" title=\"yasr-stats\"> [" . __("Total: ", 'yet-another-stars-rating') . "$number_of_votes &nbsp; &nbsp;" . __("Average:", 'yet-another-stars-rating') . " $medium_rating/5 ]</span>
1140
  <span class=\"yasr-small-block-bold\" id=\"yasr-vote-saved\">" . __("Vote Saved" , 'yet-another-stars-rating') . "</span>";
lib/yasr-db-functions.php CHANGED
@@ -129,7 +129,6 @@ used in yasr_add_filter_for_schema() and yasr_get_id_value_callback() ******/
129
  function yasr_get_overall_rating($post_id=FALSE, $create_transient=TRUE) {
130
  global $wpdb;
131
 
132
-
133
  //if values it's not passed get the post id, most of cases and default one
134
  if(!$post_id) {
135
 
129
  function yasr_get_overall_rating($post_id=FALSE, $create_transient=TRUE) {
130
  global $wpdb;
131
 
 
132
  //if values it's not passed get the post id, most of cases and default one
133
  if(!$post_id) {
134
 
lib/yasr-functions.php CHANGED
@@ -414,6 +414,12 @@ add_filter('the_content', 'yasr_add_schema');
414
 
415
  }
416
 
 
 
 
 
 
 
417
  $script_type = '<script type="application/ld+json">';
418
 
419
  $end_script_type = '</script>';
@@ -756,24 +762,31 @@ function yasr_stars_size ($size) {
756
 
757
  $size = sanitize_text_field($size);
758
 
 
 
759
  $stars_attribute = array();
760
 
761
  if ($size === 'small') {
 
762
  $stars_attribute['class'] = 'rateit yasr_visitor_votes_stars_div';
763
  $stars_attribute['px_size'] = '16';
764
  }
765
 
766
  elseif ($size === 'medium') {
 
767
  $stars_attribute['class'] = 'rateit medium yasr_visitor_votes_stars_div';
768
  $stars_attribute['px_size'] = '24';
769
  }
770
 
771
  //default values
772
  else {
 
773
  $stars_attribute['class'] = 'rateit bigstars yasr_visitor_votes_stars_div';
774
  $stars_attribute['px_size'] = '32';
775
  }
776
 
 
 
777
  return $stars_attribute;
778
 
779
  }
414
 
415
  }
416
 
417
+ if(!is_singular() && is_main_query() || is_404()){
418
+
419
+ return $content;
420
+
421
+ }
422
+
423
  $script_type = '<script type="application/ld+json">';
424
 
425
  $end_script_type = '</script>';
762
 
763
  $size = sanitize_text_field($size);
764
 
765
+ //var_dump($size);
766
+
767
  $stars_attribute = array();
768
 
769
  if ($size === 'small') {
770
+
771
  $stars_attribute['class'] = 'rateit yasr_visitor_votes_stars_div';
772
  $stars_attribute['px_size'] = '16';
773
  }
774
 
775
  elseif ($size === 'medium') {
776
+
777
  $stars_attribute['class'] = 'rateit medium yasr_visitor_votes_stars_div';
778
  $stars_attribute['px_size'] = '24';
779
  }
780
 
781
  //default values
782
  else {
783
+
784
  $stars_attribute['class'] = 'rateit bigstars yasr_visitor_votes_stars_div';
785
  $stars_attribute['px_size'] = '32';
786
  }
787
 
788
+ //var_dump($stars_attribute);
789
+
790
  return $stars_attribute;
791
 
792
  }
lib/yasr-shortcode-functions.php CHANGED
@@ -25,6 +25,12 @@ 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',
@@ -94,6 +100,12 @@ add_shortcode ('yasr_overall_rating', 'shortcode_overall_rating_callback');
94
  add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
95
 
96
  function shortcode_visitor_votes_callback ($atts) {
 
 
 
 
 
 
97
 
98
  $shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
99
 
@@ -144,6 +156,8 @@ add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
144
 
145
  $stars_attribute = yasr_stars_size($size);
146
 
 
 
147
  $yasr_cookiename = 'yasr_visitor_vote_' . $post_id;
148
 
149
  if (isset($_COOKIE[$yasr_cookiename])) {
25
 
26
  function shortcode_overall_rating_callback ($atts) {
27
 
28
+ if (YASR_SHOW_OVERALL_IN_LOOP === 'disabled' && !is_singular() && is_main_query()) {
29
+
30
+ return;
31
+
32
+ }
33
+
34
  extract( shortcode_atts (
35
  array(
36
  'size' => 'large',
100
  add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
101
 
102
  function shortcode_visitor_votes_callback ($atts) {
103
+
104
+ if (YASR_SHOW_OVERALL_IN_LOOP === 'disabled' && !is_singular() && is_main_query()) {
105
+
106
+ return;
107
+
108
+ }
109
 
110
  $shortcode_html = NULL; //Avoid undefined variable outside is_singular && is_main_query
111
 
156
 
157
  $stars_attribute = yasr_stars_size($size);
158
 
159
+ //var_dump($stars_attribute);
160
+
161
  $yasr_cookiename = 'yasr_visitor_vote_' . $post_id;
162
 
163
  if (isset($_COOKIE[$yasr_cookiename])) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: 5 star, admin, administrator, AJAX, five-star, javascript, jquery, post r
4
  Requires at least: 4.3.0
5
  Contributors: Dudo
6
  Tested up to: 4.9.4
7
- Stable tag: 1.5.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
@@ -107,6 +107,10 @@ Of course not: you can easily add it on the visual editor just by clicking the "
107
 
108
  The full changelog can be found in the plugin's directory. Recent entries:
109
 
 
 
 
 
110
  = 1.5.1 =
111
  * FIXED: when a post/page was removed from trash
112
 
4
  Requires at least: 4.3.0
5
  Contributors: Dudo
6
  Tested up to: 4.9.4
7
+ Stable tag: 1.5.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
107
 
108
  The full changelog can be found in the plugin's directory. Recent entries:
109
 
110
+ = 1.5.2 =
111
+ * TWEAKED: smaller number of queries when Yasr is called in archive pages
112
+ * FIXED: css problem with "small" and "medium" size
113
+
114
  = 1.5.1 =
115
  * FIXED: when a post/page was removed from trash
116
 
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.5.1
7
  * Author: Dario Curvino
8
  * Author URI: https://yetanotherstarsrating.com/
9
  * Text Domain: yet-another-stars-rating
@@ -31,7 +31,7 @@ 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
- define('YASR_VERSION_NUM', '1.5.1');
35
 
36
  //Plugin relative path
37
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
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.5.2
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
+ define('YASR_VERSION_NUM', '1.5.2');
35
 
36
  //Plugin relative path
37
  define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );