File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 *
1313 * @package Progress_Planner
1414 */
15- class Update_150 {
15+ class Update_161 {
1616
17- const VERSION = '1.5.0 ' ;
17+ const VERSION = '1.6.1 ' ;
1818
1919 /**
2020 * Run the update.
2121 *
2222 * @return void
2323 */
2424 public function run () {
25+ // Migrate the badges.
26+ $ this ->migrate_badges ();
27+
28+ // Migrate the tasks.
2529 $ this ->migrate_tasks ();
2630 }
2731
32+ /**
33+ * Migrate the badges.
34+ *
35+ * @return void
36+ */
37+ private function migrate_badges () {
38+ // Get all badges.
39+ $ badges = \progress_planner ()->get_settings ()->get ( 'badges ' , [] );
40+
41+ foreach ( $ badges as $ badge_id => $ badge ) {
42+
43+ // We are only migrating monthly badges.
44+ if ( 0 !== strpos ( $ badge_id , 'monthly- ' ) ) {
45+ continue ;
46+ }
47+
48+ if ( ! isset ( $ badges [ $ badge_id ]['points ' ] ) ) {
49+ // We are just adding the points to the badge, for the new data structure - 10 is the max points for a badge.
50+ $ badges [ $ badge_id ]['points ' ] = 10 - (int ) $ badge ['remaining ' ];
51+ }
52+ }
53+
54+ // Set the badges.
55+ \progress_planner ()->get_settings ()->set ( 'badges ' , $ badges );
56+ }
57+
2858 /**
2959 * Migrate the tasks.
3060 *
You can’t perform that action at this time.
0 commit comments