diff --git a/assets/css/page-widgets/suggested-tasks.css b/assets/css/page-widgets/suggested-tasks.css index dfd884dac..e81d56efa 100644 --- a/assets/css/page-widgets/suggested-tasks.css +++ b/assets/css/page-widgets/suggested-tasks.css @@ -92,6 +92,14 @@ font-weight: 600; } } + + .prpl-montly-completed-tasks-list { + + li { + display: flex; + justify-content: space-between; + } + } } .prpl-dashboard-widget-suggested-tasks { diff --git a/classes/badges/class-monthly.php b/classes/badges/class-monthly.php index 2804b801b..bdb7c9689 100644 --- a/classes/badges/class-monthly.php +++ b/classes/badges/class-monthly.php @@ -200,6 +200,34 @@ public function progress_callback() { return $saved_progress; } + $activities = $this->get_monthly_activities(); + + $points = 0; + foreach ( $activities as $activity ) { + $points += $activity->get_points( $activity->date ); + } + + $return_progress = ( $points > self::TARGET_POINTS ) + ? [ + 'progress' => 100, + 'remaining' => 0, + ] : [ + 'progress' => (int) max( 0, min( 100, floor( 100 * $points / self::TARGET_POINTS ) ) ), + 'remaining' => self::TARGET_POINTS - $points, + ]; + + $this->save_progress( $return_progress ); + + return $return_progress; + } + + /** + * Get the monthly activities. + * + * @return array + */ + protected function get_monthly_activities() { + $month = self::get_months()[ 'm' . $this->get_month() ]; $year = $this->get_year(); $month_num = (int) $this->get_month(); @@ -216,22 +244,26 @@ public function progress_callback() { ], ); - $points = 0; - foreach ( $activities as $activity ) { - $points += $activity->get_points( $activity->date ); - } + return $activities; + } - $return_progress = ( $points > self::TARGET_POINTS ) - ? [ - 'progress' => 100, - 'remaining' => 0, - ] : [ - 'progress' => (int) max( 0, min( 100, floor( 100 * $points / self::TARGET_POINTS ) ) ), - 'remaining' => self::TARGET_POINTS - $points, - ]; + /** + * Get the tasks for the badge. + * + * @return array + */ + public function get_monthly_tasks() { + $activities = $this->get_monthly_activities(); - $this->save_progress( $return_progress ); + $tasks = []; + foreach ( $activities as $activity ) { + $task = \progress_planner()->get_suggested_tasks()->get_tasks_by( 'task_id', $activity->data_id ); - return $return_progress; + if ( isset( $task[0] ) && isset( $task[0]['provider_id'] ) ) { + $tasks[] = \progress_planner()->get_suggested_tasks()->get_local()->get_task_details( $task[0]['task_id'] ); + } + } + + return $tasks; } } diff --git a/views/page-widgets/suggested-tasks.php b/views/page-widgets/suggested-tasks.php index d2a1e0e6a..9888cea19 100644 --- a/views/page-widgets/suggested-tasks.php +++ b/views/page-widgets/suggested-tasks.php @@ -59,6 +59,26 @@ + get_monthly_tasks(); ?> + + +