| 1 |
<?php |
| 2 |
/** |
| 3 |
* Profile tabs template (default) |
| 4 |
* |
| 5 |
* @ver 0.0.1 |
| 6 |
*/ |
| 7 |
$css_class = ! empty( $args['css_class'] ) ? esc_attr( $args['css_class'] ) : 'border-0'; |
| 8 |
$output = ! empty( $args['output'] ) ? esc_attr( $args['output'] ) : ''; |
| 9 |
$account_page = uwp_get_page_id('account_page', false); |
| 10 |
$tabs_array = $args['tabs_array']; |
| 11 |
$active_tab = $args['active_tab']; |
| 12 |
$greedy_menu_class = empty($args['disable_greedy']) ? 'greedy' : ''; |
| 13 |
|
| 14 |
do_action( 'uwp_template_before', 'profile-tabs' ); |
| 15 |
$user = uwp_get_displayed_user(); |
| 16 |
if(!$user){ |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
$head_output = $active_tab_content = ''; |
| 21 |
if(!empty($tabs_array)) { |
| 22 |
foreach ($tabs_array as $tab) { |
| 23 |
$tab_id = $tab['tab_key']; |
| 24 |
$tab_url = uwp_build_profile_tab_url($user->ID, $tab_id, false); |
| 25 |
|
| 26 |
$active = $active_tab == $tab_id ? ' active border-bottom border-primary border-width-2' : ''; |
| 27 |
|
| 28 |
if ($active_tab == $tab_id) { |
| 29 |
$active_tab_content = $tab['tab_content_rendered']; |
| 30 |
} |
| 31 |
|
| 32 |
$append_hash = apply_filters('uwp_add_tab_content_hashtag', true, $tab, $user); |
| 33 |
$head_output .= ' |
| 34 |
<li id="uwp-profile-'.esc_attr( $tab_id ).'" |
| 35 |
class="nav-item '.esc_attr( $active ).' list-unstyled m-0"> |
| 36 |
'; |
| 37 |
|
| 38 |
$content = '<span class="uwp-profile-tab-label uwp-profile-'.esc_attr( $tab_id ).'-label">'.esc_html__($tab['tab_name'], 'userswp').'</span>'; |
| 39 |
$head_output .= aui()->button(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 40 |
'type' => 'a', |
| 41 |
'href' => $append_hash ? esc_url($tab_url).'#tab-content' : esc_url($tab_url), |
| 42 |
'class' => 'nav-link', |
| 43 |
'icon' => esc_attr($tab['tab_icon']), |
| 44 |
'content' => $content, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 45 |
)); |
| 46 |
|
| 47 |
$head_output .= '</li>'; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
if($output === '' || $output=='head'){ |
| 52 |
?> |
| 53 |
<nav class="navbar navbar-expand-xl navbar-light bg-white mb-4 p-xl-0 <?php echo esc_attr($greedy_menu_class); ?>"> |
| 54 |
<div class="w-100 justify-content-center p-xl-0 border-bottom"> |
| 55 |
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#uwp-profile-tabs-nav" aria-controls="navbarNavDropdown-1" aria-expanded="false" aria-label="Toggle navigation" style=""><span class="navbar-toggler-icon"></span></button> |
| 56 |
<div class="collapse navbar-collapse" id="uwp-profile-tabs-nav"> |
| 57 |
<ul class="navbar-nav flex-wrap m-0 list-unstyled"> |
| 58 |
<?php |
| 59 |
echo $head_output; |
| 60 |
?> |
| 61 |
</ul> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
</nav> |
| 65 |
<?php |
| 66 |
} |
| 67 |
|
| 68 |
if ( $output === '' || $output == 'body' ) { |
| 69 |
if ( isset( $active_tab_content ) && ! empty( $active_tab_content ) ) { |
| 70 |
?> |
| 71 |
<div id="tab-content" class="uwp-profile-content"> |
| 72 |
<div class="uwp-profile-entries"> |
| 73 |
<?php |
| 74 |
echo $active_tab_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 75 |
?> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
<?php |
| 79 |
} |
| 80 |
} |
| 81 |
?> |