tabs_group.php
4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
* LearnDash LD30 Displays tabs content for a group
*
* @since 3.0.0
*
* @package LearnDash\Templates\LD30
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-content-tabs-before', get_the_ID(), $group_id, $user_id );
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-' . $context . '-content-tabs-before', get_the_ID(), $group_id, $user_id );
$tab_count = 0;
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
$tabs = apply_filters(
'learndash_content_tabs',
array(
array(
'id' => 'content',
'icon' => 'ld-icon-content',
'label' => LearnDash_Custom_Label::get_label( $context ),
'content' => $content,
),
array(
'id' => 'materials',
'icon' => 'ld-icon-materials',
'label' => __( 'Materials', 'learndash' ),
'content' => $materials,
'condition' => ( isset( $materials ) && ! empty( $materials ) ),
),
),
$context,
$group_id,
$user_id
);
foreach ( $tabs as $tab ) {
if ( ! isset( $tab['condition'] ) ) {
$tab_count++;
}
if ( isset( $tab['condition'] ) && $tab['condition'] ) {
$tab_count++;
}
} ?>
<div class="ld-tabs <?php echo esc_attr( 'ld-tab-count-' . $tab_count ); ?>">
<?php
/**
* If we have more than one tab, show them
*/
if ( $tab_count > 1 ) :
$i = 0;
?>
<div class="ld-tabs-navigation">
<?php
foreach ( $tabs as $tab ) :
// Skip if conditionally indicated.
if ( isset( $tab['condition'] ) && ! $tab['condition'] ) {
continue;
}
$tab_class = 'ld-tab ' . ( 0 === $i ? 'ld-active' : '' );
?>
<div class="<?php echo esc_attr( $tab_class ); ?>" data-ld-tab="<?php echo esc_attr( 'ld-tab-' . $tab['id'] . '-' . get_the_ID() ); ?>">
<span class="<?php echo esc_attr( 'ld-icon ' . $tab['icon'] ); ?>"></span>
<span class="ld-text"><?php echo esc_attr( $tab['label'] ); ?></span>
</div>
<?php
$i++;
endforeach;
?>
</div>
<?php endif; ?>
<div class="ld-tabs-content">
<?php
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-content-tab-listing-before', get_the_ID(), $context, $group_id, $user_id );
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-' . $context . '-content-tab-listing-before', get_the_ID(), $group_id, $user_id );
$i = 0;
foreach ( $tabs as $tab ) :
// Skip if conditionally indicated.
if ( isset( $tab['condition'] ) && ! $tab['condition'] ) {
continue;
}
$tab_class = 'ld-tab-content ' . ( 0 === $i ? 'ld-visible' : '' );
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-content-tabs-' . $tab['id'] . '-before', get_the_ID(), $context, $group_id, $user_id );
?>
<div class="<?php echo esc_attr( $tab_class ); ?>" id="<?php echo esc_attr( 'ld-tab-' . $tab['id'] . '-' . get_the_ID() ); ?>">
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Might output HTML?>
<?php echo $tab['content']; ?>
</div>
<?php
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-content-tabs-' . $tab['id'] . '-after', get_the_ID(), $context, $group_id, $user_id );
$i++;
endforeach;
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-content-tab-listing-after', get_the_ID(), $group_id, $user_id );
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-' . $context . '-content-tab-listing-after', get_the_ID(), $group_id, $user_id );
?>
</div> <!--/.ld-tabs-content-->
</div> <!--/.ld-tabs-->
<?php
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-content-tabs-after', get_the_ID(), $group_id, $user_id );
/** This filter is documented in themes/ld30/templates/modules/tabs.php */
do_action( 'learndash-' . $context . '-content-tabs-after', get_the_ID(), $group_id, $user_id );