From cf397154ff83d7843260a1889c885dc91e68fc87 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Tue, 12 Nov 2024 10:43:17 +0100 Subject: [PATCH] run the loop twice, to be more clear --- views/page-widgets/parts/monthly-badges.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/views/page-widgets/parts/monthly-badges.php b/views/page-widgets/parts/monthly-badges.php index 283753078..aa48ce12e 100644 --- a/views/page-widgets/parts/monthly-badges.php +++ b/views/page-widgets/parts/monthly-badges.php @@ -28,8 +28,14 @@ $prpl_total_rows = (int) ceil( $prpl_badges_count / $prpl_badges_per_row ); // We need to know current month badge position. - $prpl_current_month_position = 0; - $prpl_current_month_found = false; + $prpl_current_month_position = 1; + + foreach ( $prpl_badges as $prpl_badge ) { + $prpl_current_month_position++; + if ( 'monthly-' . gmdate( 'Y' ) . '-m' . (int) gmdate( 'm' ) === $prpl_badge->get_id() ) { + break; + } + } $prpl_scroll_to_row = (int) ceil( $prpl_current_month_position / $prpl_badges_per_row ); @@ -57,14 +63,6 @@
- get_id() ) { - $prpl_current_month_found = true; - } - } - ?>