Yasr – Yet Another Stars Rating - Version 2.8.9

Version Description

  • FIXED: stars next to the title didn't work if shortcode doesn't exists in a post or page
  • TWEAKED: minor changes
Download this release

Release Info

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

Code changes from version 2.8.8 to 2.8.9

includes/js/yasr-front.js DELETED
@@ -1 +0,0 @@
1
- (()=>{"use strict";function t(t,e,r=!1,s=.1,a=!0,i=!1,n=!1){let o;o=r||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:o,step:s,readOnly:a,rating:i,rateCallback:n})}const{__:e}=wp.i18n,r=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"];for(let t=0;t<r.length;t++)s(r[t]);function s(e){const r=document.getElementsByClassName(e);r.length>0&&("yasr-rater-stars"!==e&&"yasr-ranking-stars"!==e||function(e){for(let r=0;r<e.length;r++)if(!1===e.item(r).classList.contains("yasr-star-rating")){const s=e.item(r),a=s.id;t(s.getAttribute("data-rater-starsize"),a,s)}}(r),"yasr-multiset-visitors-rater"===e&&function(e){var r="",s=[];for(let a=0;a<e.length;a++)!function(a){if(!1!==e.item(a).classList.contains("yasr-star-rating"))return;let i=e.item(a),n=i.id,o=i.getAttribute("data-rater-readonly");var l;null!=(l=o)&&""!==l||(l=!0),"true"!==l&&"1"!==l||(l=!0),"false"!==l&&"0"!==l||(l=!1),o=l;t(16,n,i,1,o,!1,(function(t,e){const a=i.getAttribute("data-rater-postid"),n=i.getAttribute("data-rater-setid"),o=i.getAttribute("data-rater-set-field-id");t=t.toFixed(1);const l=parseInt(t);this.setRating(l),r={postid:a,setid:n,field:o,rating:l},s.push(r),e()}))}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){const t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),r=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var a={action:"yasr_visitor_multiset_field_vote",nonce:r,post_id:t,rating:s,set_id:e};jQuery.post(yasrCommonData.ajaxurl,a,(function(r){let s;s=(r=JSON.parse(r)).text,jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(s)}))}))}(r))}})();
 
includes/shortcodes/classes/YasrMultiSet.php CHANGED
@@ -48,7 +48,7 @@ class YasrMultiSet extends YasrShortcode {
48
  $this->shortcode_html .= "</table>";
49
  $this->shortcode_html .= '<!--End Yasr Multi Set Shortcode-->';
50
 
51
- $this->enqueueReadonlyAndMultisetScript();
52
 
53
  return $this->shortcode_html;
54
  }
48
  $this->shortcode_html .= "</table>";
49
  $this->shortcode_html .= '<!--End Yasr Multi Set Shortcode-->';
50
 
51
+ YasrShortcode::enqueueReadonlyAndMultisetScript();
52
 
53
  return $this->shortcode_html;
54
  }
includes/shortcodes/classes/YasrNoStarsRankings.php CHANGED
@@ -45,7 +45,7 @@ class YasrNoStarsRankings extends YasrShortcode {
45
 
46
  $this->shortcode_html .= '<!-- Yasr '.$this->shortcode_name.' Shortcode-->';
47
 
48
- $this->enqueueRankingScript();
49
 
50
  return $this->shortcode_html;
51
 
45
 
46
  $this->shortcode_html .= '<!-- Yasr '.$this->shortcode_name.' Shortcode-->';
47
 
48
+ YasrShortcode::enqueueRankingScript();
49
 
50
  return $this->shortcode_html;
51
 
includes/shortcodes/classes/YasrOverallRating.php CHANGED
@@ -52,9 +52,9 @@ class YasrOverallRating extends YasrShortcode {
52
  //Use this filter to customize overall rating
53
  $shortcode_html = apply_filters('yasr_overall_rating_shortcode', $shortcode_html, $overall_attributes);
54
 
55
- $this->defineOvAttributes($overall_attributes);
56
 
57
- $this->enqueueReadonlyAndMultisetScript();
58
 
59
  return $shortcode_html;
60
  }
@@ -134,12 +134,12 @@ class YasrOverallRating extends YasrShortcode {
134
  /**
135
  * @author Dario Curvino <@dudo>
136
  * @since 2.8.8
137
- * @param $overall_attributes
 
138
  */
139
- protected function defineOvAttributes($overall_attributes) {
140
  if(!defined('YASR_OV_ATTRIBUTES')) {
141
- unset($overall_attributes['html_stars'], $overall_attributes['post_id']);
142
- define('YASR_OV_ATTRIBUTES', json_encode($overall_attributes));
143
  }
144
  }
145
 
52
  //Use this filter to customize overall rating
53
  $shortcode_html = apply_filters('yasr_overall_rating_shortcode', $shortcode_html, $overall_attributes);
54
 
55
+ self::defineOvAttributes($overall_attributes['overall_rating']);
56
 
57
+ YasrShortcode::enqueueReadonlyAndMultisetScript();
58
 
59
  return $shortcode_html;
60
  }
134
  /**
135
  * @author Dario Curvino <@dudo>
136
  * @since 2.8.8
137
+ *
138
+ * @param $overall_rating
139
  */
140
+ public static function defineOvAttributes($overall_rating) {
141
  if(!defined('YASR_OV_ATTRIBUTES')) {
142
+ define('YASR_OV_ATTRIBUTES', json_encode($overall_rating));
 
143
  }
144
  }
145
 
includes/shortcodes/classes/YasrRankings.php CHANGED
@@ -56,7 +56,7 @@ class YasrRankings extends YasrShortcode {
56
  $this->returnSingleTableRanking($this->urlencodeAtts($sql_atts));
57
  $this->shortcode_html .= '<!--End Yasr Top 10 highest Rated Shortcode-->';
58
 
59
- $this->enqueueRankingScript();
60
 
61
  return $this->shortcode_html;
62
  }
56
  $this->returnSingleTableRanking($this->urlencodeAtts($sql_atts));
57
  $this->shortcode_html .= '<!--End Yasr Top 10 highest Rated Shortcode-->';
58
 
59
+ YasrShortcode::enqueueRankingScript();
60
 
61
  return $this->shortcode_html;
62
  }
includes/shortcodes/classes/YasrShortcode.php CHANGED
@@ -44,7 +44,7 @@ abstract class YasrShortcode
44
  public function __construct( $atts, $shortcode_name )
45
  {
46
  //Enqueue Scripts
47
- $this->enqueueScripts();
48
  $this->shortcode_name = $shortcode_name;
49
 
50
  if ( $atts !== false ) {
@@ -77,7 +77,7 @@ abstract class YasrShortcode
77
  * @author Dario Curvino <@dudo>
78
  * @since 2.8.5
79
  */
80
- public function enqueueScripts()
81
  {
82
  //scripts required for all shortocdes
83
  yasr_enqueue_includes_js_scripts();
@@ -90,7 +90,7 @@ abstract class YasrShortcode
90
  * @author Dario Curvino <@dudo>
91
  * @since 2.8.8
92
  */
93
- public function enqueueReadonlyAndMultisetScript()
94
  {
95
  wp_enqueue_script(
96
  'yasr-ov-multi',
@@ -105,9 +105,9 @@ abstract class YasrShortcode
105
  * Enqueue scripts for rankings
106
  *
107
  * @author Dario Curvino <@dudo>
108
- * @since 2.8.8
109
  */
110
- public function enqueueRankingScript()
111
  {
112
  wp_enqueue_script(
113
  'yasr-rankings',
44
  public function __construct( $atts, $shortcode_name )
45
  {
46
  //Enqueue Scripts
47
+ self::enqueueScripts();
48
  $this->shortcode_name = $shortcode_name;
49
 
50
  if ( $atts !== false ) {
77
  * @author Dario Curvino <@dudo>
78
  * @since 2.8.5
79
  */
80
+ public static function enqueueScripts()
81
  {
82
  //scripts required for all shortocdes
83
  yasr_enqueue_includes_js_scripts();
90
  * @author Dario Curvino <@dudo>
91
  * @since 2.8.8
92
  */
93
+ public static function enqueueReadonlyAndMultisetScript()
94
  {
95
  wp_enqueue_script(
96
  'yasr-ov-multi',
105
  * Enqueue scripts for rankings
106
  *
107
  * @author Dario Curvino <@dudo>
108
+ * @since 2.8.8
109
  */
110
+ public static function enqueueRankingScript()
111
  {
112
  wp_enqueue_script(
113
  'yasr-rankings',
includes/shortcodes/classes/YasrVisitorMultiSet.php CHANGED
@@ -99,7 +99,7 @@ class YasrVisitorMultiSet extends YasrMultiSet {
99
  $this->shortcode_html .= "</table>";
100
  $this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
101
 
102
- $this->enqueueReadonlyAndMultisetScript();
103
 
104
  return $this->shortcode_html;
105
  }
99
  $this->shortcode_html .= "</table>";
100
  $this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
101
 
102
+ YasrShortcode::enqueueReadonlyAndMultisetScript();
103
 
104
  return $this->shortcode_html;
105
  }
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -64,7 +64,7 @@ class YasrVisitorVotes extends YasrShortcode {
64
 
65
  $average_rating=round($average_rating, 1);
66
 
67
- $this->defineVvAttributes($stored_votes);
68
 
69
  //if this come from yasr_visitor_votes_readonly...
70
  if ($this->readonly === 'true' || $this->readonly === "yes") {
@@ -153,7 +153,7 @@ class YasrVisitorVotes extends YasrShortcode {
153
 
154
  $shortcode_html = $container . $stars . $end_container;
155
 
156
- $this->enqueueReadonlyAndMultisetScript();
157
 
158
  //Use this filter to customize yasr_visitor_votes readonly
159
  return apply_filters('yasr_vv_ro_shortcode', $shortcode_html, $stored_votes);
@@ -467,12 +467,9 @@ class YasrVisitorVotes extends YasrShortcode {
467
  *
468
  * @param $stored_votes
469
  */
470
- protected function defineVvAttributes($stored_votes) {
471
  if(!defined('YASR_VV_ATTRIBUTES')) {
472
- $yasr_vv_attributes = array (
473
- 'stored_votes' => $stored_votes,
474
- );
475
-
476
  define('YASR_VV_ATTRIBUTES', json_encode($yasr_vv_attributes));
477
  }
478
  }
64
 
65
  $average_rating=round($average_rating, 1);
66
 
67
+ self::defineVvAttributes($stored_votes);
68
 
69
  //if this come from yasr_visitor_votes_readonly...
70
  if ($this->readonly === 'true' || $this->readonly === "yes") {
153
 
154
  $shortcode_html = $container . $stars . $end_container;
155
 
156
+ YasrShortcode::enqueueReadonlyAndMultisetScript();
157
 
158
  //Use this filter to customize yasr_visitor_votes readonly
159
  return apply_filters('yasr_vv_ro_shortcode', $shortcode_html, $stored_votes);
467
  *
468
  * @param $stored_votes
469
  */
470
+ public static function defineVvAttributes($stored_votes) {
471
  if(!defined('YASR_VV_ATTRIBUTES')) {
472
+ $yasr_vv_attributes = $stored_votes;
 
 
 
473
  define('YASR_VV_ATTRIBUTES', json_encode($yasr_vv_attributes));
474
  }
475
  }
public/classes/YasrPublicFilters.php CHANGED
@@ -22,6 +22,10 @@ class YasrPublicFilters {
22
  //stars next to the title
23
  if (YASR_STARS_TITLE === 'yes') {
24
  add_filter('the_title', array($this, 'filterTitle'));
 
 
 
 
25
  }
26
 
27
  }
@@ -223,7 +227,7 @@ class YasrPublicFilters {
223
  $average_rating = round($average_rating, 1);
224
  $htmlid = 'yasr-visitor-votes-readonly-rater-' . str_shuffle(uniqid());
225
 
226
- $vv_widget = "<div class='yasr-stars-title yasr-rater-stars-vv'
227
  id='$htmlid'
228
  data-rating='$average_rating'
229
  data-rater-starsize='16'
@@ -234,6 +238,8 @@ class YasrPublicFilters {
234
 
235
  $vv_widget .= "<span class='yasr-stars-title-average'>$average_rating ($number_of_votes)</span>";
236
 
 
 
237
  //Use this hook to customize widget
238
  //if doesn't exists a filter for yasr_title_vv_widget, put $vv_widget into $content_after_title
239
  return apply_filters('yasr_title_vv_widget', $vv_widget, $stored_votes);
@@ -266,8 +272,11 @@ class YasrPublicFilters {
266
  $overall_widget = "<span class='yasr-stars-title-average'>";
267
  $overall_widget .= $overall_attributes['html_stars'];
268
  $overall_widget .= "</span>";
 
 
269
  }
270
 
 
271
  //Use this hook to customize widget overall
272
  //if doesn't exists a filter for yasr_title_overall_widget, put $overall_widget into $content_after_title
273
  return apply_filters('yasr_title_overall_widget', $overall_widget, $overall_rating);
22
  //stars next to the title
23
  if (YASR_STARS_TITLE === 'yes') {
24
  add_filter('the_title', array($this, 'filterTitle'));
25
+ add_action('wp_enqueue_scripts', static function() {
26
+ YasrShortcode::enqueueScripts();
27
+ YasrShortcode::enqueueReadonlyAndMultisetScript();
28
+ });
29
  }
30
 
31
  }
227
  $average_rating = round($average_rating, 1);
228
  $htmlid = 'yasr-visitor-votes-readonly-rater-' . str_shuffle(uniqid());
229
 
230
+ $vv_widget = "<div class='yasr-stars-title yasr-rater-stars'
231
  id='$htmlid'
232
  data-rating='$average_rating'
233
  data-rater-starsize='16'
238
 
239
  $vv_widget .= "<span class='yasr-stars-title-average'>$average_rating ($number_of_votes)</span>";
240
 
241
+ YasrVisitorVotes::defineVvAttributes($stored_votes);
242
+
243
  //Use this hook to customize widget
244
  //if doesn't exists a filter for yasr_title_vv_widget, put $vv_widget into $content_after_title
245
  return apply_filters('yasr_title_vv_widget', $vv_widget, $stored_votes);
272
  $overall_widget = "<span class='yasr-stars-title-average'>";
273
  $overall_widget .= $overall_attributes['html_stars'];
274
  $overall_widget .= "</span>";
275
+
276
+ YasrOverallRating::defineOvAttributes($overall_rating);
277
  }
278
 
279
+
280
  //Use this hook to customize widget overall
281
  //if doesn't exists a filter for yasr_title_overall_widget, put $overall_widget into $content_after_title
282
  return apply_filters('yasr_title_overall_widget', $overall_widget, $overall_rating);
public/classes/YasrRichSnippets.php CHANGED
@@ -45,13 +45,13 @@ class YasrRichSnippets {
45
  //check if ov_rating shortcode has run
46
  if (defined('YASR_OV_ATTRIBUTES')) {
47
  $ov_attributes = json_decode(YASR_OV_ATTRIBUTES, true);
48
- $overall_rating = $ov_attributes['overall_rating'];
49
  }
50
 
51
  //check if vv has run
52
  if(defined('YASR_VV_ATTRIBUTES')) {
53
  $vv_attributes = json_decode(YASR_VV_ATTRIBUTES, true);
54
- $visitor_votes = $vv_attributes['stored_votes'];
55
  }
56
 
57
  $script_type = '<script type="application/ld+json">';
45
  //check if ov_rating shortcode has run
46
  if (defined('YASR_OV_ATTRIBUTES')) {
47
  $ov_attributes = json_decode(YASR_OV_ATTRIBUTES, true);
48
+ $overall_rating = $ov_attributes;
49
  }
50
 
51
  //check if vv has run
52
  if(defined('YASR_VV_ATTRIBUTES')) {
53
  $vv_attributes = json_decode(YASR_VV_ATTRIBUTES, true);
54
+ $visitor_votes = $vv_attributes;
55
  }
56
 
57
  $script_type = '<script type="application/ld+json">';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: rating, rate post, rate page, star rating, google rating, votes
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.9
7
- Stable tag: 2.8.8
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
@@ -187,7 +187,7 @@ If doesn't, you should work on your seo reputation.
187
  Yes, YASR is 100% fully compatible with PHP 8
188
 
189
  == Screenshots ==
190
- 1. Example of Yasr Overall Rating and Yast Visitor Votes shortcodes
191
  2. Yasr Multi Set
192
  3. User's ranking showing most rated posts
193
  4. User's ranking showing highest rated posts
@@ -197,6 +197,10 @@ Yes, YASR is 100% fully compatible with PHP 8
197
 
198
  The full changelog can be found in the plugin's directory. Recent entries:
199
 
 
 
 
 
200
  = 2.8.8 =
201
  * TWEAKED: rich snippets are now included only if shortcode exists in post or page
202
  * TWEAKED: global yasr_plugin_imported is now refactored into a constant
@@ -280,9 +284,11 @@ The class yasr-total-average-container has be renamed yasr-vv-stats-text-contain
280
  * NEW FEATURE: new shortcode: yasr_visitor_multi_set_ranking : this will show rankings from yasr_visitor_multiset
281
  * TWEAKED: minor fixes
282
 
 
283
  = 2.7.1 =
284
  * FIXED: minor bugs that could happen in rare circumstances
285
 
 
286
  = 2.7.0 =
287
  * FIXED: fixed warning that can return on fresh installations
288
 
4
  Requires at least: 5.0
5
  Contributors: Dudo
6
  Tested up to: 5.9
7
+ Stable tag: 2.8.9
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
187
  Yes, YASR is 100% fully compatible with PHP 8
188
 
189
  == Screenshots ==
190
+ 1. Example of Yasr Overall Rating and Yasr Visitor Votes shortcodes
191
  2. Yasr Multi Set
192
  3. User's ranking showing most rated posts
193
  4. User's ranking showing highest rated posts
197
 
198
  The full changelog can be found in the plugin's directory. Recent entries:
199
 
200
+ = 2.8.9 =
201
+ * FIXED: stars next to the title didn't work if shortcode doesn't exists in a post or page
202
+ * TWEAKED: minor changes
203
+
204
  = 2.8.8 =
205
  * TWEAKED: rich snippets are now included only if shortcode exists in post or page
206
  * TWEAKED: global yasr_plugin_imported is now refactored into a constant
284
  * NEW FEATURE: new shortcode: yasr_visitor_multi_set_ranking : this will show rankings from yasr_visitor_multiset
285
  * TWEAKED: minor fixes
286
 
287
+
288
  = 2.7.1 =
289
  * FIXED: minor bugs that could happen in rare circumstances
290
 
291
+
292
  = 2.7.0 =
293
  * FIXED: fixed warning that can return on fresh installations
294
 
yet-another-stars-rating.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
- * Version: 2.8.8
8
  * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
@@ -78,7 +78,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
- define( 'YASR_VERSION_NUM', '2.8.8' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );
4
  * Plugin Name: Yet Another Stars Rating
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
7
+ * Version: 2.8.9
8
  * Requires at least: 5.6
9
  * Requires PHP: 5.4
10
  * Author: Dario Curvino
78
  yasr_fs();
79
  // Signal that SDK was initiated.
80
  do_action( 'yasr_fs_loaded' );
81
+ define( 'YASR_VERSION_NUM', '2.8.9' );
82
  //Plugin absolute path
83
  //e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
84
  define( 'YASR_ABSOLUTE_PATH', __DIR__ );