Yasr – Yet Another Stars Rating - Version 2.8.8

Version Description

  • TWEAKED: rich snippets are now included only if shortcode exists in post or page
  • TWEAKED: global yasr_plugin_imported is now refactored into a constant
  • FIXED: removed duplicated query
  • FIXED: Import functions from external plugins is now compatible with mysql8
  • FIXED: itemTypename didn't get saved into Rich snippet options above the editor
Download this release

Release Info

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

Code changes from version 2.8.7 to 2.8.8

admin/editor/YasrOnSavePost.php CHANGED
@@ -156,11 +156,17 @@ class YasrOnSavePost {
156
  }
157
  }
158
 
 
 
 
 
 
159
  //get value, sanitize it and save, only if:
160
  //$item_type_name contain $snippet_type (e.g. I don't need to save yasr_MOVIE_* if
161
  //the selected snippet is BOOK)
162
  //$_POST item_type_name isset
163
  //$_POST item_type_name is not empty string
 
164
  if(strpos($item_type_name, $snippet_type) !== false) {
165
  if (isset($_POST[$item_type_name])
166
  && $_POST[$item_type_name] !== ''
156
  }
157
  }
158
 
159
+ //always check the ItemType Name
160
+ if(isset($_POST['yasr_schema_title'])) {
161
+ $array_to_save['yasr_schema_title'] = sanitize_text_field($_POST['yasr_schema_title']);
162
+ }
163
+
164
  //get value, sanitize it and save, only if:
165
  //$item_type_name contain $snippet_type (e.g. I don't need to save yasr_MOVIE_* if
166
  //the selected snippet is BOOK)
167
  //$_POST item_type_name isset
168
  //$_POST item_type_name is not empty string
169
+
170
  if(strpos($item_type_name, $snippet_type) !== false) {
171
  if (isset($_POST[$item_type_name])
172
  && $_POST[$item_type_name] !== ''
admin/settings/classes/YasrImportRatingPlugins.php CHANGED
@@ -187,7 +187,7 @@ class YasrImportRatingPlugins {
187
  WHERE pm.meta_key IN ('ratings_average', 'ratings_users')
188
  AND pm.meta_value <> 0
189
  AND pm.post_id = p.ID
190
- GROUP BY pm.post_id ASC
191
  ORDER BY pm.post_id
192
  "
193
  );
@@ -213,7 +213,7 @@ class YasrImportRatingPlugins {
213
  WHERE pm.meta_key IN ('_kksr_avg', '_kksr_casts')
214
  AND pm.meta_value <> 0
215
  AND pm.post_id = p.ID
216
- GROUP BY pm.post_id ASC
217
  ORDER BY pm.post_id
218
  "
219
  );
@@ -263,7 +263,7 @@ class YasrImportRatingPlugins {
263
  WHERE pm.meta_key IN ('mr_rating_results_star_rating', 'mr_rating_results_count_entries')
264
  AND pm.meta_value <> 0
265
  AND pm.post_id = p.ID
266
- GROUP BY pm.post_id ASC
267
  ORDER BY pm.post_id
268
  "
269
  );
187
  WHERE pm.meta_key IN ('ratings_average', 'ratings_users')
188
  AND pm.meta_value <> 0
189
  AND pm.post_id = p.ID
190
+ GROUP BY pm.post_id
191
  ORDER BY pm.post_id
192
  "
193
  );
213
  WHERE pm.meta_key IN ('_kksr_avg', '_kksr_casts')
214
  AND pm.meta_value <> 0
215
  AND pm.post_id = p.ID
216
+ GROUP BY pm.post_id
217
  ORDER BY pm.post_id
218
  "
219
  );
263
  WHERE pm.meta_key IN ('mr_rating_results_star_rating', 'mr_rating_results_count_entries')
264
  AND pm.meta_value <> 0
265
  AND pm.post_id = p.ID
266
+ GROUP BY pm.post_id
267
  ORDER BY pm.post_id
268
  "
269
  );
admin/settings/classes/YasrSettings.php CHANGED
@@ -52,7 +52,8 @@ class YasrSettings {
52
  */
53
  public function generalOptions() {
54
  register_setting(
55
- '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()
 
56
  'yasr_general_options', //The name of an option to sanitize and save.
57
  array($this, 'sanitize')
58
  );
52
  */
53
  public function generalOptions() {
54
  register_setting(
55
+ 'yasr_general_options_group', // A settings group name. Must exist prior to the register_setting call.
56
+ // This must match the group name in settings_fields()
57
  'yasr_general_options', //The name of an option to sanitize and save.
58
  array($this, 'sanitize')
59
  );
admin/yasr-update-functions.php CHANGED
@@ -11,14 +11,13 @@ add_action('plugins_loaded', 'yasr_update_version');
11
  function yasr_update_version() {
12
  //do only in admin
13
  if (is_admin()) {
14
- global $yasr_version_installed;
15
  global $wpdb;
16
  global $yasr_stored_options;
17
 
18
- if ($yasr_version_installed !== false) {
19
 
20
  //remove end 2021
21
- if (version_compare($yasr_version_installed, '2.0.9') === -1) {
22
 
23
  //drop useless multi_set_id on yasr log table
24
  $wpdb->query("ALTER TABLE " . YASR_LOG_TABLE . " DROP multi_set_id");
@@ -53,7 +52,7 @@ function yasr_update_version() {
53
  }
54
 
55
  //remove end 2021
56
- if (version_compare($yasr_version_installed, '2.1.0') === -1) {
57
  $old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
58
 
59
  $sql_import_multiset = $wpdb->get_results(
@@ -88,7 +87,7 @@ function yasr_update_version() {
88
 
89
  //remove end 2021
90
  //this fix a bug of table not created on version 2.0.9 and 2.1.0
91
- if (version_compare($yasr_version_installed, '2.1.1') === -1) {
92
  $multi_set_name_exists = $wpdb->get_var("SELECT COUNT(1) FROM " . YASR_MULTI_SET_NAME_TABLE);
93
 
94
  $multi_set_field_exists = $wpdb->get_var("SELECT COUNT(1) FROM " . YASR_MULTI_SET_FIELDS_TABLE);
@@ -105,7 +104,7 @@ function yasr_update_version() {
105
  * Here is the fix
106
  */
107
 
108
- if ($yasr_version_installed === '2.1.0' || $yasr_version_installed === '2.1.1') {
109
  //First I've to check if the column set_id is auto increment
110
  $column_auto_increment = null;
111
  $sql_check_auto_increment = "
@@ -161,8 +160,8 @@ function yasr_update_version() {
161
  //yasr before 2.1.3 was using JSON_OBJECT to import data.
162
  //This function doesn't works with all servers, and import can fail
163
  //Here I check if no meta exists and try to import it again
164
- if ($yasr_version_installed === '2.0.9' || $yasr_version_installed === '2.1.0'
165
- || $yasr_version_installed === '2.1.1' || $yasr_version_installed === '2.1.2') {
166
 
167
  $sql_meta_multiset = $wpdb->query('SELECT * FROM ' . $wpdb->postmeta .
168
  ' WHERE (meta_key LIKE \'%yasr_multiset_author_votes%\'
@@ -177,13 +176,13 @@ function yasr_update_version() {
177
  }
178
 
179
  //In version 2.4.3 is added a setting to show stars near the post title
180
- if (version_compare($yasr_version_installed, '2.4.3') === -1) {
181
  $yasr_stored_options['stars_title'] = 'no';
182
  update_option('yasr_general_options', $yasr_stored_options);
183
  }
184
 
185
  //In version 2.6.6 %overall_rating% pattern is replaced with %rating%
186
- if (version_compare($yasr_version_installed, '2.6.6') === -1) {
187
  if(array_key_exists('text_before_overall', $yasr_stored_options)) {
188
  $yasr_stored_options['text_before_overall'] =
189
  str_replace('%overall_rating%', '%rating%', $yasr_stored_options['text_before_overall']);
@@ -194,7 +193,7 @@ function yasr_update_version() {
194
 
195
  //In version 2.7.4 option "text_before_stars" is removed.
196
  //if it was set to 0, be sure that text before overall is empty
197
- if (version_compare($yasr_version_installed, '2.7.4') === -1) {
198
  if (array_key_exists('text_before_stars', $yasr_stored_options)) {
199
  if($yasr_stored_options['text_before_stars'] === 0) {
200
  $yasr_stored_options['text_before_overall'] = '';
@@ -208,7 +207,7 @@ function yasr_update_version() {
208
 
209
 
210
  /****** End backward compatibility functions ******/
211
- if ($yasr_version_installed != YASR_VERSION_NUM) {
212
  update_option('yasr-version', YASR_VERSION_NUM);
213
  }
214
 
11
  function yasr_update_version() {
12
  //do only in admin
13
  if (is_admin()) {
 
14
  global $wpdb;
15
  global $yasr_stored_options;
16
 
17
+ if (YASR_VERSION_INSTALLED !== false) {
18
 
19
  //remove end 2021
20
+ if (version_compare(YASR_VERSION_INSTALLED, '2.0.9') === -1) {
21
 
22
  //drop useless multi_set_id on yasr log table
23
  $wpdb->query("ALTER TABLE " . YASR_LOG_TABLE . " DROP multi_set_id");
52
  }
53
 
54
  //remove end 2021
55
+ if (version_compare(YASR_VERSION_INSTALLED, '2.1.0') === -1) {
56
  $old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
57
 
58
  $sql_import_multiset = $wpdb->get_results(
87
 
88
  //remove end 2021
89
  //this fix a bug of table not created on version 2.0.9 and 2.1.0
90
+ if (version_compare(YASR_VERSION_INSTALLED, '2.1.1') === -1) {
91
  $multi_set_name_exists = $wpdb->get_var("SELECT COUNT(1) FROM " . YASR_MULTI_SET_NAME_TABLE);
92
 
93
  $multi_set_field_exists = $wpdb->get_var("SELECT COUNT(1) FROM " . YASR_MULTI_SET_FIELDS_TABLE);
104
  * Here is the fix
105
  */
106
 
107
+ if (YASR_VERSION_INSTALLED === '2.1.0' || YASR_VERSION_INSTALLED === '2.1.1') {
108
  //First I've to check if the column set_id is auto increment
109
  $column_auto_increment = null;
110
  $sql_check_auto_increment = "
160
  //yasr before 2.1.3 was using JSON_OBJECT to import data.
161
  //This function doesn't works with all servers, and import can fail
162
  //Here I check if no meta exists and try to import it again
163
+ if (YASR_VERSION_INSTALLED === '2.0.9' || YASR_VERSION_INSTALLED === '2.1.0'
164
+ || YASR_VERSION_INSTALLED === '2.1.1' || YASR_VERSION_INSTALLED === '2.1.2') {
165
 
166
  $sql_meta_multiset = $wpdb->query('SELECT * FROM ' . $wpdb->postmeta .
167
  ' WHERE (meta_key LIKE \'%yasr_multiset_author_votes%\'
176
  }
177
 
178
  //In version 2.4.3 is added a setting to show stars near the post title
179
+ if (version_compare(YASR_VERSION_INSTALLED, '2.4.3') === -1) {
180
  $yasr_stored_options['stars_title'] = 'no';
181
  update_option('yasr_general_options', $yasr_stored_options);
182
  }
183
 
184
  //In version 2.6.6 %overall_rating% pattern is replaced with %rating%
185
+ if (version_compare(YASR_VERSION_INSTALLED, '2.6.6') === -1) {
186
  if(array_key_exists('text_before_overall', $yasr_stored_options)) {
187
  $yasr_stored_options['text_before_overall'] =
188
  str_replace('%overall_rating%', '%rating%', $yasr_stored_options['text_before_overall']);
193
 
194
  //In version 2.7.4 option "text_before_stars" is removed.
195
  //if it was set to 0, be sure that text before overall is empty
196
+ if (version_compare(YASR_VERSION_INSTALLED, '2.7.4') === -1) {
197
  if (array_key_exists('text_before_stars', $yasr_stored_options)) {
198
  if($yasr_stored_options['text_before_stars'] === 0) {
199
  $yasr_stored_options['text_before_overall'] = '';
207
 
208
 
209
  /****** End backward compatibility functions ******/
210
+ if (YASR_VERSION_INSTALLED !== YASR_VERSION_NUM) {
211
  update_option('yasr-version', YASR_VERSION_NUM);
212
  }
213
 
includes/shortcodes/classes/YasrMultiSet.php CHANGED
@@ -48,6 +48,8 @@ class YasrMultiSet extends YasrShortcode {
48
  $this->shortcode_html .= "</table>";
49
  $this->shortcode_html .= '<!--End Yasr Multi Set Shortcode-->';
50
 
 
 
51
  return $this->shortcode_html;
52
  }
53
 
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
  }
55
 
includes/shortcodes/classes/YasrNoStarsRankings.php CHANGED
@@ -45,6 +45,8 @@ class YasrNoStarsRankings extends YasrShortcode {
45
 
46
  $this->shortcode_html .= '<!-- Yasr '.$this->shortcode_name.' Shortcode-->';
47
 
 
 
48
  return $this->shortcode_html;
49
 
50
  }
45
 
46
  $this->shortcode_html .= '<!-- Yasr '.$this->shortcode_name.' Shortcode-->';
47
 
48
+ $this->enqueueRankingScript();
49
+
50
  return $this->shortcode_html;
51
 
52
  }
includes/shortcodes/classes/YasrOverallRating.php CHANGED
@@ -34,35 +34,29 @@ class YasrOverallRating extends YasrShortcode {
34
  /**
35
  * This is called when shortcode is used
36
  *
37
- * @return string|null
38
  */
39
  public function returnShortcode () {
40
-
41
  $overall_attributes = $this->returnAttributes();
42
 
43
- $this->shortcode_html = '<!--Yasr Overall Rating Shortcode-->';
44
 
45
- $this->shortcode_html .= $this->customTextBefore();
46
 
47
- $this->shortcode_html .= '<div class="yasr-overall-rating">';
48
- $this->shortcode_html .= $overall_attributes['html_stars'];
49
- $this->shortcode_html .= '</div>';
50
 
51
- $this->shortcode_html .= '<!--End Yasr Overall Rating Shortcode-->';
52
 
53
  //Use this filter to customize overall rating
54
- $this->shortcode_html = apply_filters('yasr_overall_rating_shortcode', $this->shortcode_html, $overall_attributes);
55
 
56
- //If overall rating in loop is enabled don't use is_singular && is main_query
57
- if (YASR_SHOW_OVERALL_IN_LOOP === 'enabled') {
58
- return $this->shortcode_html;
59
- } //default
60
 
61
- if (is_singular() && is_main_query()) {
62
- return $this->shortcode_html;
63
- }
64
 
65
- return null;
66
  }
67
 
68
  /**
@@ -79,7 +73,6 @@ class YasrOverallRating extends YasrShortcode {
79
  * );
80
  */
81
  public function returnAttributes($stars_size=false, $post_id=false, $class=false, $rating=false) {
82
-
83
  if(!is_int($stars_size)) {
84
  $stars_size = $this->starSize();
85
  }
@@ -111,14 +104,12 @@ class YasrOverallRating extends YasrShortcode {
111
  data-rater-starsize='$stars_size'>
112
  </div>";
113
 
114
- $array_to_return = array(
115
  'overall_rating' => $overall_rating,
116
  'post_id' => $post_id,
117
  'html_stars' => $html_stars
118
  );
119
 
120
- return $array_to_return;
121
-
122
  }
123
 
124
  /**
@@ -130,14 +121,26 @@ class YasrOverallRating extends YasrShortcode {
130
  *
131
  */
132
  protected function customTextBefore() {
133
- //Get overall Rating
134
- $this->overall_rating = YasrDatabaseRatings::getOverallRating();
135
- $text_before_star = apply_filters('yasr_cstm_text_before_overall', $this->overall_rating);
136
 
137
- return "<div class='yasr-container-custom-text-and-overall'>
138
- <span id='yasr-custom-text-before-overall'>".htmlspecialchars_decode($text_before_star )."</span>
139
- </div>";
140
 
141
  }
142
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
34
  /**
35
  * This is called when shortcode is used
36
  *
37
+ * @return string
38
  */
39
  public function returnShortcode () {
 
40
  $overall_attributes = $this->returnAttributes();
41
 
42
+ $shortcode_html = '<!--Yasr Overall Rating Shortcode-->';
43
 
44
+ $shortcode_html .= $this->customTextBefore();
45
 
46
+ $shortcode_html .= '<div class="yasr-overall-rating">';
47
+ $shortcode_html .= $overall_attributes['html_stars'];
48
+ $shortcode_html .= '</div>';
49
 
50
+ $shortcode_html .= '<!--End Yasr Overall Rating Shortcode-->';
51
 
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
  }
61
 
62
  /**
73
  * );
74
  */
75
  public function returnAttributes($stars_size=false, $post_id=false, $class=false, $rating=false) {
 
76
  if(!is_int($stars_size)) {
77
  $stars_size = $this->starSize();
78
  }
104
  data-rater-starsize='$stars_size'>
105
  </div>";
106
 
107
+ return array(
108
  'overall_rating' => $overall_rating,
109
  'post_id' => $post_id,
110
  'html_stars' => $html_stars
111
  );
112
 
 
 
113
  }
114
 
115
  /**
121
  *
122
  */
123
  protected function customTextBefore() {
124
+ //Get overall Rating
125
+ $this->overall_rating = YasrDatabaseRatings::getOverallRating();
126
+ $text_before_star = apply_filters('yasr_cstm_text_before_overall', $this->overall_rating);
127
 
128
+ return "<div class='yasr-container-custom-text-and-overall'>
129
+ <span id='yasr-custom-text-before-overall'>".htmlspecialchars_decode($text_before_star )."</span>
130
+ </div>";
131
 
132
  }
133
 
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
+
146
  }
includes/shortcodes/classes/YasrRankings.php CHANGED
@@ -56,6 +56,8 @@ class YasrRankings extends YasrShortcode {
56
  $this->returnSingleTableRanking($this->urlencodeAtts($sql_atts));
57
  $this->shortcode_html .= '<!--End Yasr Top 10 highest Rated Shortcode-->';
58
 
 
 
59
  return $this->shortcode_html;
60
  }
61
 
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
  }
63
 
includes/shortcodes/classes/YasrShortcode.php CHANGED
@@ -81,33 +81,48 @@ abstract class YasrShortcode
81
  {
82
  //scripts required for all shortocdes
83
  yasr_enqueue_includes_js_scripts();
84
- $called_class = static::class;
85
- if ( $called_class === 'YasrOverallRating' || $called_class === 'YasrMultiSet' || $called_class === 'YasrVisitorMultiSet' ) {
86
- wp_enqueue_script(
87
- 'yasr-ov-multi',
88
- YASR_JS_DIR_INCLUDES . 'shortcodes/overall-multiset.js',
89
- array( 'jquery', 'rater', 'wp-i18n' ),
90
- YASR_VERSION_NUM,
91
- true
92
- );
93
- }
94
- if ( $called_class === 'YasrRankings' || $called_class === 'YasrNoStarsRankings' ) {
95
- wp_enqueue_script(
96
- 'yasr-rankings',
97
- YASR_JS_DIR_INCLUDES . 'shortcodes/rankings.js',
98
- array(
99
- 'jquery',
100
- 'rater',
101
- 'wp-i18n',
102
- 'wp-element'
103
- ),
104
- YASR_VERSION_NUM,
105
- true
106
- );
107
- }
108
  do_action( 'yasr_enqueue_assets_shortcode' );
109
  }
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  /**
112
  * Return the stars size according to size attribute in shortcode.
113
  * If not used, return 32 (default value)
81
  {
82
  //scripts required for all shortocdes
83
  yasr_enqueue_includes_js_scripts();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  do_action( 'yasr_enqueue_assets_shortcode' );
85
  }
86
 
87
+ /***
88
+ * This function is called by all the shortcodes that works in read only and in multiset
89
+ *
90
+ * @author Dario Curvino <@dudo>
91
+ * @since 2.8.8
92
+ */
93
+ public function enqueueReadonlyAndMultisetScript()
94
+ {
95
+ wp_enqueue_script(
96
+ 'yasr-ov-multi',
97
+ YASR_JS_DIR_INCLUDES . 'shortcodes/overall-multiset.js',
98
+ array( 'jquery', 'rater', 'wp-i18n' ),
99
+ YASR_VERSION_NUM,
100
+ true
101
+ );
102
+ }
103
+
104
+ /**
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',
114
+ YASR_JS_DIR_INCLUDES . 'shortcodes/rankings.js',
115
+ array(
116
+ 'jquery',
117
+ 'rater',
118
+ 'wp-i18n',
119
+ 'wp-element'
120
+ ),
121
+ YASR_VERSION_NUM,
122
+ true
123
+ );
124
+ }
125
+
126
  /**
127
  * Return the stars size according to size attribute in shortcode.
128
  * If not used, return 32 (default value)
includes/shortcodes/classes/YasrVisitorMultiSet.php CHANGED
@@ -99,6 +99,8 @@ class YasrVisitorMultiSet extends YasrMultiSet {
99
  $this->shortcode_html .= "</table>";
100
  $this->shortcode_html .= '<!-- End Yasr Multi Set Visitor Shortcode-->';
101
 
 
 
102
  return $this->shortcode_html;
103
  }
104
 
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
  }
106
 
includes/shortcodes/classes/YasrVisitorVotes.php CHANGED
@@ -41,14 +41,10 @@ class YasrVisitorVotes extends YasrShortcode {
41
  $this->is_singular = 'false';
42
  }
43
 
44
- $this->unique_id = str_shuffle(uniqid());
45
  $this->ajax_nonce_visitor = wp_create_nonce("yasr_nonce_vv");
46
 
47
- $this->shortcode_html = '<!--Yasr Visitor Votes Shortcode-->';
48
- $this->shortcode_html .= "<div id='yasr_visitor_votes_$this->post_id' class='yasr-visitor-votes'>";
49
-
50
  $this->tippy_loaded = false;
51
-
52
  }
53
 
54
  /**
@@ -57,10 +53,9 @@ class YasrVisitorVotes extends YasrShortcode {
57
  * @return string|null
58
  */
59
  public function returnShortcode() {
60
- //returns int
61
- $stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id);
62
-
63
  $number_of_votes = $stored_votes['number_of_votes'];
 
64
  if ($number_of_votes > 0) {
65
  $average_rating = $stored_votes['sum_votes']/$number_of_votes;
66
  } else {
@@ -69,12 +64,14 @@ class YasrVisitorVotes extends YasrShortcode {
69
 
70
  $average_rating=round($average_rating, 1);
71
 
 
 
72
  //if this come from yasr_visitor_votes_readonly...
73
  if ($this->readonly === 'true' || $this->readonly === "yes") {
74
  return $this->readonlyShortcode($average_rating, $stored_votes);
75
  }
76
 
77
- $cookie_value = self::checkCookie($this->post_id);
78
  $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
79
 
80
  if($stars_enabled === 'true_logged' || $stars_enabled === 'true_not_logged') {
@@ -83,29 +80,7 @@ class YasrVisitorVotes extends YasrShortcode {
83
  $this->readonly = 'true';
84
  }
85
 
86
- $this->shortcode_html .= $this->textBeforeStars($number_of_votes, $average_rating);
87
-
88
- $this->shortcode_html .= "<div id='yasr-vv-second-row-container-$this->unique_id'
89
- class='yasr-vv-second-row-container'>";
90
-
91
- $stars_htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
92
- $this->shortcode_html .= "<div id='$stars_htmlid'
93
- class='yasr-rater-stars-vv'
94
- data-rater-postid='$this->post_id'
95
- data-rating='$average_rating'
96
- data-rater-starsize='".$this->starSize()."'
97
- data-rater-readonly='$this->readonly'
98
- data-rater-nonce='$this->ajax_nonce_visitor'
99
- data-issingular='$this->is_singular'
100
- ></div>";
101
-
102
- $this->shortcode_html .= $this->containerAfterStars($number_of_votes, $average_rating);
103
- //loader div
104
- $this->shortcode_html .= "<div id='yasr-vv-loader-$this->unique_id' class='yasr-vv-container-loader'></div>";
105
- $this->shortcode_html .= '</div>'; //close yasr-vv-stars-stats-container
106
- $this->shortcode_html = apply_filters('yasr_vv_shortcode', $this->shortcode_html, $stored_votes);
107
-
108
- return $this->returnYasrVisitorVotes($cookie_value, $this->post_id);
109
 
110
  } //end function
111
 
@@ -164,7 +139,7 @@ class YasrVisitorVotes extends YasrShortcode {
164
 
165
  $htmlid = 'yasr-visitor-votes-readonly-rater-'.$this->unique_id;
166
 
167
- $stars = "<div class='yasr-rater-stars-vv'
168
  id='$htmlid'
169
  data-rating='$average_rating'
170
  data-rater-starsize='".$this->starSize()."'
@@ -178,7 +153,7 @@ class YasrVisitorVotes extends YasrShortcode {
178
 
179
  $shortcode_html = $container . $stars . $end_container;
180
 
181
- $this->loadVVScripts();
182
 
183
  //Use this filter to customize yasr_visitor_votes readonly
184
  return apply_filters('yasr_vv_ro_shortcode', $shortcode_html, $stored_votes);
@@ -243,7 +218,7 @@ class YasrVisitorVotes extends YasrShortcode {
243
  */
244
  public static function showTextBelowStars ($cookie_value, $post_id=false) {
245
 
246
- $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
247
  $div_bottom_line = false;
248
  $span_bottom_line_content = false;
249
 
@@ -308,9 +283,8 @@ class YasrVisitorVotes extends YasrShortcode {
308
  protected function textBeforeStars($number_of_votes, $average_rating) {
309
  $custom_text_before_star = apply_filters('yasr_cstm_text_before_vv', $number_of_votes, $average_rating, $this->unique_id);
310
 
311
- $class_text_before = 'yasr-custom-text-vv-before yasr-custom-text-vv-before-'.$this->post_id;
312
 
313
- //if filters doesn't exists, put $shortcode_html inside $this->shortcode_html
314
  return '<div class="'.$class_text_before.'">'
315
  . wp_kses_post($custom_text_before_star) .
316
  '</div>';
@@ -325,7 +299,7 @@ class YasrVisitorVotes extends YasrShortcode {
325
  * @param $number_of_votes
326
  * @param $average_rating
327
  *
328
- * @return mixed|void $span_text_after_stars
329
  */
330
  public function containerAfterStars ($number_of_votes, $average_rating) {
331
  $container_div = '<div class="yasr-vv-stats-text-container" id="yasr-vv-stats-text-container-'. $this->unique_id .'">';
@@ -356,55 +330,114 @@ class YasrVisitorVotes extends YasrShortcode {
356
  }
357
 
358
 
359
-
360
-
361
  /**
362
- * This function will return the html code for the dashicons
363
  *
364
  * @param void
365
  *
366
  * @return string
367
  */
368
  public function visitorStats () {
369
- global $yasr_plugin_imported;
 
 
 
 
 
 
 
 
 
 
 
370
 
371
- $span_dashicon = '<svg xmlns="https://www.w3.org/2000/svg" width="20" height="20"
372
- class="yasr-dashicons-visitor-stats"
373
- data-postid="'.$this->post_id.'"
374
- id="yasr-stats-dashicon-'.$this->unique_id.'">
375
- <path d="M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z"></path>
376
- </svg>';
377
 
378
- if (is_array($yasr_plugin_imported)) {
 
 
 
 
 
 
 
 
 
379
  $plugin_import_date = null; //avoid undefined
380
- if (array_key_exists('wppr', $yasr_plugin_imported)) {
381
- $plugin_import_date = $yasr_plugin_imported['wppr']['date'];
382
  }
383
 
384
- if (array_key_exists('kksr', $yasr_plugin_imported)) {
385
- $plugin_import_date = $yasr_plugin_imported['kksr']['date'];
386
  }
387
 
388
- if (array_key_exists('mr', $yasr_plugin_imported)) {
389
- $plugin_import_date = $yasr_plugin_imported['mr']['date'];
390
  }
391
 
392
  //remove hour from date
393
  $plugin_import_date=strtok($plugin_import_date,' ');
394
-
395
  $post_date = get_the_date('Y-m-d', $this->post_id);
396
 
397
- //if one of these plugin has been imported and post is older then import, hide stats
398
- if ($post_date < $plugin_import_date) {
399
- $span_dashicon = "";
400
- }
401
- } //End if $yasr_plugin_imported
402
 
403
- if($span_dashicon !== '') {
404
- $this->loadTippy();
405
- }
406
 
407
- return $span_dashicon;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  }
409
 
410
  /**
@@ -415,24 +448,32 @@ class YasrVisitorVotes extends YasrShortcode {
415
  *
416
  * @return string
417
  */
418
- protected function returnYasrVisitorVotes ($cookie_value, $post_id) {
419
  if(YASR_ENABLE_AJAX === 'yes') {
420
- $container= "<div id='yasr-vv-bottom-container-$this->unique_id'
421
  class='yasr-vv-bottom-container'
422
  style='display:none'>";
423
  } else {
424
  $container = "<div id='yasr-vv-bottom-container-$this->unique_id' class='yasr-vv-bottom-container'>";
425
  }
426
 
427
- $this->shortcode_html .= $container;
428
- $this->shortcode_html .= self::showTextBelowStars($cookie_value, $post_id);
429
- $this->shortcode_html .= '</div>'; //close bottom container
430
-
431
- $this->shortcode_html .= '</div>'; //close all
432
- $this->shortcode_html .= '<!--End Yasr Visitor Votes Shortcode-->';
433
 
434
- $this->loadVVScripts();
 
 
 
 
 
 
 
 
 
 
435
 
436
- return $this->shortcode_html;
 
437
  }
438
  }
41
  $this->is_singular = 'false';
42
  }
43
 
44
+ $this->unique_id = str_shuffle(uniqid());
45
  $this->ajax_nonce_visitor = wp_create_nonce("yasr_nonce_vv");
46
 
 
 
 
47
  $this->tippy_loaded = false;
 
48
  }
49
 
50
  /**
53
  * @return string|null
54
  */
55
  public function returnShortcode() {
56
+ $stored_votes = YasrDatabaseRatings::getVisitorVotes($this->post_id);
 
 
57
  $number_of_votes = $stored_votes['number_of_votes'];
58
+
59
  if ($number_of_votes > 0) {
60
  $average_rating = $stored_votes['sum_votes']/$number_of_votes;
61
  } else {
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") {
71
  return $this->readonlyShortcode($average_rating, $stored_votes);
72
  }
73
 
74
+ $cookie_value = self::checkCookie($this->post_id);
75
  $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
76
 
77
  if($stars_enabled === 'true_logged' || $stars_enabled === 'true_not_logged') {
80
  $this->readonly = 'true';
81
  }
82
 
83
+ return $this->returnYasrVisitorVotes($stored_votes, $number_of_votes, $average_rating, $cookie_value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  } //end function
86
 
139
 
140
  $htmlid = 'yasr-visitor-votes-readonly-rater-'.$this->unique_id;
141
 
142
+ $stars = "<div class='yasr-rater-stars'
143
  id='$htmlid'
144
  data-rating='$average_rating'
145
  data-rater-starsize='".$this->starSize()."'
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);
218
  */
219
  public static function showTextBelowStars ($cookie_value, $post_id=false) {
220
 
221
+ $stars_enabled = YasrShortcode::starsEnalbed($cookie_value);
222
  $div_bottom_line = false;
223
  $span_bottom_line_content = false;
224
 
283
  protected function textBeforeStars($number_of_votes, $average_rating) {
284
  $custom_text_before_star = apply_filters('yasr_cstm_text_before_vv', $number_of_votes, $average_rating, $this->unique_id);
285
 
286
+ $class_text_before = 'yasr-custom-text-vv-before yasr-custom-text-vv-before-'.$this->post_id;
287
 
 
288
  return '<div class="'.$class_text_before.'">'
289
  . wp_kses_post($custom_text_before_star) .
290
  '</div>';
299
  * @param $number_of_votes
300
  * @param $average_rating
301
  *
302
+ * @return string $span_text_after_stars
303
  */
304
  public function containerAfterStars ($number_of_votes, $average_rating) {
305
  $container_div = '<div class="yasr-vv-stats-text-container" id="yasr-vv-stats-text-container-'. $this->unique_id .'">';
330
  }
331
 
332
 
 
 
333
  /**
334
+ * This function will return the html code for the stat icon
335
  *
336
  * @param void
337
  *
338
  * @return string
339
  */
340
  public function visitorStats () {
341
+ if ($this->externalPluginImported()) {
342
+ $stat_icon = '';
343
+ }
344
+ else {
345
+ $stat_icon = '<svg xmlns="https://www.w3.org/2000/svg" width="20" height="20"
346
+ class="yasr-dashicons-visitor-stats"
347
+ data-postid="'.$this->post_id.'"
348
+ id="yasr-stats-dashicon-'.$this->unique_id.'">
349
+ <path d="M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z"></path>
350
+ </svg>';
351
+ $this->loadTippy();
352
+ }
353
 
354
+ return $stat_icon;
355
+ }
 
 
 
 
356
 
357
+ /**
358
+ * Check if an external plugin was imported, and if the date of the import is prior of post date,
359
+ * return true
360
+ *
361
+ * @author Dario Curvino <@dudo>
362
+ * @since 2.8.8
363
+ * @return bool
364
+ */
365
+ protected function externalPluginImported () {
366
+ if (YASR_PLUGIN_IMPORTED !== false && is_array(YASR_PLUGIN_IMPORTED)) {
367
  $plugin_import_date = null; //avoid undefined
368
+ if (array_key_exists('wppr', YASR_PLUGIN_IMPORTED)) {
369
+ $plugin_import_date = YASR_PLUGIN_IMPORTED['wppr']['date'];
370
  }
371
 
372
+ if (array_key_exists('kksr', YASR_PLUGIN_IMPORTED)) {
373
+ $plugin_import_date = YASR_PLUGIN_IMPORTED['kksr']['date'];
374
  }
375
 
376
+ if (array_key_exists('mr', YASR_PLUGIN_IMPORTED)) {
377
+ $plugin_import_date = YASR_PLUGIN_IMPORTED['mr']['date'];
378
  }
379
 
380
  //remove hour from date
381
  $plugin_import_date=strtok($plugin_import_date,' ');
 
382
  $post_date = get_the_date('Y-m-d', $this->post_id);
383
 
384
+ //return true if post_date is < plugin_import_date, return false otherwise
385
+ return $post_date < $plugin_import_date;
386
+ } //End if YASR_PLUGIN_IMPORTED
 
 
387
 
388
+ return false;
389
+ }
 
390
 
391
+ /***
392
+ *
393
+ *
394
+ * @author Dario Curvino <@dudo>
395
+ * @since 2.8.8
396
+ * @param $stored_votes
397
+ * @param $number_of_votes
398
+ * @param $average_rating
399
+ * @param $cookie_value
400
+ *
401
+ * @return string
402
+ */
403
+ protected function returnYasrVisitorVotes ($stored_votes, $number_of_votes, $average_rating, $cookie_value) {
404
+ $stars_htmlid = 'yasr-visitor-votes-rater-' . $this->unique_id ;
405
+
406
+ $shortcode_html = '<!--Yasr Visitor Votes Shortcode-->';
407
+ $shortcode_html .= "<div id='yasr_visitor_votes_$this->post_id' class='yasr-visitor-votes'>";
408
+
409
+ $shortcode_html .= $this->textBeforeStars($number_of_votes, $average_rating);
410
+ $shortcode_html .= "<div id='yasr-vv-second-row-container-$this->unique_id'
411
+ class='yasr-vv-second-row-container'>";
412
+
413
+ $shortcode_html .= "<div id='$stars_htmlid'
414
+ class='yasr-rater-stars-vv'
415
+ data-rater-postid='$this->post_id'
416
+ data-rating='$average_rating'
417
+ data-rater-starsize='".$this->starSize()."'
418
+ data-rater-readonly='$this->readonly'
419
+ data-rater-nonce='$this->ajax_nonce_visitor'
420
+ data-issingular='$this->is_singular'
421
+ ></div>";
422
+
423
+ $shortcode_html .= $this->containerAfterStars($number_of_votes, $average_rating);
424
+
425
+ //loader div
426
+ $shortcode_html .= "<div id='yasr-vv-loader-$this->unique_id' class='yasr-vv-container-loader'></div>";
427
+
428
+ //close yasr-vv-second-row-container-$this->unique_id'
429
+ $shortcode_html .= '</div>';
430
+
431
+ $shortcode_html = apply_filters('yasr_vv_shortcode', $shortcode_html, $stored_votes);
432
+
433
+ $shortcode_html .= $this->bottomContainer($cookie_value, $this->post_id);
434
+
435
+ $shortcode_html .= '</div>'; //close all
436
+ $shortcode_html .= '<!--End Yasr Visitor Votes Shortcode-->';
437
+
438
+ $this->loadVVScripts();
439
+
440
+ return $shortcode_html;
441
  }
442
 
443
  /**
448
  *
449
  * @return string
450
  */
451
+ protected function bottomContainer ($cookie_value, $post_id) {
452
  if(YASR_ENABLE_AJAX === 'yes') {
453
+ $container = "<div id='yasr-vv-bottom-container-$this->unique_id'
454
  class='yasr-vv-bottom-container'
455
  style='display:none'>";
456
  } else {
457
  $container = "<div id='yasr-vv-bottom-container-$this->unique_id' class='yasr-vv-bottom-container'>";
458
  }
459
 
460
+ //return bottom container
461
+ return $container.self::showTextBelowStars($cookie_value, $post_id).'</div>';
462
+ }
 
 
 
463
 
464
+ /**
465
+ * @author Dario Curvino <@dudo>
466
+ * @since 2.8.8
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
  }
479
  }
public/classes/YasrRichSnippets.php CHANGED
@@ -10,7 +10,8 @@
10
  class YasrRichSnippets {
11
 
12
  public function addFilters() {
13
- add_filter('the_content', array($this, 'addSchema'));
 
14
  add_filter('yasr_filter_schema_title', array($this, 'filter_title'));
15
  add_filter('yasr_filter_existing_schema', array($this, 'additional_schema'), 10, 2);
16
  }
@@ -21,6 +22,11 @@ class YasrRichSnippets {
21
  * @return string
22
  */
23
  public function addSchema($content) {
 
 
 
 
 
24
  //Add buddypress compatibility
25
  //If this is a page, return $content without adding schema.
26
  if (function_exists('bp_is_active') && is_page()) {
@@ -31,17 +37,21 @@ class YasrRichSnippets {
31
  return $content;
32
  }
33
 
34
- $post_id = get_the_ID();
35
- $overall_rating = YasrDatabaseRatings::getOverallRating();
36
- $visitor_votes = YasrDatabaseRatings::getVisitorVotes();
37
 
38
- if (!$overall_rating && !$visitor_votes['number_of_votes'] && !$visitor_votes['sum_votes']) {
39
- return $content;
 
 
 
 
 
40
  }
41
 
42
- //can't be between 0.1 and 1
43
- if ($overall_rating > 0 && $overall_rating < 1) {
44
- $overall_rating = 1;
 
45
  }
46
 
47
  $script_type = '<script type="application/ld+json">';
@@ -59,8 +69,8 @@ class YasrRichSnippets {
59
  return $content . $script_type . $filtered_schema . $end_script_type;
60
  }
61
 
62
- //YASR adds microdata only if is_singular() && is_main_query() && !is_404()
63
- if (is_singular() && is_main_query() && !is_404()) {
64
  $rich_snippet = $this->returnRichSnippets($post_id, $review_choosen, $content, $overall_rating, $visitor_votes);
65
 
66
  return $content . $script_type . json_encode($rich_snippet) . $end_script_type;
10
  class YasrRichSnippets {
11
 
12
  public function addFilters() {
13
+ //Low priority to be sure that shortcodes has run
14
+ add_filter('the_content', array($this, 'addSchema'), 99);
15
  add_filter('yasr_filter_schema_title', array($this, 'filter_title'));
16
  add_filter('yasr_filter_existing_schema', array($this, 'additional_schema'), 10, 2);
17
  }
22
  * @return string
23
  */
24
  public function addSchema($content) {
25
+ //if both shortcodes ov_rating and visitor votes didn't run, return $content
26
+ if (!defined('YASR_OV_ATTRIBUTES') && !defined('YASR_VV_ATTRIBUTES')) {
27
+ return $content;
28
+ }
29
+
30
  //Add buddypress compatibility
31
  //If this is a page, return $content without adding schema.
32
  if (function_exists('bp_is_active') && is_page()) {
37
  return $content;
38
  }
39
 
40
+ $post_id = get_the_ID();
 
 
41
 
42
+ $overall_rating = false;
43
+ $visitor_votes = false;
44
+
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">';
69
  return $content . $script_type . $filtered_schema . $end_script_type;
70
  }
71
 
72
+ //YASR adds microdata only if is_singular() && is_main_query()
73
+ if (is_singular() && is_main_query()) {
74
  $rich_snippet = $this->returnRichSnippets($post_id, $review_choosen, $content, $overall_rating, $visitor_votes);
75
 
76
  return $content . $script_type . json_encode($rich_snippet) . $end_script_type;
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.7
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
@@ -197,10 +197,17 @@ 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.7 =
201
- * FIXED: litespeed compatibility
202
  * TWEAKED: added a check to improve compatibility with external plugins
203
  * TWEAKED: removed old and useless languages files: only three were left to use as example
 
204
 
205
  = 2.8.6 =
206
  * FIXED: Missing dependency for rankings shortcodes
@@ -223,11 +230,9 @@ WordPress version 5.6
223
  * FIXED: link to trial page
224
  * TWEAKED: added some hooks
225
 
226
-
227
  = 2.8.2 =
228
  * FIXED: if "Enable stars next to the title?" is activated, the ratings also appears in rss feed.
229
 
230
-
231
  = 2.8.1 =
232
  * FIXED: error that could occurs in some circumstances
233
 
@@ -242,7 +247,6 @@ a php warning is returned
242
  = 2.7.9 =
243
  * FIXED: missing stats in some circumstances for yasr_visitor_votes shortcode
244
 
245
-
246
  = 2.7.8 =
247
  * FIXED: error when "Load results with AJAX?" is enabled, and the attribute "readonly" is set to yasr_visitor_votes shortcode
248
  * TWEAKED: css minor changes
@@ -276,11 +280,9 @@ The class yasr-total-average-container has be renamed yasr-vv-stats-text-contain
276
  * NEW FEATURE: new shortcode: yasr_visitor_multi_set_ranking : this will show rankings from yasr_visitor_multiset
277
  * TWEAKED: minor fixes
278
 
279
-
280
  = 2.7.1 =
281
  * FIXED: minor bugs that could happen in rare circumstances
282
 
283
-
284
  = 2.7.0 =
285
  * FIXED: fixed warning that can return on fresh installations
286
 
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
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
203
+ * FIXED: removed duplicated query
204
+ * FIXED: Import functions from external plugins is now compatible with mysql8
205
+ * FIXED: itemTypename didn't get saved into Rich snippet options above the editor
206
+
207
  = 2.8.7 =
 
208
  * TWEAKED: added a check to improve compatibility with external plugins
209
  * TWEAKED: removed old and useless languages files: only three were left to use as example
210
+ * FIXED: litespeed compatibility
211
 
212
  = 2.8.6 =
213
  * FIXED: Missing dependency for rankings shortcodes
230
  * FIXED: link to trial page
231
  * TWEAKED: added some hooks
232
 
 
233
  = 2.8.2 =
234
  * FIXED: if "Enable stars next to the title?" is activated, the ratings also appears in rss feed.
235
 
 
236
  = 2.8.1 =
237
  * FIXED: error that could occurs in some circumstances
238
 
247
  = 2.7.9 =
248
  * FIXED: missing stats in some circumstances for yasr_visitor_votes shortcode
249
 
 
250
  = 2.7.8 =
251
  * FIXED: error when "Load results with AJAX?" is enabled, and the attribute "readonly" is set to yasr_visitor_votes shortcode
252
  * TWEAKED: css minor changes
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
 
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.7
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.7' );
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__ );
@@ -118,17 +118,14 @@ if ( !function_exists( 'yasr_fs' ) ) {
118
  if ( !defined( 'YASR_USER_CAPABILITY_EDIT_POST' ) ) {
119
  define( 'YASR_USER_CAPABILITY_EDIT_POST', 'edit_posts' );
120
  }
121
- $yasr_version_installed = get_option( 'yasr-version' );
122
- global $yasr_version_installed ;
123
- $yasr_plugin_imported = get_option( 'yasr_plugin_imported' );
124
- global $yasr_plugin_imported ;
125
  //Run this only on plugin activation (doesn't work on update)
126
  register_activation_hook( __FILE__, 'yasr_on_activation' );
127
  function yasr_on_activation( $network_wide )
128
  {
129
- global $yasr_version_installed ;
130
  //If this is a fresh new installation
131
- if ( !$yasr_version_installed ) {
132
  new YasrOnInstall( $network_wide );
133
  }
134
  }
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
  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__ );
118
  if ( !defined( 'YASR_USER_CAPABILITY_EDIT_POST' ) ) {
119
  define( 'YASR_USER_CAPABILITY_EDIT_POST', 'edit_posts' );
120
  }
121
+ define( 'YASR_VERSION_INSTALLED', get_option( 'yasr-version' ) );
122
+ define( 'YASR_PLUGIN_IMPORTED', get_option( 'yasr_plugin_imported' ) );
 
 
123
  //Run this only on plugin activation (doesn't work on update)
124
  register_activation_hook( __FILE__, 'yasr_on_activation' );
125
  function yasr_on_activation( $network_wide )
126
  {
 
127
  //If this is a fresh new installation
128
+ if ( !YASR_VERSION_INSTALLED ) {
129
  new YasrOnInstall( $network_wide );
130
  }
131
  }