From 254c5d478237a74d433285c7dde3a375c34de9c6 Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Wed, 19 Nov 2025 19:47:48 +0200 Subject: [PATCH] Improve subnav link class handling in user profiles Refactor the subnav link class generation to use an array-based approach. This ensures better flexibility and readability while adding the "active" class conditionally when needed. --- changelog.txt | 1 + includes/core/um-actions-profile.php | 10 ++++++++-- readme.txt | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 5c96e988..0381a567 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ - Added: Extra condition for checking the license activation requests. - Added: 2nd `$args` attribute to the action hook 'um_cover_area_content'. + - Added: Class `um-profile-subnav-{$subnav_id}-link` to the sub navigation links in the User Profile page. - Tweak: Updated `Extensions_Updater` class to use Action Scheduler in the upgrade process of the UM extensions. * Bugfixes: diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index da1c67d5..6653b0ef 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -1856,9 +1856,15 @@ function um_profile_menu( $args ) { $subtab ) { $subnav_link = add_query_arg( 'subnav', $id_s ); - $subnav_link = apply_filters( 'um_user_profile_subnav_link', $subnav_link, $id_s, $subtab ); ?> + $subnav_link = apply_filters( 'um_user_profile_subnav_link', $subnav_link, $id_s, $subtab ); - + $subnav_classes = array( 'um-profile-subnav-' . $id_s . '-link' ); + if ( $active_subnav === $id_s ) { + $subnav_classes[] = 'active'; + } + ?> + + diff --git a/readme.txt b/readme.txt index fba8bf26..9ce63838 100644 --- a/readme.txt +++ b/readme.txt @@ -173,6 +173,7 @@ IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSI * Added: Extra condition for checking the license activation requests. * Added: 2nd `$args` attribute to the action hook 'um_cover_area_content'. +* Added: Class `um-profile-subnav-{$subnav_id}-link` to the sub navigation links in the User Profile page. * Tweak: Updated `Extensions_Updater` class to use Action Scheduler in the upgrade process of the UM extensions. **Bugfixes**