From feeebf66a2296bc96a10da8b43893e813b16403a Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Thu, 19 Feb 2026 15:53:31 +0100 Subject: [PATCH] Add year-specific monthly badge names with 2026 names Co-Authored-By: Claude Opus 4.6 --- classes/badges/class-monthly.php | 37 +++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/classes/badges/class-monthly.php b/classes/badges/class-monthly.php index 449fe35aa..ed1274cbf 100644 --- a/classes/badges/class-monthly.php +++ b/classes/badges/class-monthly.php @@ -148,14 +148,19 @@ public static function get_instance_from_id( $badge_id ) { /** * Get an array of months. * + * Year-specific names are supported. If no names are defined for the + * given year, the default (2025) names are returned as a fallback. + * + * @param int|null $year The year. Null returns the default names. + * * @return array */ - public static function get_months() { + public static function get_months( $year = null ) { /* * Indexed months, The array keys are prefixed with an "m" * so that they are strings and not integers. */ - $months = [ + $default = [ 'm1' => 'Jack January', 'm2' => 'Felix February', 'm3' => 'Mary March', @@ -169,7 +174,29 @@ public static function get_months() { 'm11' => 'Noah November', 'm12' => 'Daisy December', ]; - return $months; + + $yearly = [ + 2026 => [ + 'm1' => 'Jamie January', + 'm2' => 'Freya February', + 'm3' => 'Milo March', + 'm4' => 'Aida April', + 'm5' => 'Maeve May', + 'm6' => 'Jason June', + 'm7' => 'Julia July', + 'm8' => 'Ava August', + 'm9' => 'Sophie September', + 'm10' => 'Omar October', + 'm11' => 'Nathan November', + 'm12' => 'Daniel December', + ], + ]; + + if ( null !== $year && isset( $yearly[ $year ] ) ) { + return $yearly[ $year ]; + } + + return $default; } /** @@ -179,7 +206,7 @@ public static function get_months() { */ public function get_name() { return $this->id - ? self::get_months()[ 'm' . $this->get_month() ] + ? self::get_months( (int) $this->get_year() )[ 'm' . $this->get_month() ] : ''; } @@ -229,8 +256,8 @@ public function progress_callback( $args = [] ) { return $saved_progress; } - $month = self::get_months()[ 'm' . $this->get_month() ]; $year = $this->get_year(); + $month = self::get_months( (int) $year )[ 'm' . $this->get_month() ]; $month_num = (int) $this->get_month(); $start_date = \DateTime::createFromFormat( 'Y-m-d', "{$year}-{$month_num}-01" );