Yasr – Yet Another Stars Rating - Version 2.2.5

Version Description

  • FIXED: bug if upgrading from version before than 2.0.9
Download this release

Release Info

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

Code changes from version 2.2.4 to 2.2.5

lib/admin/yasr-update-functions.php CHANGED
@@ -62,7 +62,7 @@ function yasr_update_version() {
62
 
63
  dbDelta($sql_yasr_log_multi_set_table);
64
 
65
- import_multiset_author();
66
 
67
  }
68
 
@@ -186,22 +186,30 @@ function yasr_update_version() {
186
 
187
  //if no meta are found, try to import data again
188
  if ($sql_meta_multiset === 0) {
189
- import_multiset_author();
190
  }
191
 
192
  }
193
 
194
  } //Endif yasr_version_installed !== false
195
 
 
 
 
 
196
 
197
- function import_multiset_author () {
198
 
199
- global $wpdb;
200
 
201
- $old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
202
 
203
- $sql_import_author_multiset = $wpdb->get_results(
204
- "SELECT post_id, set_type AS set_id,
 
 
 
 
205
  CONCAT(
206
  '[',
207
  GROUP_CONCAT(
@@ -220,52 +228,43 @@ function yasr_update_version() {
220
  )
221
  GROUP BY post_id, set_type
222
  ORDER BY post_id, set_type", ARRAY_A
223
- );
224
 
225
- if(!empty($sql_import_author_multiset)) {
226
- //just the same code used in yasr_save_multiset_editor
227
- $i = 0;
228
- foreach ($sql_import_author_multiset as $multiset_ratings) {
229
 
230
- $post_id = $multiset_ratings['post_id'];
231
- $set_id = (int)$multiset_ratings['set_id'];
232
- $field_and_vote_array = json_decode($multiset_ratings['fields_and_ratings']);
233
 
234
- //convert in a object with json_decode
235
- $data_to_save[$i] = array(
236
- 'set_id' => $set_id,
237
- 'fields_and_ratings' => $field_and_vote_array
238
- );
239
 
240
- $set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes',true);
241
 
242
- if ($set_post_meta_values) {
243
- //first, loop saved fields and ratings
244
- foreach ($set_post_meta_values as $saved_set) {
245
- //if the saved set is different from the one that we're trying to save,
246
- //append data to save to the post meta
247
- if ($saved_set['set_id'] !== $set_id) {
248
- //increment i
249
- $i++;
250
- $data_to_save[$i]['set_id'] = $saved_set['set_id'];
251
- $data_to_save[$i]['fields_and_ratings'] = $saved_set['fields_and_ratings'];
252
 
253
- }
254
- }
255
  }
256
- update_post_meta($multiset_ratings['post_id'], 'yasr_multiset_author_votes', $data_to_save);
257
- //empty array
258
- $data_to_save = array();
259
  }
260
-
261
  }
262
- }
263
-
264
- /****** End backward compatibility functions ******/
265
- if ($yasr_version_installed != YASR_VERSION_NUM) {
266
- update_option('yasr-version', YASR_VERSION_NUM);
267
  }
268
 
269
  }
270
-
271
  }
62
 
63
  dbDelta($sql_yasr_log_multi_set_table);
64
 
65
+ yasr_import_multiset_author();
66
 
67
  }
68
 
186
 
187
  //if no meta are found, try to import data again
188
  if ($sql_meta_multiset === 0) {
189
+ yasr_import_multiset_author();
190
  }
191
 
192
  }
193
 
194
  } //Endif yasr_version_installed !== false
195
 
196
+ /****** End backward compatibility functions ******/
197
+ if ($yasr_version_installed != YASR_VERSION_NUM) {
198
+ update_option('yasr-version', YASR_VERSION_NUM);
199
+ }
200
 
201
+ }
202
 
203
+ }
204
 
205
+ function yasr_import_multiset_author () {
206
 
207
+ global $wpdb;
208
+
209
+ $old_yasr_table = $wpdb->prefix . 'yasr_multi_values';
210
+
211
+ $sql_import_author_multiset = $wpdb->get_results(
212
+ "SELECT post_id, set_type AS set_id,
213
  CONCAT(
214
  '[',
215
  GROUP_CONCAT(
228
  )
229
  GROUP BY post_id, set_type
230
  ORDER BY post_id, set_type", ARRAY_A
231
+ );
232
 
233
+ if(!empty($sql_import_author_multiset)) {
234
+ //just the same code used in yasr_save_multiset_editor
235
+ $i = 0;
236
+ foreach ($sql_import_author_multiset as $multiset_ratings) {
237
 
238
+ $post_id = $multiset_ratings['post_id'];
239
+ $set_id = (int)$multiset_ratings['set_id'];
240
+ $field_and_vote_array = json_decode($multiset_ratings['fields_and_ratings']);
241
 
242
+ //convert in a object with json_decode
243
+ $data_to_save[$i] = array(
244
+ 'set_id' => $set_id,
245
+ 'fields_and_ratings' => $field_and_vote_array
246
+ );
247
 
248
+ $set_post_meta_values = get_post_meta($post_id, 'yasr_multiset_author_votes',true);
249
 
250
+ if ($set_post_meta_values) {
251
+ //first, loop saved fields and ratings
252
+ foreach ($set_post_meta_values as $saved_set) {
253
+ //if the saved set is different from the one that we're trying to save,
254
+ //append data to save to the post meta
255
+ if ($saved_set['set_id'] !== $set_id) {
256
+ //increment i
257
+ $i++;
258
+ $data_to_save[$i]['set_id'] = $saved_set['set_id'];
259
+ $data_to_save[$i]['fields_and_ratings'] = $saved_set['fields_and_ratings'];
260
 
 
 
261
  }
 
 
 
262
  }
 
263
  }
264
+ update_post_meta($multiset_ratings['post_id'], 'yasr_multiset_author_votes', $data_to_save);
265
+ //empty array
266
+ $data_to_save = array();
 
 
267
  }
268
 
269
  }
 
270
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 4.9.0
5
  Contributors: Dudo
6
  Tested up to: 5.4
7
  Requires PHP: 5.3
8
- Stable tag: 2.2.4
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  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
@@ -125,6 +125,9 @@ If doesn't, it's suggested to ask in a SEO oriented forum.
125
 
126
  The full changelog can be found in the plugin's directory. Recent entries:
127
 
 
 
 
128
  = 2.2.4 =
129
  * FIXED: Multi Set didn't shows up vote in admin screen
130
  * FIXED: attribute "readonly" to the yasr_visitor_votes shortcode
5
  Contributors: Dudo
6
  Tested up to: 5.4
7
  Requires PHP: 5.3
8
+ Stable tag: 2.2.5
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  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
125
 
126
  The full changelog can be found in the plugin's directory. Recent entries:
127
 
128
+ = 2.2.5 =
129
+ * FIXED: bug if upgrading from version before than 2.0.9
130
+
131
  = 2.2.4 =
132
  * FIXED: Multi Set didn't shows up vote in admin screen
133
  * FIXED: attribute "readonly" to the yasr_visitor_votes shortcode
yet-another-stars-rating.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
  * testimonials to your website posts, pages and CPT, without affecting its speed.
8
- * Version: 2.2.4
9
  * Author: Dario Curvino
10
  * Author URI: https://dariocurvino.it/
11
  * Text Domain: yet-another-stars-rating
@@ -77,7 +77,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
77
  yasr_fs();
78
  // Signal that SDK was initiated.
79
  do_action( 'yasr_fs_loaded' );
80
- define( 'YASR_VERSION_NUM', '2.2.4' );
81
  //Plugin relative path
82
  define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
83
  //Plugin RELATIVE PATH without slashes (just the directory's name)
5
  * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
6
  * Description: Yasr - Yet Another Stars Rating is a powerful way to add SEO-friendly user-generated reviews and
7
  * testimonials to your website posts, pages and CPT, without affecting its speed.
8
+ * Version: 2.2.5
9
  * Author: Dario Curvino
10
  * Author URI: https://dariocurvino.it/
11
  * Text Domain: yet-another-stars-rating
77
  yasr_fs();
78
  // Signal that SDK was initiated.
79
  do_action( 'yasr_fs_loaded' );
80
+ define( 'YASR_VERSION_NUM', '2.2.5' );
81
  //Plugin relative path
82
  define( "YASR_ABSOLUTE_PATH", dirname( __FILE__ ) );
83
  //Plugin RELATIVE PATH without slashes (just the directory's name)