From ee8d6dbfd9cc837e7042c84bda0e308804a95f58 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Thu, 14 Nov 2024 15:35:53 +0100 Subject: [PATCH] use already existing helper --- classes/class-suggested-tasks.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/classes/class-suggested-tasks.php b/classes/class-suggested-tasks.php index 07e37eab9..dd3cc370f 100644 --- a/classes/class-suggested-tasks.php +++ b/classes/class-suggested-tasks.php @@ -87,19 +87,15 @@ public function mark_task_as_completed( $task_id ) { $activity->save(); // Clear monthly saved progress. - $badge_id = 'monthly-' . $activity_date->format( 'Y' ) . '-m' . $activity_date->format( 'm' ); + $badge_id = 'monthly-' . $activity_date->format( 'Y' ) . '-m' . $activity_date->format( 'm' ); + $monthly_badge = \progress_planner()->get_badges()->get_badge( $badge_id ); - foreach ( \progress_planner()->get_badges()->get_badges( 'monthly' ) as $badge ) { + if ( $monthly_badge ) { + // Clear the progress. + $monthly_badge->clear_progress(); - if ( $badge_id === $badge->get_id() ) { - - // Clear the progress. - $badge->clear_progress(); - - // Save the progress. - $badge->get_progress(); - break; - } + // Save the progress. + $monthly_badge->get_progress(); } $this->mark_task_as_pending_celebration( $task_id );