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.
This commit is contained in:
Mykyta Synelnikov
2025-11-19 19:47:48 +02:00
parent c7ff157ff8
commit 254c5d4782
3 changed files with 10 additions and 2 deletions
+1
View File
@@ -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:
+8 -2
View File
@@ -1856,9 +1856,15 @@ function um_profile_menu( $args ) {
<?php foreach ( $tab['subnav'] as $id_s => $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 );
<a href="<?php echo esc_url( $subnav_link ); ?>" class="<?php echo $active_subnav == $id_s ? 'active' : ''; ?>">
$subnav_classes = array( 'um-profile-subnav-' . $id_s . '-link' );
if ( $active_subnav === $id_s ) {
$subnav_classes[] = 'active';
}
?>
<a href="<?php echo esc_url( $subnav_link ); ?>" class="<?php echo esc_attr( implode( ' ', $subnav_classes ) ); ?>">
<?php echo $subtab; ?>
</a>
+1
View File
@@ -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**