| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying sections in the top of user profile tab content. |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/learnpress/tabs/sections.php. |
| 6 |
* |
| 7 |
* @author ThimPress |
| 8 |
* @package Learnpress/Templates |
| 9 |
* @version 4.0.2 |
| 10 |
*/ |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit(); |
| 13 |
|
| 14 |
$profile = LP_Profile::instance(); |
| 15 |
|
| 16 |
|
| 17 |
if ( ! isset( $tab_key, $tab_data ) ) { |
| 18 |
return; |
| 19 |
} |
| 20 |
|
| 21 |
if ( empty( $tab_data->get( 'sections' ) ) || ( sizeof( $tab_data->get( 'sections' ) ) < 2 ) ) { |
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
$link = $profile->get_tab_link( $tab_key ); |
| 26 |
$unique_group = uniqid( 'course-tab-' ); |
| 27 |
$sections = $tab_data->get( 'sections' ); |
| 28 |
$visible_tabs = array(); |
| 29 |
$active_tab = ''; |
| 30 |
?> |
| 31 |
|
| 32 |
<div class="learn-press-tabs"> |
| 33 |
<?php |
| 34 |
foreach ( $sections as $section_key => $section_data ) { |
| 35 |
if ( $profile->is_hidden( $section_data ) ) { |
| 36 |
continue; |
| 37 |
} |
| 38 |
|
| 39 |
$visible_tabs[] = $section_key; |
| 40 |
$checked = ''; |
| 41 |
|
| 42 |
if ( $profile->is_current_section( $section_key, $section_key ) ) { |
| 43 |
$active_tab = $section_key; |
| 44 |
$checked = checked( true, true, false ); |
| 45 |
} |
| 46 |
?> |
| 47 |
|
| 48 |
<input type="radio" name="<?php echo esc_attr( $unique_group ); ?>" |
| 49 |
class="learn-press-tabs__checker" <?php echo esc_attr( $checked ); ?> |
| 50 |
id="<?php echo esc_attr( $unique_group . '__' . $section_key ); ?>"/> |
| 51 |
<?php } ?> |
| 52 |
|
| 53 |
<ul class="learn-press-tabs__nav" data-tabs="<?php echo esc_attr( count( $visible_tabs ) ); ?>"> |
| 54 |
<?php |
| 55 |
foreach ( $sections as $section_key => $section_data ) { |
| 56 |
if ( ! in_array( $section_key, $visible_tabs ) ) { |
| 57 |
continue; |
| 58 |
} |
| 59 |
|
| 60 |
$classes = array( 'learn-press-tabs__tab', esc_attr( $section_key ) ); |
| 61 |
|
| 62 |
if ( $active_tab == $section_key ) { |
| 63 |
$classes[] = 'active'; |
| 64 |
} |
| 65 |
|
| 66 |
$section_slug = $profile->get_slug( $section_data, $section_key ); |
| 67 |
$section_link = $profile->get_tab_link( $tab_key, $section_slug ); |
| 68 |
?> |
| 69 |
|
| 70 |
<li class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"> |
| 71 |
<label><a href="<?php echo esc_url_raw( $section_link ); ?>"><?php echo esc_html( $section_data['title'] ); ?></a></label> |
| 72 |
</li> |
| 73 |
|
| 74 |
<?php } ?> |
| 75 |
|
| 76 |
</ul> |
| 77 |
</div> |
| 78 |
|
| 79 |
|