row.php
11.7 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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<?php
/**
* LearnDash LD30 Displays a single lesson row that appears in the course content listing
*
* Available Variables:
* WIP
*
* @since 3.0.0
*
* @package LearnDash\Templates\LD30
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Populate a list of topics and quizzes for this lesson
*
* @var $topics [array]
* @var $quizzes [array]
* @since 3.0.0
*/
$topics = ! empty( $lesson_topics ) && ! empty( $lesson_topics[ $lesson['post']->ID ] ) ? $lesson_topics[ $lesson['post']->ID ] : '';
$quizzes = learndash_get_lesson_quiz_list( $lesson['post']->ID, $user_id, $course_id );
$attributes = learndash_get_course_step_attributes( $lesson['post']->ID, $course_id, $user_id );
$content_count = learndash_get_lesson_content_count( $lesson, $course_id );
// Fallbacks.
$count = ( isset( $count ) ? $count : 0 );
$sections = ( isset( $sections ) ? $sections : array() );
/**
* Filters lesson row attributes. Used while displaying lesson lists in a course.
*
* @since 3.0.0
*
* @param string $attribute Lesson row attribute. The value is data-ld-tooltip if a user does not have access to the course otherwise an empty string.
*/
$atts = apply_filters( 'learndash_lesson_row_atts', ( isset( $has_access ) && ! $has_access && 'is_not_sample' === $lesson['sample'] ? 'data-ld-tooltip="' . esc_html__( "You don't currently have access to this content", 'learndash' ) . '"' : '' ), $lesson['post']->ID, $course_id, $user_id );
/**
* New logic to override sample lessons access LEARNDASH-3854
*/
if ( ( empty( $atts ) ) && ( ! is_user_logged_in() ) ) {
if ( 'is_sample' === $lesson['sample'] ) {
/** This filter is documented in themes/ld30/includes/helpers.php */
if ( true !== (bool) apply_filters( 'learndash_lesson_sample_access', true, $lesson['post']->ID, $course_id, $user_id ) ) {
/**
* Filters lesson row attributes if the access to sample lesson is not allowed to a user.
*
* @since 3.1.4
*
* @param string $attribute Lesson row attribute. The attribute value to show if the sample lesson is not accessible.
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
$atts = apply_filters( 'learndash_lesson_row_atts_sample_no_access', 'data-ld-tooltip="' . esc_html__( 'Please login to view sample content', 'learndash' ) . '"', $lesson['post']->ID, $course_id, $user_id );
}
}
}
/**
* Fires before a lesson row.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-before', $lesson['post']->ID, $course_id, $user_id );
if ( isset( $sections[ $lesson['post']->ID ] ) ) :
learndash_get_template_part(
'lesson/partials/section.php',
array(
'section' => $sections[ $lesson['post']->ID ],
'course_id' => $course_id,
'user_id' => $user_id,
),
true
);
endif; ?>
<div class="<?php learndash_lesson_row_class( $lesson, $has_access, $topics, $quizzes ); ?>" id="<?php echo esc_attr( 'ld-expand-' . $lesson['post']->ID ); ?>" data-ld-expand-id="<?php echo esc_attr( 'ld-expand-' . $lesson['post']->ID ); ?>" <?php echo wp_kses_post( $atts ); ?>>
<div class="ld-item-list-item-preview">
<?php
/**
* Fires before a lesson title.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-title-before', $lesson['post']->ID, $course_id, $user_id );
?>
<a class="ld-item-name ld-primary-color-hover" href="<?php echo esc_attr( learndash_get_step_permalink( $lesson['post']->ID, $course_id ) ); ?>">
<?php
$lesson_progress = learndash_lesson_progress( $lesson['post'] );
if ( is_array( $lesson_progress ) ) {
$status = ( $lesson_progress['completed'] > 0 && 'completed' !== $lesson['status'] ? 'progress' : $lesson['status'] );
} else {
$status = $lesson['status'];
}
learndash_status_icon( $status, $lesson['post']->post_type, null, true );
?>
<div class="ld-item-title">
<?php
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
echo wp_kses_post( apply_filters( 'the_title', $lesson['post']->post_title, $lesson['post']->ID ) );
/**
* Display content counts if the lesson has topics
*/
/**
* Filters whether to show lesson row attributes in lesson listing.
*
* @since 3.0.0
*
* @param boolean $show_row_attributes Whether to show lesson row attributes.
*/
if ( ! empty( $topics ) || ! empty( $quizzes ) || ! empty( $attributes ) || apply_filters( 'learndash-lesson-row-attributes', false ) ) :
/**
* Fires after the lesson topic counts.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-topic-count-before', $lesson['post']->ID, $course_id, $user_id );
?>
<span class="ld-item-components">
<?php
/**
* Fires after the lesson topic counts.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-components-before', $lesson['post']->ID, $course_id, $user_id );
if ( $content_count['topics'] > 0 ) :
?>
<span class="ld-item-component">
<?php
printf(
// translators: placeholders: Topic Count, Topic/Topics Label.
_nx(
'%1$d %2$s',
'%1$d %2$s',
$content_count['topics'],
'placeholders: Topic Count, Topic/Topics Label',
'learndash'
),
$content_count['topics'],
( $content_count['topics'] < 2 ? esc_attr( LearnDash_Custom_Label::get_label( 'topic' ) ) : esc_attr( LearnDash_Custom_Label::get_label( 'topics' ) ) ),
number_format_i18n( $content_count['topics'] )
);
?>
</span>
<?php
endif;
if ( $content_count['topics'] > 0 && $content_count['quizzes'] > 0 ) {
echo '<span class="ld-sep">|</span>';
}
if ( $content_count['quizzes'] > 0 ) :
?>
<span class="ld-item-component">
<?php
printf(
// translators: placeholders: Quiz Count, Quiz/Quizzes Label.
_nx(
'%1$d %2$s',
'%1$d %2$s',
$content_count['quizzes'],
'placeholders: Quiz Count, Quiz/Quizzes Label',
'learndash'
),
$content_count['quizzes'],
( $content_count['quizzes'] < 2 ? esc_attr( LearnDash_Custom_Label::get_label( 'quiz' ) ) : esc_attr( LearnDash_Custom_Label::get_label( 'quizzes' ) ) ),
number_format_i18n( $content_count['quizzes'] )
);
?>
</span>
<?php
endif;
if ( ! empty( $attributes ) ) :
foreach ( $attributes as $attribute ) :
?>
<span class="<?php echo esc_attr( 'ld-status ' . $attribute['class'] ); ?>">
<span class="<?php echo esc_attr( 'ld-icon ' . $attribute['icon'] ); ?>"></span>
<?php echo esc_html( $attribute['label'] ); ?>
</span>
<?php
endforeach;
endif;
/**
* Fires after the lesson topic counts.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-components-after', $lesson['post']->ID, $course_id, $user_id );
?>
</span> <!--/.ld-item-components-->
<?php
/**
* Fires after the lesson topic counts.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-preview-after', $lesson['post']->ID, $course_id, $user_id );
?>
<?php endif; ?>
</div> <!--/.ld-item-title-->
</a>
<?php
/**
* Fires after the lesson title.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-title-after', $lesson['post']->ID, $course_id, $user_id );
?>
<div class="ld-item-details">
<?php
/**
* Fires before the attribute bubbles.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-attributes-before', $lesson['post']->ID, $course_id, $user_id );
/**
* If this lesson has topics or quizzes show an expand button
*
* @var [type]
*/
if ( ! empty( $topics ) || ! empty( $quizzes ) ) :
/**
* Fires before the expand button.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-expand-before', $lesson['post']->ID, $course_id, $user_id );
?>
<div class="ld-expand-button ld-button-alternate" data-ld-expands="<?php echo esc_attr( 'ld-expand-' . $lesson['post']->ID ); ?>" data-ld-expand-text="<?php esc_html_e( 'Expand', 'learndash' ); ?>" data-ld-collapse-text="<?php esc_html_e( 'Collapse', 'learndash' ); ?>">
<span class="ld-icon-arrow-down ld-icon ld-primary-background"></span>
<span class="ld-text ld-primary-color"><?php esc_html_e( 'Expand', 'learndash' ); ?></span>
</div> <!--/.ld-expand-button-->
<?php
/**
* Fires after the lesson title.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-expand-after', $lesson['post']->ID, $course_id, $user_id );
endif;
?>
</div> <!--/.ld-item-details-->
<?php
/**
* Fires after the attribute bubbles.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-attributes-after', $lesson['post']->ID, $course_id, $user_id );
?>
</div> <!--/.ld-item-list-item-preview-->
<?php
/**
* If the lesson has associated topics, display a list
*
* @var $topics [array]
* @since 3.0.0
*/
if ( ! empty( $topics ) || ! empty( $quizzes ) ) :
?>
<div class="ld-item-list-item-expanded">
<?php
/**
* Fires before the topic/quiz list
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-topic-list-before', $lesson['post']->ID, $course_id, $user_id );
learndash_get_template_part(
'lesson/listing.php',
array(
'lesson' => $lesson,
'topics' => $topics,
'quizzes' => $quizzes,
'course_id' => $course_id,
'user_id' => $user_id,
'course_pager_results' => $course_pager_results,
),
true
);
/**
* Fires after the topic/quiz list.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-topic-list-after', $lesson['post']->ID, $course_id, $user_id );
?>
</div> <!--/.ld-item-list-item-expanded-->
<?php endif; ?>
</div> <!--/.ld-item-list-item-->
<?php
/**
* Fires after a lesson row.
*
* @since 3.0.0
*
* @param int $lesson_id Lesson ID.
* @param int $course_id Course ID.
* @param int $user_id User ID.
*/
do_action( 'learndash-lesson-row-after', $lesson['post']->ID, $course_id, $user_id ); ?>