course-row.php
4.11 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
<?php
/**
* LearnDash LD30 Displays the status of a user's course in the ld_profile shortode
*
* Available Variables:
* $course_id : (int) ID of the course
* $course : (object) Post object of the course
* $course_link : (object) Permalink to the current course
* $progress : (array) Progress of the current user's course
* $status : (string) Status of the current user's course
* $since : (string) Date user gained access to the course
* $course_class : (string) CSS class for each course row
* $user_id : (int) ID of the user
* $course_icon_class : (string) CSS class for course status icon
* $components : (array) User status components
*
* @since 3.0.0
*
* @package LearnDash\Templates\LD30
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$course = get_post( $course_id );
$course_link = get_permalink( $course_id );
$progress = learndash_course_progress(
array(
'user_id' => $user_id,
'course_id' => $course_id,
'array' => true,
)
);
$status = ( 100 === absint( $progress['percentage'] ) ) ? 'completed' : 'notcompleted';
$status = ( absint( $progress['percentage'] ) > 0 && 100 !== absint( $progress['percentage'] ) ? 'progress' : $status );
$since = learndash_user_group_enrolled_to_course_from( $user_id, $course_id );
if ( empty( $since ) ) {
$since = ld_course_access_from( $course_id, $user_id );
}
/** This filter is documented in themes/ld30/templates/shortcodes/profile/course-row.php */
$course_class = apply_filters(
'learndash-course-row-class',
'ld-item-list-item ld-item-list-item-course ld-expandable ' . ( 100 === absint( $progress['percentage'] ) ? 'learndash-complete' : 'learndash-incomplete' ),
$course,
$user_id
);
/**
* Filters course icon CSS class.
*
* @since 3.0.0
*
* @param string $course_icon_class List of Course icon CSS class.
* @param \WP_Post|array|null $course Course Object.
* @param int $user_id User ID.
*/
$course_icon_class = apply_filters(
'learndash-course-icon-class',
'ld-status-icon ' . ( 100 === absint( $progress['percentage'] ) ? 'ld-status-complete' : 'ld-status-incomplete' ),
$course,
$user_id
); ?>
<div class="<?php echo esc_attr( $course_class ); ?>" id="<?php echo esc_attr( 'ld-course-list-item-' . $course_id ); ?>">
<div class="ld-item-list-item-preview">
<a href="<?php echo esc_url( get_the_permalink( $course_id ) ); ?>" class="ld-item-name">
<?php learndash_status_icon( $status, get_post_type( 'sfwd-courses' ), null, true ); ?>
<span class="ld-item-title">
<?php
echo esc_html( get_the_title( $course_id ) );
$components = array(
// translators: User Status Course Progress.
'progress' => sprintf( esc_html_x( '%s%% Complete', 'User Status Course Progress', 'learndash' ), $progress['percentage'] ),
// translators: User Status Course Steps.
'steps' => sprintf( esc_html_x( '%1$d/%2$d Steps', 'User Status Course Steps', 'learndash' ), $progress['completed'], $progress['total'] ),
);
if ( ! empty( $since ) ) {
// translators: User Status Course Since.
$components['since'] = sprintf( esc_html_x( 'Since %s', 'User Status Course Since', 'learndash' ), learndash_adjust_date_time_display( $since ) );
}
/**
* Filters user status course components.
*
* @since 3.0.0
*
* @param array $components An Array of user status components.
*/
$components = apply_filters( 'learndash_user_status_course_components', $components );
?>
<span class="ld-item-components">
<?php $i = 1; foreach ( $components as $slug => $markup ) : ?>
<span class="<?php echo esc_attr( 'ld-item-component-' . $slug ); ?>">
<?php echo wp_kses_post( $markup ); ?>
</span>
<?php
if ( count( $components ) !== $i ) :
?>
<span class="ld-sep">|</span>
<?php
endif;
$i++;
endforeach;
?>
</span>
</span>
</a> <!--/.ld-course-name-->
</div> <!--/.ld-course-preview-->
</div> <!--/.ld-course-list-item-->