group.php
9.43 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?php
/**
* LearnDash LD30 Displays a group
*
* Available Variables:
*
* @var int $group_id Group ID.
* @var int $user_id User ID.
* @var bool $has_access User has access to group or is enrolled.
* @var bool $group_status User's Group Status. Completed, No Started, or In Complete.
* @var object $post Group Post Object.
* @var array $group_courses Array of Group Courses to display in listing.
* @var string $materials Group Material from Settings.
* @var bool $has_group_content True/False if there is Group Post content.
*
* @since 3.1.7
*
* @package LearnDash\Templates\LD30
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// $group_course_ids = learndash_group_enrolled_courses( $group_id );
?>
<div class="<?php echo esc_attr( learndash_the_wrapper_class() ); ?>">
<?php
global $course_pager_results;
/**
* Fires before the group.
*
* @since 3.1.7
*
* @param int $post_id Post ID.
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_before', get_the_ID(), $group_id, $user_id );
/**
* Fires before the group certificate link.
*
* @since 3.1.7
*
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_certificate_link_before', $group_id, $user_id );
/**
* Certificate link
*/
if ( ( defined( 'LEARNDASH_TEMPLATE_CONTENT_METHOD' ) ) && ( 'shortcode' === LEARNDASH_TEMPLATE_CONTENT_METHOD ) ) {
$shown_content_key = 'learndash-shortcode-wrap-ld_certificate-' . absint( $group_id ) . '_' . absint( $user_id );
if ( false === strstr( $content, $shown_content_key ) ) {
$shortcode_out = do_shortcode( '[ld_certificate group_id="' . $group_id . '" user_id="' . $user_id . '" display_as="banner"]' );
if ( ! empty( $shortcode_out ) ) {
echo $shortcode_out;
}
}
} else {
if ( $group_certficate_link && ! empty( $group_certficate_link ) ) :
learndash_get_template_part(
'modules/alert.php',
array(
'type' => 'success ld-alert-certificate',
'icon' => 'certificate',
'message' => __( 'You\'ve earned a certificate!', 'learndash' ),
'button' => array(
'url' => $group_certficate_link,
'icon' => 'download',
'label' => __( 'Download Certificate', 'learndash' ),
'target' => '_new',
),
),
true
);
endif;
}
/**
* Fires after the group certificate link.
*
* @since 3.1.7
*
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_certificate_link_after', $group_id, $user_id );
/**
* Course info bar
*/
if ( ( defined( 'LEARNDASH_TEMPLATE_CONTENT_METHOD' ) ) && ( 'shortcode' === LEARNDASH_TEMPLATE_CONTENT_METHOD ) ) {
$shown_content_key = 'learndash-shortcode-wrap-ld_infobar-' . absint( $group_id ) . '_' . absint( $user_id );
if ( false === strstr( $content, $shown_content_key ) ) {
$shortcode_out = do_shortcode( '[ld_infobar group_id="' . $group_id . '" user_id="' . $user_id . '"]' );
if ( ! empty( $shortcode_out ) ) {
echo $shortcode_out;
}
}
} else {
learndash_get_template_part(
'modules/infobar_group.php',
array(
'context' => 'group',
'group_id' => $group_id,
'user_id' => $user_id,
'has_access' => $has_access,
'group_status' => $group_status,
'post' => $post,
),
true
);
}
?>
<?php
/**
* Filters the content to be echoed after the group status section of the group template output.
*
* @since 3.1.7
* See https://developers.learndash.com/hook/ld_after_course_status_template_container/ for example use of this filter used for Courses.
*
* @param string $content Custom content showed after the group status section. Can be empty.
* @param string $group_status_index Group status index from the course status label
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
echo apply_filters( 'ld_after_group_status_template_container', '', learndash_course_status_idx( $group_status ), $group_id, $user_id );
/**
* Content tabs
*/
learndash_get_template_part(
'modules/tabs_group.php',
array(
'group_id' => $group_id,
'post_id' => get_the_ID(),
'user_id' => $user_id,
'content' => $content,
'materials' => $materials,
'context' => 'group',
),
true
);
/**
* Identify if we should show the course content listing
*
* @var $show_course_content [bool]
*/
$show_group_content = ( ! $has_access && 'on' === learndash_get_setting( $group_id, 'group_disable_content_table' ) ? false : true );
if ( $has_group_content && $show_group_content ) :
if ( ( defined( 'LEARNDASH_TEMPLATE_CONTENT_METHOD' ) ) && ( 'shortcode' === LEARNDASH_TEMPLATE_CONTENT_METHOD ) ) {
$shown_content_key = 'learndash-shortcode-wrap-course_content-' . absint( $group_id ) . '_' . absint( $user_id );
if ( false === strstr( $content, $shown_content_key ) ) {
$shortcode_out = do_shortcode( '[course_content group_id="' . $group_id . '" user_id="' . $user_id . '"]' );
if ( ! empty( $shortcode_out ) ) {
echo $shortcode_out;
}
}
} else {
?>
<div class="ld-item-list ld-lesson-list">
<div class="ld-section-heading">
<?php
/**
* Fires before the group heading.
*
* @since 3.1.7
*
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_heading_before', $group_id, $user_id );
?>
<h2>
<?php
printf(
// translators: placeholders: Group, Courses.
esc_html_x( '%1$s %2$s', 'placeholders: Group, Courses', 'learndash' ),
LearnDash_Custom_Label::get_label( 'group' ),
LearnDash_Custom_Label::get_label( 'courses' )
);
?>
</h2>
<?php
/**
* Fires after the group heading.
*
* @since 3.1.7
*
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_heading_after', $group_id, $user_id );
?>
<?php if ( true === $has_access ) { ?>
<div class="ld-item-list-actions" data-ld-expand-list="true">
<?php
/**
* Fires before the course expand.
*
* @since 3.1.7
*
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_expand_before', $group_id, $user_id );
// Only display if there is something to expand.
if ( ( isset( $group_courses ) ) && ( ! empty( $group_courses ) ) ) {
?>
<div class="ld-expand-button ld-primary-background" id="<?php echo esc_attr( 'ld-expand-button-' . $group_id ); ?>" data-ld-expands="<?php echo esc_attr( 'ld-item-list-' . $group_id ); ?>" data-ld-expand-text="<?php echo esc_attr_e( 'Expand All', 'learndash' ); ?>" data-ld-collapse-text="<?php echo esc_attr_e( 'Collapse All', 'learndash' ); ?>">
<span class="ld-icon-arrow-down ld-icon"></span>
<span class="ld-text"><?php echo esc_html_e( 'Expand All', 'learndash' ); ?></span>
</div> <!--/.ld-expand-button-->
<?php
/**
* Filters whether to expand all course steps by default. Default is false.
*
* @since 2.5.0
*
* @param boolean $expand_all Whether to expand all course steps.
* @param int $course_id Course ID.
* @param string $context The context where course is expanded.
*/
if ( apply_filters( 'learndash_course_steps_expand_all', false, $group_id, 'course_lessons_listing_main' ) ) {
?>
<script>
jQuery( function(){
setTimeout(function(){
jQuery("<?php echo esc_attr( '#ld-expand-button-' . $group_id ); ?>").trigger('click');
}, 1000);
});
</script>
<?php
}
}
/**
* Action to add custom content after the course content expand button
*
* @since 3.0.0
*
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_expand_after', $group_id, $user_id );
?>
</div> <!--/.ld-item-list-actions-->
<?php } ?>
</div> <!--/.ld-section-heading-->
<?php
/**
* Fires before the group content listing
*
* @since 3.1.7
*
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_content_list_before', $group_id, $user_id );
/**
* Content content listing
*
* @since 3.1.7
*
* ('listing.php');
*/
learndash_get_template_part(
'group/listing.php',
array(
'group_id' => $group_id,
'user_id' => $user_id,
'group_courses' => $group_courses,
'has_access' => $has_access,
'course_pager_results' => $course_pager_results,
),
true
);
/**
* Fires before the group content listing.
*
* @since 3.1.7
*
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_content_list_after', $group_id, $user_id );
?>
</div> <!--/.ld-item-list-->
<?php
}
endif;
/**
* Fires before the group listing.
*
* @since 3.1.7
*
* @param int $post_id Post ID.
* @param int $group_id Group ID.
* @param int $user_id User ID.
*/
do_action( 'learndash_group_after', get_the_ID(), $group_id, $user_id );
learndash_load_login_modal_html();
?>
</div>