Skip to content

Commit 3aec230

Browse files
authored
Merge pull request #528 from ProgressPlanner/ari/rename-update-class
Rename the 1.5.0 update class to 1.6.1
2 parents 1c4d542 + f0bc05b commit 3aec230

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,49 @@
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
*

0 commit comments

Comments
 (0)