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.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / templates / learning-area / subpages / course-info.php
tutor / templates / learning-area / subpages Last commit date
qna 5 days ago reviews 5 days ago announcements.php 5 days ago course-info.php 5 days ago qna.php 5 days ago reviews.php 5 days ago
course-info.php
291 lines
1 <?php
2 /**
3 * Tutor learning area course info.
4 *
5 * @package Tutor\Templates
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 4.0.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 use Tutor\Components\Avatar;
14 use Tutor\Components\Badge;
15 use Tutor\Components\Constants\Color;
16 use Tutor\Components\Constants\Variant;
17 use Tutor\Components\StarRating;
18 use Tutor\Components\SvgIcon;
19 use TUTOR\Icon;
20
21 // Globals inherited from learning-area/index.php template.
22 global $tutor_course_id,
23 $tutor_course,
24 $current_user_id;
25
26 $course_thumbnail = get_tutor_course_thumbnail_src( 'full', $tutor_course_id );
27 $course_author = get_user( $tutor_course->post_author );
28 $course_benefits = tutor_course_benefits( $tutor_course_id );
29 $instructors = tutor_utils()->get_instructors_by_course( $tutor_course_id );
30 $course_rating = tutor_utils()->get_course_rating( $tutor_course_id );
31 $course_materials = tutor_course_material_includes( $tutor_course_id );
32 $course_attachments = tutor_utils()->get_attachments( $tutor_course_id );
33 $course_tags = get_tutor_course_tags( $tutor_course_id );
34 $course_categories = get_tutor_course_categories( $tutor_course_id );
35 $category_list = ! empty( $course_categories ) && is_array( $course_categories )
36 ? implode( ', ', array_column( $course_categories, 'name' ) ) : '';
37 $course_requirements = tutor_course_requirements( $tutor_course_id );
38 $course_target_audience = tutor_course_target_audience( $tutor_course_id );
39
40
41
42 ob_start();
43 foreach ( $instructors as $key => $instructor ) {
44 ?>
45 <div class="tutor-flex tutor-items-center tutor-sm-items-start tutor-gap-5 tutor-sm-gap-4 tutor-mb-6">
46 <?php Avatar::make()->user( $instructor->ID )->size( 'md' )->render(); ?>
47
48 <div class="tutor-flex tutor-flex-column tutor-gap-2 tutor-sm-gap-1">
49 <div class="tutor-medium tutor-font-medium tutor-sm-text-small">
50 <?php echo esc_html( $instructor->display_name ); ?>
51 </div>
52 <?php if ( ! empty( $instructor->tutor_profile_job_title ) ) : ?>
53 <div class="tutor-tiny tutor-text-secondary">
54 <?php echo esc_html( $instructor->tutor_profile_job_title ); ?>
55 </div>
56 <?php endif; ?>
57 </div>
58 </div>
59 <?php
60 }
61
62 $instructors_content = ob_get_clean();
63
64 $default_meta = array(
65 array(
66 'icon' => Icon::INSTRUCTOR,
67 'title' => __( 'Instructors', 'tutor' ),
68 'content' => $instructors_content,
69 ),
70 );
71
72 // Helper function to add meta to the default meta array.
73 $add_meta = function ( string $icon, string $title, string $content ) use ( &$default_meta ) {
74 if ( ! empty( $content ) ) {
75 $default_meta[] = array(
76 'icon' => $icon,
77 'title' => $title,
78 'content' => $content,
79 );
80 }
81 };
82
83 // Helper function to render list content.
84 $render_list = function ( $items ) {
85 $list = implode(
86 '',
87 array_map(
88 fn( $item ) => '<li>' . esc_html( $item ) . '</li>',
89 $items
90 )
91 );
92 return "<ul>{$list}</ul>";
93 };
94
95 // Course categories.
96 if ( ! empty( $category_list ) ) {
97 $add_meta( Icon::CATEGORIES, __( 'Categories', 'tutor' ), $category_list );
98 }
99
100 if ( tutor_utils()->get_option( 'enable_course_total_enrolled' ) ) {
101
102 $course_enrolled_count = sprintf(
103 // translators: %s is the total enrolled users count.
104 _n( '%s Student', '%s Students', tutor_utils()->count_enrolled_users_by_course(), 'tutor' ),
105 tutor_utils()->count_enrolled_users_by_course()
106 );
107
108 $add_meta( Icon::PASSED, __( 'Total Enrolled', 'tutor' ), $course_enrolled_count );
109 }
110
111 if ( tutor_utils()->get_option( 'enable_course_level', true, true ) ) {
112 $add_meta( Icon::LEVEL, __( 'Level', 'tutor' ), get_tutor_course_level( $tutor_course_id ) );
113 }
114
115 if ( tutor_utils()->get_option( 'enable_course_duration', true, true ) ) {
116 $add_meta( Icon::TIME, __( 'Duration', 'tutor' ), get_tutor_course_duration_context( $tutor_course_id ) );
117 }
118
119 // Ratings.
120 $rating_content = StarRating::make()->count( $course_rating->rating_count )->rating( $course_rating->rating_avg )->show_average( true )->get();
121 $add_meta( Icon::RATINGS, __( 'Student Ratings', 'tutor' ), $rating_content );
122
123 // Resources.
124 $resource_content = sprintf(
125 // translators: %s is the total attachments count.
126 _n( '%s File', '%s Files', count( $course_attachments ), 'tutor' ),
127 count( $course_attachments )
128 );
129 $add_meta( Icon::RESOURCES, __( 'Resources', 'tutor' ), $resource_content );
130
131 // Course Tags Contents.
132 ob_start();
133 if ( ! empty( $course_tags ) && is_array( $course_tags ) ) {
134 ?>
135 <div class="tutor-flex tutor-items-start tutor-flex-wrap tutor-gap-3">
136 <?php
137 foreach ( $course_tags as $key => $tags ) {
138 Badge::make()
139 ->label( $tags->name )
140 ->variant( Variant::SECONDARY )
141 ->render();
142 }
143 ?>
144 </div>
145 <?php
146 }
147 $course_tag_contents = ob_get_clean();
148
149 if ( ! empty( $course_tag_contents ) ) {
150 $add_meta( Icon::TAG, __( 'Tags', 'tutor' ), $course_tag_contents );
151 }
152
153 // Course materials.
154 if ( ! empty( $course_materials ) && is_array( $course_materials ) ) {
155 $add_meta( Icon::MATERIAL, __( 'Materials', 'tutor' ), $render_list( $course_materials ) );
156 }
157
158 // Course Requirements.
159 if ( ! empty( $course_requirements ) && is_array( $course_requirements ) ) {
160 $add_meta( Icon::REQUIREMENTS, __( 'Requirements', 'tutor' ), $render_list( $course_requirements ) );
161 }
162
163 // Course Target Audience.
164 if ( ! empty( $course_target_audience ) && is_array( $course_target_audience ) ) {
165 $add_meta( Icon::AUDIENCE, __( 'Audience', 'tutor' ), $render_list( $course_target_audience ) );
166 }
167
168 $metadata = apply_filters( 'tutor_learning_area_course_info_metadata', $default_meta, $tutor_course_id );
169 ?>
170 <div class="tutor-course-info tutor-pt-4" x-data="tutorCourseCompleteHandler">
171 <?php do_action( 'tutor_learning_area_before_course_info', $tutor_course_id ); ?>
172
173 <div class="tutor-course-thumb">
174 <img src="<?php echo esc_url( $course_thumbnail ); ?>" alt="<?php echo esc_attr( $tutor_course->post_title ); ?>" />
175 </div>
176
177 <div class="tutor-course-intro">
178 <div class="tutor-flex tutor-items-center tutor-justify-center tutor-gap-3 tutor-tiny tutor-text-secondary">
179 <?php SvgIcon::make()->name( Icon::CALENDAR_CHECK )->color( Color::BRAND )->render(); ?>
180 <?php
181 echo esc_html(
182 sprintf(
183 // translators: %s is the course last modified date.
184 __( '%s Last Updated', 'tutor' ),
185 tutor_i18n_get_formated_date( $tutor_course->post_modified )
186 )
187 );
188 ?>
189 </div>
190 <h3 class="tutor-h3 tutor-sm-text-h5 tutor-mt-3"><?php echo esc_html( $tutor_course->post_title ); ?></h3>
191 <div class="tutor-medium tutor-sm-text-small tutor-text-secondary tutor-mt-4 tutor-mb-6">
192 <?php
193 printf(
194 wp_kses(
195 // translators: %s is the linked course author name.
196 __( 'by %s', 'tutor' ),
197 array(
198 'a' => array(
199 'href' => true,
200 'class' => true,
201 ),
202 )
203 ),
204 sprintf(
205 '<a href="%1$s">%2$s</a>',
206 esc_url( tutor_utils()->profile_url( $course_author, true ) ),
207 esc_html( $course_author->display_name )
208 )
209 );
210 ?>
211 </div>
212 </div>
213
214 <!-- TODO: sticky behaviour -->
215 <!-- <div class="tutor-course-sticky-card tutor-mt-9">
216 <div class="tutor-course-thumb">
217 <img src="<?php echo esc_url( $course_thumbnail ); ?>" alt="course thumb" />
218 </div>
219 <div class="tutor-flex tutor-flex-column tutor-gap-2">
220 <h5 class="tutor-h5 tutor-sm-text-medium"><?php echo esc_html( $tutor_course->post_title ); ?></h5>
221 <div class="tutor-medium tutor-sm-text-small tutor-text-secondary">
222 <?php
223 echo esc_html(
224 sprintf(
225 // translators: %s is the course author name.
226 __( 'by %s', 'tutor' ),
227 $course_author->display_name
228 )
229 );
230 ?>
231 </div>
232 </div>
233 </div> -->
234
235 <div class="tutor-course-info-cards">
236 <?php if ( ! empty( get_the_content() ) || ! empty( $course_benefits ) ) : ?>
237 <?php if ( ! empty( get_the_content() ) ) : ?>
238 <div class="tutor-card">
239 <div class="tutor-medium tutor-font-medium">
240 <?php esc_html_e( 'About this Course', 'tutor' ); ?>
241 </div>
242 <div class="tutor-p3">
243 <?php the_content(); ?>
244 </div>
245 </div>
246 <?php endif; ?>
247
248 <?php if ( ! empty( $course_benefits ) && is_array( $course_benefits ) ) : ?>
249 <div class="tutor-card">
250 <div class="tutor-medium tutor-font-medium">
251 <?php esc_html_e( "What you'll learn", 'tutor' ); ?>
252 </div>
253 <div class="tutor-course-info-list tutor-mt-6">
254 <?php foreach ( $course_benefits as $benefit ) : ?>
255 <div class="tutor-course-info-list-item">
256 <?php SvgIcon::make()->name( Icon::CHECK_2 )->render(); ?>
257 <div class="tutor-course-info-list-content">
258 <?php echo esc_html( $benefit ); ?>
259 </div>
260 </div>
261 <?php endforeach; ?>
262 </div>
263 </div>
264 <?php endif; ?>
265 <?php endif; ?>
266 </div>
267
268 <div class="tutor-course-info-table tutor-table-wrapper tutor-table-bordered tutor-table-column-borders tutor-mt-4">
269 <table class="tutor-table tutor-surface-l1">
270 <?php foreach ( $metadata as $meta ) : ?>
271 <tr>
272 <td>
273 <div class="tutor-flex tutor-items-center tutor-gap-4 tutor-sm-gap-3">
274 <?php SvgIcon::make()->name( $meta['icon'] )->size( 20 )->render(); ?>
275 <?php echo esc_html( $meta['title'] ); ?>
276 </div>
277 </td>
278
279 <td>
280 <?php
281 add_filter( 'wp_kses_allowed_html', 'TUTOR\Input::allow_svg' );
282 echo wp_kses_post( $meta['content'] );
283 remove_filter( 'wp_kses_allowed_html', 'TUTOR\Input::allow_svg' );
284 ?>
285 </td>
286 </tr>
287 <?php endforeach ?>
288 </table>
289 </div>
290 </div>
291