Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor/templates/dashboard/my-courses.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
/**
3
+
* My Courses Page
4
+
*
5
+
* @package Tutor\Templates
6
+
* @subpackage Dashboard
7
+
* @author Themeum <support@themeum.com>
8
+
* @link https://themeum.com
9
+
* @since 1.4.3
10
+
*/
11
+
12
+
use TUTOR\Input;
13
+
use Tutor\Models\CourseModel;
14
+
15
+
// Get the user ID and active tab.
16
+
$current_user_id = get_current_user_id();
17
+
! isset( $active_tab ) ? $active_tab = 'my-courses' : 0;
18
+
19
+
// Map required course status according to page.
20
+
$status_map = array(
21
+
'my-courses' => CourseModel::STATUS_PUBLISH,
22
+
'my-courses/draft-courses' => CourseModel::STATUS_DRAFT,
23
+
'my-courses/pending-courses' => CourseModel::STATUS_PENDING,
24
+
'my-courses/schedule-courses' => CourseModel::STATUS_FUTURE,
25
+
);
26
+
27
+
// Set currently required course status fo rcurrent tab.
28
+
$status = isset( $status_map[ $active_tab ] ) ? $status_map[ $active_tab ] : CourseModel::STATUS_PUBLISH;
29
+
$post_type = apply_filters( 'tutor_dashboard_course_list_post_type', array( tutor()->course_post_type ) );
30
+
31
+
// Get counts for course tabs.
32
+
$count_map = array(
33
+
'publish' => CourseModel::get_courses_by_instructor( $current_user_id, CourseModel::STATUS_PUBLISH, 0, 0, true, $post_type ),
34
+
'pending' => CourseModel::get_courses_by_instructor( $current_user_id, CourseModel::STATUS_PENDING, 0, 0, true, $post_type ),
35
+
'draft' => CourseModel::get_courses_by_instructor( $current_user_id, CourseModel::STATUS_DRAFT, 0, 0, true, $post_type ),
36
+
'future' => CourseModel::get_courses_by_instructor( $current_user_id, CourseModel::STATUS_FUTURE, 0, 0, true, $post_type ),
37
+
);
38
+
39
+
$course_archive_arg = isset( $GLOBALS['tutor_course_archive_arg'] ) ? $GLOBALS['tutor_course_archive_arg']['column_per_row'] : null;
40
+
$courseCols = null === $course_archive_arg ? tutor_utils()->get_option( 'courses_col_per_row', 4 ) : $course_archive_arg;
41
+
$per_page = tutor_utils()->get_option( 'courses_per_page', 10 );
42
+
$paged = Input::get( 'current_page', 1, Input::TYPE_INT );
43
+
$offset = $per_page * ( $paged - 1 );
44
+
$results = CourseModel::get_courses_by_instructor( $current_user_id, $status, $offset, $per_page, false, $post_type );
45
+
$show_course_delete = true;
46
+
$post_type_query = Input::get( 'type', '' );
47
+
$post_type_args = $post_type_query ? array( 'type' => $post_type_query ) : array();
48
+
49
+
$tabs = array(
50
+
'publish' => array(
51
+
'title' => __( 'Publish', 'tutor' ),
52
+
'link' => 'my-courses',
53
+
),
54
+
'pending' => array(
55
+
'title' => __( 'Pending', 'tutor' ),
56
+
'link' => 'my-courses/pending-courses',
57
+
),
58
+
'draft' => array(
59
+
'title' => __( 'Draft', 'tutor' ),
60
+
'link' => 'my-courses/draft-courses',
61
+
),
62
+
'future' => array(
63
+
'title' => __( 'Schedule', 'tutor' ),
64
+
'link' => 'my-courses/schedule-courses',
65
+
),
66
+
);
67
+
68
+
if ( ! current_user_can( 'administrator' ) && ! tutor_utils()->get_option( 'instructor_can_delete_course' ) ) {
69
+
$show_course_delete = false;
70
+
}
71
+
?>
72
+
73
+
<div class="tutor-dashboard-my-courses">
74
+
<div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-16">
75
+
<?php esc_html_e( 'My Courses', 'tutor' ); ?>
76
+
</div>
77
+
78
+
<div class="tutor-dashboard-content-inner">
79
+
<div class="tutor-mb-32 tutor-w-100">
80
+
<ul class="tutor-nav">
81
+
<?php foreach ( $tabs as $key => $tab ) : ?>
82
+
<li class="tutor-nav-item">
83
+
<a class="tutor-nav-link<?php echo esc_attr( $tab['link'] === $active_tab ? ' is-active' : '' ); ?>" href="<?php echo esc_url( add_query_arg( $post_type_args, tutor_utils()->get_tutor_dashboard_page_permalink( $tab['link'] ) ) ); ?>">
84
+
<?php echo esc_html( $tab['title'] ); ?> <?php echo esc_html( '(' . $count_map[ $key ] . ')' ); ?>
85
+
</a>
86
+
</li>
87
+
<?php endforeach; ?>
88
+
<?php do_action( 'tutor_dashboard_my_courses_filter' ); ?>
89
+
</ul>
90
+
91
+
</div>
92
+
93
+
<!-- Course list -->
94
+
<?php
95
+
$placeholder_img = tutor()->url . 'assets/images/placeholder.svg';
96
+
97
+
if ( ! is_array( $results ) || ( ! count( $results ) && 1 == $paged ) ) {
98
+
tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() );
99
+
} else {
100
+
?>
101
+
<div class="tutor-grid tutor-grid-3">
102
+
<?php
103
+
global $post;
104
+
$tutor_nonce_value = wp_create_nonce( tutor()->nonce_action );
105
+
foreach ( $results as $post ) :
106
+
setup_postdata( $post );
107
+
108
+
$avg_rating = tutor_utils()->get_course_rating()->rating_avg;
109
+
$tutor_course_img = get_tutor_course_thumbnail_src();
110
+
$id_string_delete = 'tutor_my_courses_delete_' . $post->ID;
111
+
$row_id = 'tutor-dashboard-my-course-' . $post->ID;
112
+
$course_duration = get_tutor_course_duration_context( $post->ID, true );
113
+
$course_students = tutor_utils()->count_enrolled_users_by_course();
114
+
$is_main_instructor = CourseModel::is_main_instructor( $post->ID );
115
+
$course_edit_link = apply_filters( 'tutor_dashboard_course_list_edit_link', tutor_utils()->course_edit_link( $post->ID, tutor()->has_pro ? 'frontend' : 'backend' ), $post );
116
+
?>
117
+
118
+
<div id="<?php echo esc_attr( $row_id ); ?>" class="tutor-card tutor-course-card tutor-mycourse-<?php the_ID(); ?>">
119
+
<a href="<?php echo esc_url( get_the_permalink() ); ?>" class="tutor-d-block">
120
+
<div class="tutor-ratio tutor-ratio-16x9">
121
+
<img class="tutor-card-image-top" src="<?php echo empty( $tutor_course_img ) ? esc_url( $placeholder_img ) : esc_url( $tutor_course_img ); ?>" alt="<?php the_title(); ?>" loading="lazy">
122
+
</div>
123
+
</a>
124
+
125
+
<?php if ( false === $is_main_instructor ) : ?>
126
+
<div class="tutor-course-co-author-badge"><?php esc_html_e( 'Co-author', 'tutor' ); ?></div>
127
+
<?php endif; ?>
128
+
<div class="tutor-card-body">
129
+
<?php do_action( 'tutor_my_courses_before_meta', get_the_ID() ); ?>
130
+
<div class="tutor-meta tutor-mb-8">
131
+
<span>
132
+
<?php echo esc_html( get_the_date() ); ?> <?php echo esc_html( get_the_time() ); ?>
133
+
</span>
134
+
</div>
135
+
136
+
<div class="tutor-course-name tutor-fs-6 tutor-fw-bold tutor-mb-16">
137
+
<a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php the_title(); ?></a>
138
+
</div>
139
+
140
+
<?php if ( ! empty( $course_duration ) || ! empty( $course_students ) ) : ?>
141
+
<div class="tutor-meta tutor-mt-16">
142
+
<?php if ( ! empty( $course_duration ) ) : ?>
143
+
<div>
144
+
<span class="tutor-icon-clock-line tutor-meta-icon" area-hidden="true"></span>
145
+
<span class="tutor-meta-value">
146
+
<?php
147
+
echo wp_kses(
148
+
stripslashes( $course_duration ),
149
+
array(
150
+
'span' => array( 'class' => true ),
151
+
)
152
+
);
153
+
?>
154
+
</span>
155
+
</div>
156
+
<?php endif; ?>
157
+
158
+
<?php if ( ! empty( $course_students ) ) : ?>
159
+
<div>
160
+
<span class="tutor-icon-user-line tutor-meta-icon" area-hidden="true"></span>
161
+
<span class="tutor-meta-value">
162
+
<?php
163
+
echo wp_kses(
164
+
stripslashes( $course_students ),
165
+
array(
166
+
'span' => array( 'class' => true ),
167
+
)
168
+
);
169
+
?>
170
+
</span>
171
+
</div>
172
+
<?php endif; ?>
173
+
</div>
174
+
<?php endif; ?>
175
+
</div>
176
+
177
+
<div class="tutor-card-footer">
178
+
<div class="tutor-d-flex tutor-align-center tutor-justify-between">
179
+
<div class="tutor-d-flex tutor-align-center">
180
+
<span class="tutor-fs-7 tutor-fw-medium tutor-color-muted tutor-mr-4">
181
+
<?php
182
+
$membership_only_mode = apply_filters( 'tutor_membership_only_mode', false );
183
+
echo esc_html( $membership_only_mode ? __( 'Plan:', 'tutor' ) : '' );
184
+
?>
185
+
</span>
186
+
<span class="tutor-fs-7 tutor-fw-medium tutor-color-black">
187
+
<?php
188
+
$price = tutor_utils()->get_course_price();
189
+
if ( null === $price ) {
190
+
esc_html_e( 'Free', 'tutor' );
191
+
} else {
192
+
echo wp_kses_post( tutor_utils()->get_course_price() );
193
+
}
194
+
?>
195
+
</span>
196
+
</div>
197
+
<div class="tutor-iconic-btn-group tutor-mr-n8">
198
+
<a href="<?php echo esc_url( $course_edit_link ); ?>" class="tutor-iconic-btn tutor-my-course-edit">
199
+
<i class="tutor-icon-edit" area-hidden="true"></i>
200
+
</a>
201
+
<div class="tutor-dropdown-parent">
202
+
<button type="button" class="tutor-iconic-btn" action-tutor-dropdown="toggle">
203
+
<span class="tutor-icon-kebab-menu" area-hidden="true"></span>
204
+
</button>
205
+
<div id="table-dashboard-course-list-<?php echo esc_attr( $post->ID ); ?>" class="tutor-dropdown tutor-dropdown-dark tutor-text-left">
206
+
207
+
<!-- Submit Action -->
208
+
<?php if ( tutor()->has_pro && in_array( $post->post_status, array( CourseModel::STATUS_DRAFT ), true ) ) : ?>
209
+
<?php
210
+
$params = http_build_query(
211
+
array(
212
+
'tutor_action' => 'update_course_status',
213
+
'status' => CourseModel::STATUS_PENDING,
214
+
'course_id' => $post->ID,
215
+
tutor()->nonce => $tutor_nonce_value,
216
+
)
217
+
);
218
+
?>
219
+
<a class="tutor-dropdown-item" href="?<?php echo esc_attr( $params ); ?>">
220
+
<i class="tutor-icon-share tutor-mr-8" area-hidden="true"></i>
221
+
<span>
222
+
<?php
223
+
$can_publish_course = current_user_can( 'administrator' ) || (bool) tutor_utils()->get_option( 'instructor_can_publish_course' );
224
+
if ( $can_publish_course ) {
225
+
esc_html_e( 'Publish', 'tutor' );
226
+
} else {
227
+
esc_html_e( 'Submit', 'tutor' );
228
+
}
229
+
?>
230
+
</span>
231
+
</a>
232
+
<?php endif; ?>
233
+
<!-- # Submit Action -->
234
+
235
+
<!-- Duplicate Action -->
236
+
<?php if ( tutor()->has_pro && in_array( $post->post_status, array( CourseModel::STATUS_PUBLISH, CourseModel::STATUS_PENDING, CourseModel::STATUS_DRAFT, CourseModel::STATUS_FUTURE ) ) ) : ?>
237
+
<?php
238
+
$params = http_build_query(
239
+
array(
240
+
'tutor_action' => 'duplicate_course',
241
+
'course_id' => $post->ID,
242
+
)
243
+
);
244
+
?>
245
+
<a class="tutor-dropdown-item" href="?<?php echo esc_attr( $params ); ?>">
246
+
<i class="tutor-icon-copy-text tutor-mr-8" area-hidden="true"></i>
247
+
<span><?php esc_html_e( 'Duplicate', 'tutor' ); ?></span>
248
+
</a>
249
+
<?php endif; ?>
250
+
<!-- # Duplicate Action -->
251
+
252
+
<!-- Move to Draf Action -->
253
+
<?php if ( tutor()->has_pro && in_array( $post->post_status, array( CourseModel::STATUS_PUBLISH, CourseModel::STATUS_FUTURE ) ) ) : ?>
254
+
<?php
255
+
$params = http_build_query(
256
+
array(
257
+
'tutor_action' => 'update_course_status',
258
+
'status' => CourseModel::STATUS_DRAFT,
259
+
'course_id' => $post->ID,
260
+
tutor()->nonce => $tutor_nonce_value,
261
+
)
262
+
);
263
+
?>
264
+
<a class="tutor-dropdown-item" href="?<?php echo esc_attr( $params ); ?>">
265
+
<i class="tutor-icon-archive tutor-mr-8" area-hidden="true"></i>
266
+
<span><?php esc_html_e( 'Move to Draft', 'tutor' ); ?></span>
267
+
</a>
268
+
<?php endif; ?>
269
+
<!-- # Move to Draft Action -->
270
+
271
+
<!-- Cancel Submission -->
272
+
<?php if ( tutor()->has_pro && in_array( $post->post_status, array( CourseModel::STATUS_PENDING ) ) ) : ?>
273
+
<?php
274
+
$params = http_build_query(
275
+
array(
276
+
'tutor_action' => 'update_course_status',
277
+
'status' => CourseModel::STATUS_DRAFT,
278
+
'course_id' => $post->ID,
279
+
tutor()->nonce => $tutor_nonce_value,
280
+
)
281
+
);
282
+
?>
283
+
<a href="?<?php echo esc_attr( $params ); ?>" class="tutor-dropdown-item">
284
+
<i class="tutor-icon-times tutor-mr-8" area-hidden="true"></i>
285
+
<span><?php esc_html_e( 'Cancel Submission', 'tutor' ); ?></span>
286
+
</a>
287
+
<?php endif; ?>
288
+
<!-- # Cancel Submission -->
289
+
290
+
<!-- Delete Action -->
291
+
<?php if ( $is_main_instructor && in_array( $post->post_status, array( CourseModel::STATUS_PUBLISH, CourseModel::STATUS_DRAFT, CourseModel::STATUS_FUTURE ) ) ) : ?>
292
+
<?php if ( $show_course_delete ) : ?>
293
+
<a href="#" data-tutor-modal-target="<?php echo esc_attr( $id_string_delete ); ?>" class="tutor-dropdown-item tutor-admin-course-delete">
294
+
<i class="tutor-icon-trash-can-bold tutor-mr-8" area-hidden="true"></i>
295
+
<span><?php esc_html_e( 'Delete', 'tutor' ); ?></span>
296
+
</a>
297
+
<?php endif; ?>
298
+
<?php endif; ?>
299
+
<!-- # Delete Action -->
300
+
301
+
</div>
302
+
</div>
303
+
</div>
304
+
</div>
305
+
</div>
306
+
307
+
<!-- Delete prompt modal -->
308
+
<div id="<?php echo esc_attr( $id_string_delete ); ?>" class="tutor-modal">
309
+
<div class="tutor-modal-overlay"></div>
310
+
<div class="tutor-modal-window">
311
+
<div class="tutor-modal-content tutor-modal-content-white">
312
+
<button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close>
313
+
<span class="tutor-icon-times" area-hidden="true"></span>
314
+
</button>
315
+
316
+
<div class="tutor-modal-body tutor-text-center">
317
+
<div class="tutor-mt-48">
318
+
<img class="tutor-d-inline-block" src="<?php echo esc_attr( tutor()->url ); ?>assets/images/icon-trash.svg" />
319
+
</div>
320
+
321
+
<div class="tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mb-12"><?php esc_html_e( 'Delete This Course?', 'tutor' ); ?></div>
322
+
<div class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Are you sure you want to delete this course permanently from the site? Please confirm your choice.', 'tutor' ); ?></div>
323
+
324
+
<div class="tutor-d-flex tutor-justify-center tutor-my-48">
325
+
<button data-tutor-modal-close class="tutor-btn tutor-btn-outline-primary">
326
+
<?php esc_html_e( 'Cancel', 'tutor' ); ?>
327
+
</button>
328
+
<button class="tutor-btn tutor-btn-primary tutor-list-ajax-action tutor-ml-20" data-request_data='{"course_id":<?php echo esc_attr( $post->ID ); ?>,"action":"tutor_delete_dashboard_course","redirect_to":"<?php echo esc_url( tutor_utils()->get_current_url() ); ?>"}' data-delete_element_id="<?php echo esc_attr( $row_id ); ?>">
329
+
<?php esc_html_e( 'Yes, Delete This', 'tutor' ); ?>
330
+
</button>
331
+
</div>
332
+
</div>
333
+
</div>
334
+
</div>
335
+
</div>
336
+
</div>
337
+
<?php
338
+
endforeach;
339
+
wp_reset_postdata();
340
+
?>
341
+
</div>
342
+
<div class="tutor-mt-20">
343
+
<?php
344
+
if ( $count_map[ $status ] > $per_page ) {
345
+
$pagination_data = array(
346
+
'total_items' => $count_map[ $status ],
347
+
'per_page' => $per_page,
348
+
'paged' => $paged,
349
+
);
350
+
351
+
tutor_load_template_from_custom_path(
352
+
tutor()->path . 'templates/dashboard/elements/pagination.php',
353
+
$pagination_data
354
+
);
355
+
}
356
+
?>
357
+
358
+
</div>
359
+
<?php
360
+
}
361
+
?>
362
+
</div>
363
+
</div>
364
+