-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·689 lines (553 loc) · 22.4 KB
/
functions.php
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
<?php
/**
* CPE 365 Theme functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package CPE 365
* @since 1.0.0
*/
if (!function_exists("dd")) {
function dd($data, $exit_data = true)
{
echo '<pre>' . print_r($data, true) . '</pre>';
if ($exit_data == false) {
echo '';
} else {
exit;
}
}
}
/**
* Define Constants
*/
define('CHILD_THEME_CPE_365_VERSION', '1.0.0');
define('ASSETS_VERSION', time());
define('CPE_ASSETS', get_stylesheet_directory_uri() . "/assets");
define('CPE_DIR', trailingslashit(get_stylesheet_directory()));
define('CPE_LANG', "cpe-lang");
require_once CPE_DIR . "admin/admin-settings.php";
require_once CPE_DIR . "shortcodes/cpe_user_available_courses.php";
require_once CPE_DIR . "shortcodes/cpe_user_certificates.php";
require_once CPE_DIR . "shortcodes/cpe_user_completed_courses.php";
require_once CPE_DIR . "shortcodes/cpe_user_in_progress_courses.php";
require_once CPE_DIR . "shortcodes/cpe_user_profile.php";
require_once CPE_DIR . "shortcodes/cpe_credits_info.php";
require_once CPE_DIR . "paid-memberships-pro/user-credits.php";
add_action('after_setup_theme', 'cpe_theme_after_setup');
function cpe_theme_after_setup()
{
register_nav_menus(array(
'user_menu' => __("User Dashboard Menu", CPE_LANG),
));
}
require CPE_DIR . 'paid-memberships-pro' . DIRECTORY_SEPARATOR . 'cpe-custom-shortcodes.php';
/**
* Enqueue styles
*/
function child_enqueue_styles()
{
wp_enqueue_style('bootstrap-css', CPE_ASSETS . '/css/bootstrap.min.css', array(), ASSETS_VERSION, 'all');
wp_enqueue_style('fontawesome-css', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', array(), CHILD_THEME_CPE_365_VERSION, 'all');
wp_enqueue_style('tooltipster-css', CPE_ASSETS . '/tooltipster/css/tooltipster.bundle.min.css', array(), ASSETS_VERSION, 'all');
wp_enqueue_style('datatables-bt-css', CPE_ASSETS . '/css/dataTables.bootstrap.min.css', array(), ASSETS_VERSION, 'all');
wp_enqueue_style('cpe-365-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), ASSETS_VERSION, 'all');
wp_enqueue_script('tooltipster-js', CPE_ASSETS . '/tooltipster/js/tooltipster.bundle.min.js', array('jquery'), ASSETS_VERSION, true);
wp_enqueue_script('datatables-js', CPE_ASSETS . '/js/jquery.dataTables.min.js', array('jquery'), ASSETS_VERSION, true);
wp_enqueue_script('datatables-bt-js', CPE_ASSETS . '/js/dataTables.bootstrap.min.js', array('jquery'), ASSETS_VERSION, true);
wp_enqueue_script('cpe-365-js', CPE_ASSETS . '/js/script.js', array('jquery'), ASSETS_VERSION, true);
}
add_action('wp_enqueue_scripts', 'child_enqueue_styles', 15);
/**
* Enqueue scripts
*
* @param string $handle Script name
* @param string $src Script url
* @param array $deps (optional) Array of script names on which this script depends
* @param string|bool $ver (optional) Script version (used for cache busting), set to null to disable
* @param bool $in_footer (optional) Whether to enqueue the script before </head> or before </body>
*/
function theme_name_scripts() {
wp_enqueue_style('cpe-365-css', CPE_ASSETS . '/admin/css/style.css', array(), ASSETS_VERSION, 'all');
wp_enqueue_script( 'cpe-365-admin-js', CPE_ASSETS . '/admin/js/script.js', array( 'jquery' ), ASSETS_VERSION, true );
}
add_action( 'admin_enqueue_scripts', 'theme_name_scripts' );
add_filter("body_class", "woo_add_body_classes", 999, 2);
function woo_add_body_classes($classes, $class)
{
if (is_tax("ld_course_category")) {
$classes[] = "ast-left-sidebar";
}
return $classes;
}
function filter_ld_tax_posts($query)
{
if (!is_admin() && $query->is_main_query() && $query->is_archive()) {
if (is_tax("ld_course_category")) {
$lists_style = isset($_GET["list_style"]) && !empty($_GET["list_style"]) ? $_GET["list_style"] : "list";
$query->set('order', 'ASC');
$query->set('orderby', 'title');
if ($lists_style == "list") {
$query->set('posts_per_page', 50);
}
}
}
}
add_action('pre_get_posts', 'filter_ld_tax_posts');
/*
* custom pagination with bootstrap .pagination class
* source: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
*/
function bootstrap_pagination($echo = true)
{
global $wp_query;
$big = 999999999; // need an unlikely integer
$pages = paginate_links(
array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages,
'type' => 'array',
'prev_next' => true,
'prev_text' => __('« Prev'),
'next_text' => __('Next »'),
)
);
if (is_array($pages)) {
$paged = (get_query_var('paged') == 0) ? 1 : get_query_var('paged');
$pagination = '<ul class="pagination pagination-sm">';
foreach ($pages as $page) {
$pagination .= "<li>$page</li>";
}
$pagination .= '</ul>';
if ($echo) {
echo $pagination;
} else {
return $pagination;
}
}
}
add_action('add_meta_boxes', 'learndash_course_cpe_meta_box');
/**
* Add course grid settings meta box
*/
function learndash_course_cpe_meta_box()
{
add_meta_box(
'learndash-course-extras-meta-box',
__('Course Extra Settings', 'learndash-course-grid'),
'learndash_course_extras_output_meta_box',
array('sfwd-courses'),
'advanced',
'low',
array()
);
}
/**
* Output course grid settings meta box
*
* @param array $args List or args passed on callback function
*/
function learndash_course_extras_output_meta_box($args)
{
$post_id = get_the_ID();
$post = get_post($post_id);
$instructor = get_post_meta($post_id, '_learndash_course_instructor', true);
$cpe_credits = get_post_meta($post_id, '_learndash_course_cpe_credits', true);
$cpe_term = get_option( "cpe_term", "CPE" );
wp_nonce_field('learndash_course_extra_save', 'learndash_course_extra_nonce');
?>
<div class="sfwd sfwd_options">
<div class="sfwd_input">
<span class="sfwd_option_label" style="text-align:right;vertical-align:top;">
<a class="sfwd_help_text_link" style="cursor:pointer;" title="Click for Help!" onclick="toggleVisibility('learndash_course_cpe_text');"><img src="<?php echo LEARNDASH_LMS_PLUGIN_URL . 'assets/images/question.png' ?>">
<label class="sfwd_label textinput"><?php _e($cpe_term . ' Credits', 'learndash-course-grid'); ?></label></a>
</span>
<span class="sfwd_option_input">
<div class="sfwd_option_div">
<input name="learndash_course_cpe_credits" type="text" value="<?php echo esc_attr($cpe_credits); ?>"></textarea>
</div>
<div class="sfwd_help_text_div" style="display:none" id="learndash_course_cpe_text">
<label class="sfwd_help_text"><?php _e('Use this field to change the '.$cpe_term.' credits value.', 'learndash-course-grid'); ?>
</label>
</div>
</span>
<p style="clear:left"></p>
</div>
<div class="sfwd_input">
<span class="sfwd_option_label" style="text-align:right;vertical-align:top;">
<a class="sfwd_help_text_link" style="cursor:pointer;" title="Click for Help!" onclick="toggleVisibility('learndash_course_instructor_text');"><img src="<?php echo LEARNDASH_LMS_PLUGIN_URL . 'assets/images/question.png' ?>">
<label class="sfwd_label textinput"><?php _e('Instructor', 'learndash-course-grid'); ?></label></a>
</span>
<span class="sfwd_option_input">
<div class="sfwd_option_div">
<input name="learndash_course_instructor" type="text" value="<?php echo esc_attr($instructor); ?>"></textarea>
</div>
<div class="sfwd_help_text_div" style="display:none" id="learndash_course_instructor_text">
<label class="sfwd_help_text"><?php _e('Use this field to change the Instructor of the course.', 'learndash-course-grid'); ?>
</label>
</div>
</span>
<p style="clear:left"></p>
</div>
</div>
<?php
}
add_action('save_post', 'learndash_course_extras_save_meta_box', 10, 3);
/**
* Save course grid meta box fields
*
* @param int $post_id Post ID
* @param object $post WP post object
* @param bool $update True if post is an update
*/
function learndash_course_extras_save_meta_box($post_id, $post, $update)
{
if (!in_array($post->post_type, array('sfwd-courses'))) {
return;
}
if (wp_is_post_revision($post_id)) {
return;
}
if (!isset($_POST['learndash_course_extra_nonce'])) {
return;
}
if (!wp_verify_nonce($_POST['learndash_course_extra_nonce'], 'learndash_course_extra_save')) {
wp_die(__('Cheatin\' huh?'));
}
update_post_meta($post_id, '_learndash_course_cpe_credits', wp_filter_kses($_POST['learndash_course_cpe_credits']));
update_post_meta($post_id, '_learndash_course_instructor', wp_filter_kses($_POST['learndash_course_instructor']));
}
add_filter('pre_get_posts', "filter_pre_posts_course_tax_page", 5);
function filter_pre_posts_course_tax_page()
{
if (is_tax("ld_course_category")) {
remove_filter('pre_get_posts', 'pmpro_search_filter', 10);
}
}
add_action("learndash-course-infobar-action-cell-after", "course_add_sub_option", 99, 3);
function course_add_sub_option($post_type, $course_id, $user_id)
{
if ($post_type != "sfwd-courses") {
return;
}
$level_course_option = get_option('_level_course_option');
$pmpro_levels_page_id = get_option("pmpro_levels_page_id", 0);
$course_pricing = learndash_get_course_price($course_id);
$meta = get_post_meta($course_id, '_sfwd-courses', true);
$custom_button_url = @$meta['sfwd-courses_custom_button_url'];
if (array_key_exists($course_id, $level_course_option) && !empty($level_course_option[$course_id]) && $pmpro_levels_page_id != 0) {
?>
<?php if ($custom_button_url != "") : ?>
<p style="margin: 5px 0px;">
<?php _e('OR', 'learndash'); ?>
</p>
<?php endif; ?>
<a class="btn-join" href="<?php echo get_permalink($pmpro_levels_page_id); ?>" style="margin: 5px 0px;">
<?php _e('Buy a Subscription', 'learndash'); ?>
</a>
<?php
}
}
add_filter("learndash_get_label", "woo_learndash_set_label", 999, 2);
function woo_learndash_set_label($label, $key)
{
switch ($key) {
case 'button_take_this_course':
$label = esc_html__('Purchase Course', 'learndash');
break;
}
return $label;
}
add_filter("pmpro_not_logged_in_text_filter", function ($content) {
global $post;
if ($post->post_type == "sfwd-courses") {
return "";
}
return $content;
});
function get_course_plans($course_id, $count = false)
{
global $wpdb;
$query = "SELECT * FROM {$wpdb->pmpro_memberships_pages} WHERE `page_id` = $course_id";
$result = $wpdb->get_results($query);
if ($count && !empty($result)) {
return count($result);
} elseif ($count && empty($result)) {
return false;
} elseif (!$count && empty($result)) {
return false;
} elseif (!$count && !empty($result)) {
return $result;
}
}
add_action("learndash-course-before", "cpe_course_breadcrumbs", 9, 3);
function cpe_course_breadcrumbs($post_id, $course_id, $user_id)
{
if ("sfwd-courses" != get_post_type($post_id)) {
return;
}
global $post;
$user_id = get_current_user_id();
$post_id = $post->ID;
$term_list = wp_get_post_terms($post_id, 'ld_course_category', array("fields" => "all"));
$account_page_id = pmpro_getOption( "account_page_id" );
$account_page = get_page( $account_page_id );
$redirect_page = get_page_by_path( "{$account_page->post_name}/available-courses" );
$user_sub = pmpro_getMembershipLevelForUser( $user_id);
$has_credits = cpe_get_post_user_credits( $user_id, $post_id );
?>
<div class="learndash-breadcrumbs">
<?php
if( is_user_logged_in() ) { ?>
<?php if( !empty($user_sub) ) : ?>
<a href="<?php echo esc_url( get_permalink( $redirect_page ) ); ?>" class="user-progress-btn user-back-link learndash_mark_complete_button">
<i class="fa fa-angle-double-left" aria-hidden="true"></i> <?php _e( 'Go to Available Courses' ); ?>
</a>
<?php endif; ?>
<ol class="breadcrumb course-breadcrumb">
<li><a href="<?php echo esc_url( get_permalink( $account_page_id ) ); ?>"><?php _e("My Account"); ?></a></li>
<li><a href="<?php echo esc_url( get_permalink( $redirect_page ) ); ?>"><?php _e( 'Available Courses' ); ?></a></li>
<li class="active"><?php echo get_the_title($course_id); ?></li>
</ol>
<?php
} else {
?>
<ol class="breadcrumb course-breadcrumb">
<li><a href="<?php echo home_url("/") ?>"><?php _e("Home"); ?></a></li>
<?php
if (!empty($term_list)) {
?>
<li><a href="<?php echo get_term_link($term_list[0]->term_id, $term_list[0]->taxonomy) ?>"><?php echo $term_list[0]->name; ?></a></li>
<?php
}
?>
<li class="active"><?php echo get_the_title($course_id); ?></li>
</ol>
<?php
}
if ( is_user_logged_in() && sfwd_lms_has_access( $post_id, $user_id ) ) {
$progress = learndash_course_progress(array(
'user_id' => $user_id,
'course_id' => $post_id,
'array' => true
));
$btn_link = woo_user_course_resume_link( $post_id, $user_id );
if( $progress["percentage"] == 100 ) {
$btn_text = __("Completed");
$course_certficate_link = learndash_get_course_certificate_link( $post_id, $user_id );
if( $course_certficate_link ) {
$btn_link = $course_certficate_link;
}
}
else if ($progress["percentage"] > 0 || $has_credits && $btn_link) {
$btn_text = __("Resume");
} else {
$btn_text = __("Start");
$course_lessons = learndash_course_get_steps_by_type($post_id, 'sfwd-lessons');
if (function_exists('learndash_get_step_permalink')) {
$permalink = learndash_get_step_permalink($course_lessons[0], $post_id);
} else {
$permalink = get_permalink($course_lessons[0]);
}
if( !$has_credits ) {
$permalink = add_query_arg(array("cpe_access" => "grant_access"), $permalink);
}
$btn_link = $permalink;
}
?>
<a href="<?php echo $btn_link; ?>" class="user-progress-btn learndash_mark_complete_button"><?php echo $btn_text; ?></a>
<?php
}
?>
</div>
<?php
}
function woo_user_course_resume_link( $step_course_id, $user_id )
{
$step_id = get_user_meta($user_id, 'learndash_last_known_course_' . $step_course_id, true);
if (empty($step_id)) {
return false;
}
$last_know_post_object = get_post($step_id);
if (null !== $last_know_post_object) {
if (function_exists('learndash_get_step_permalink')) {
$permalink = learndash_get_step_permalink($step_id, $step_course_id);
} else {
$permalink = get_permalink($step_id);
}
return $permalink;
}
return false;
}
add_filter("ld_course_list_shortcode_attr_defaults", "filter_course_list_args", 99, 1);
function filter_course_list_args($attr)
{
$attr["list_type"] = "";
return $attr;
}
add_filter("learndash_ld_course_list_query_args", "cpe_learndash_filter_inprogress_user_courses", 999, 2);
function cpe_learndash_filter_inprogress_user_courses($data, $atts) {
if ($atts["list_type"] == "in_progress" && $atts["mycourses"] == "enrolled") {
$posts_in_courses = array();
$user_enrolled_courses = learndash_user_get_enrolled_courses($atts['user_id']);
if (empty($user_enrolled_courses)) {
return $data;
}
foreach ($user_enrolled_courses as $key => $enrolled_course_id) {
$progress = learndash_course_progress(array(
'user_id' => $atts['user_id'],
'course_id' => $enrolled_course_id,
'array' => true
));
if ($progress['percentage'] > 0 && $progress['percentage'] !== 100) {
if (sfwd_lms_has_access($enrolled_course_id, $atts['user_id'])) {
array_push($posts_in_courses, $enrolled_course_id);
}
}
}
$data['post__in'] = !empty($posts_in_courses) ? $posts_in_courses : array(0);
}
if ($atts["list_type"] == "completed" && $atts["mycourses"] == "enrolled") {
$posts_in_courses = array();
$user_enrolled_courses = learndash_user_get_enrolled_courses($atts['user_id']);
if (empty($user_enrolled_courses)) {
return $data;
}
foreach ($user_enrolled_courses as $key => $enrolled_course_id) {
$progress = learndash_course_progress(array(
'user_id' => $atts['user_id'],
'course_id' => $enrolled_course_id,
'array' => true
));
if ($progress['percentage'] == 100) {
array_push($posts_in_courses, $enrolled_course_id);
}
}
$data['post__in'] = !empty($posts_in_courses) ? $posts_in_courses : array(0);
}
if ($atts["list_type"] == "available" && $atts["mycourses"] == "enrolled") {
$posts_in_courses = array();
$user_enrolled_courses = learndash_user_get_enrolled_courses($atts['user_id']);
if (empty($user_enrolled_courses)) {
return $data;
}
foreach ($user_enrolled_courses as $key => $enrolled_course_id) {
$progress = learndash_course_progress(array(
'user_id' => $atts['user_id'],
'course_id' => $enrolled_course_id,
'array' => true
));
if ($progress['percentage'] == 100) {
array_push($posts_in_courses, $enrolled_course_id);
}
}
$data['post__in'] = !empty($posts_in_courses) ? $posts_in_courses : array(0);
}
return $data;
}
//add_filter( "template_include", "unaib_filter_ld_focus_mode_template", 9999, 1 );
function unaib_filter_ld_focus_mode_template($template){
$focus_mode = LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Theme_LD30', 'focus_mode_enabled');
if ($focus_mode !== 'yes') {
global $ld_in_focus_mode;
$ld_in_focus_mode = true;
return $template;
}
global $post;
$user_id = get_current_user_id();
$post_id = $post->ID;
$has_access = sfwd_lms_has_access($course_id, $user_id);
if (is_user_logged_in() && $has_access) {
$post_types = array(
'sfwd-courses',
'sfwd-lessons',
'sfwd-topic',
'sfwd-assignment',
'sfwd-quiz',
);
} else {
$post_types = array(
'sfwd-lessons',
'sfwd-topic',
'sfwd-assignment',
'sfwd-quiz',
);
}
if (in_array(get_post_type(), $post_types, true) && is_singular($post_types)) {
return LEARNDASH_LMS_PLUGIN_DIR . 'themes/ld30/templates/focus/index.php';
}
return $template;
}
/**
* Load the Orders print view.
*
* @since 1.8.6
*/
function cpe_orders_print_view()
{
/*dd(var_export(wp_verify_nonce($_GET['_wpnonce'], "cpe_print_invoice-{$_GET['order']}"), true));
if (!wp_verify_nonce($nonce, "cpe_print_invoice-{$_GET['order']}")) {
wp_die(
__("Sorry! Something went wrong. Please contact site administrator or go back and retry."),
__("Not Allowed!"),
array(
"response" => 403,
"back_link" => true
)
);
}*/
// Do we have an order ID?
if (empty($_GET['order'])) {
wp_redirect(admin_url('admin.php?page=pmpro-orders'));
exit;
}
// Get order and membership level.
$order = new MemberOrder($_GET['order']);
if (!isset($order->id)) {
wp_die(
__("Sorry! Something went wrong. Please contact site administrator or go back and retry."),
__("Not Allowed!"),
array(
"response" => 403,
"back_link" => true
)
);
}
$level = pmpro_getLevel($order->membership_id);
// Load template
$template = CPE_DIR . '/paid-memberships-pro/pages/orders-print.php';
require_once($template);
?>
<script>
window.print();
</script>
<?php
exit;
}
add_action('admin_post_cpe_print_invoice', 'cpe_orders_print_view');
function cpe_learndash_status_bubble( $bubble, $status ) {
if( strpos($status, "cpe_completed_") !== FALSE ) {
$date_format = get_option( "date_format" );
list( $string, $completed_timestamp ) = explode('cpe_completed_', $status);
$bubble = '<div class="ld-status ld-status-complete ld-secondary-background">' . esc_html_x( 'Completed on ' . date( $date_format, $completed_timestamp ) , 'In Progress item status', 'learndash' ) . '</div>';
}
return $bubble;
}
add_filter( "learndash_status_bubble", "cpe_learndash_status_bubble", 999, 2 );
function cpe_get_user_completed_courses_id( $user_id ) {
global $wpdb;
$user_courses_id = $wpdb->get_col( "SELECT `course_id` FROM `{$wpdb->base_prefix}learndash_user_activity` WHERE `user_id` = {$user_id} AND `activity_type` LIKE 'course' AND activity_completed != '' ORDER BY `activity_completed` DESC" );
$user_courses = array();
if( !empty($user_courses_id) ) {
foreach ( $user_courses_id as $course_id) {
if( get_post_status( $course_id ) ) {
array_push($user_courses, $course_id );
}
}
} else {
return $user_courses;
}
return $user_courses;
}