| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying user profile tabs. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/learnpress/profile/tabs.php. |
| 6 |
* |
| 7 |
* @author ThimPress |
| 8 |
* @package Learnpress/Templates |
| 9 |
* @version 4.0.2 |
| 10 |
*/ |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit(); |
| 13 |
|
| 14 |
if ( ! isset( $user ) || ! isset( $profile ) ) { |
| 15 |
return; |
| 16 |
} |
| 17 |
?> |
| 18 |
|
| 19 |
<div id="profile-nav"> |
| 20 |
|
| 21 |
<?php do_action( 'learn-press/before-profile-nav', $profile ); ?> |
| 22 |
|
| 23 |
<ul class="lp-profile-nav-tabs"> |
| 24 |
|
| 25 |
<?php |
| 26 |
/** |
| 27 |
* @var LP_Profile_Tab $profile_tab |
| 28 |
*/ |
| 29 |
foreach ( $profile->get_tabs()->tabs() as $tab_key => $profile_tab ) { |
| 30 |
if ( ! is_object( $profile_tab ) || ! $profile_tab || $profile_tab->is_hidden() || ! $profile_tab->user_can_view() ) { |
| 31 |
continue; |
| 32 |
} |
| 33 |
|
| 34 |
// Admin view another user profile |
| 35 |
if ( $profile->get_user()->get_id() !== get_current_user_id() && current_user_can( ADMIN_ROLE ) ) { |
| 36 |
$tab_key_hidden_admin_view_user = [ 'settings', 'logout', 'orders', 'gradebook' ]; |
| 37 |
if ( in_array( $tab_key, $tab_key_hidden_admin_view_user ) ) { |
| 38 |
continue; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
$slug = $profile->get_slug( $profile_tab, $tab_key ); |
| 43 |
$link = $profile->get_tab_link( $tab_key, true ); |
| 44 |
$tab_classes = array( esc_attr( $tab_key ) ); |
| 45 |
|
| 46 |
$sections = $profile_tab->sections(); |
| 47 |
|
| 48 |
if ( $sections && sizeof( $sections ) > 1 ) { |
| 49 |
$tab_classes[] = 'has-child'; |
| 50 |
} |
| 51 |
|
| 52 |
if ( $profile->is_current_tab( $tab_key ) ) { |
| 53 |
$tab_classes[] = 'active'; |
| 54 |
} |
| 55 |
?> |
| 56 |
|
| 57 |
<li class="<?php echo implode( ' ', $tab_classes ); ?>"> |
| 58 |
<a href="<?php echo esc_url_raw( $link ); ?>" data-slug="<?php echo esc_attr( $link ); ?>"> |
| 59 |
<?php |
| 60 |
if ( ! empty( $profile_tab->get( 'icon' ) ) ) { |
| 61 |
echo wp_kses_post( $profile_tab->get( 'icon' ) ); |
| 62 |
} |
| 63 |
?> |
| 64 |
<?php echo apply_filters( 'learn_press_profile_' . $tab_key . '_tab_title', $profile_tab->get( 'title' ), $tab_key ); ?> |
| 65 |
</a> |
| 66 |
|
| 67 |
<?php if ( $sections && sizeof( $sections ) > 1 ) { ?> |
| 68 |
|
| 69 |
<ul class="profile-tab-sections"> |
| 70 |
<?php |
| 71 |
foreach ( $sections as $section_key => $section_data ) { |
| 72 |
|
| 73 |
$classes = array( esc_attr( $section_key ) ); |
| 74 |
if ( $profile->is_current_section( $section_key, $section_key ) ) { |
| 75 |
$classes[] = 'active'; |
| 76 |
} |
| 77 |
|
| 78 |
$section_slug = $profile->get_slug( $section_data, $section_key ); |
| 79 |
$section_link = $profile->get_tab_link( $tab_key, $section_slug ); |
| 80 |
?> |
| 81 |
|
| 82 |
<li class="<?php echo implode( ' ', $classes ); ?>"> |
| 83 |
<a href="<?php echo esc_url_raw( $section_link ); ?>"> |
| 84 |
<?php |
| 85 |
if ( ! empty( $section_data['icon'] ) ) { |
| 86 |
echo wp_kses_post( $section_data['icon'] ); |
| 87 |
} |
| 88 |
?> |
| 89 |
<?php echo apply_filters( 'learn_press_profile_' . $tab_key . '_tab_title', $section_data['title'], $tab_key ); ?> |
| 90 |
</a> |
| 91 |
</li> |
| 92 |
|
| 93 |
<?php } ?> |
| 94 |
|
| 95 |
</ul> |
| 96 |
|
| 97 |
<?php } ?> |
| 98 |
|
| 99 |
</li> |
| 100 |
<?php } ?> |
| 101 |
|
| 102 |
</ul> |
| 103 |
|
| 104 |
<?php do_action( 'learn-press/after-profile-nav', $profile ); ?> |
| 105 |
|
| 106 |
</div> |
| 107 |
|