Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
add_shortcode('course-curriculum','show_course_curriculum');
function show_course_curriculum($args){
ob_start();
global $post;
$id = $args['id'];
$class='';
if(class_exists('WPLMS_tips')){
$wplms_settings = WPLMS_tips::init();
$settings = $wplms_settings->lms_settings;
if(isset($settings['general']['curriculum_accordion'])){
$class="accordion";
}
}
?>
<h3 class="heading">
<span><?php _e('Course Curriculum','vibe'); ?></span>
</h3>
<div class="course_curriculum <?php echo vibe_sanitizer($class,'text'); ?>">
<?php
do_action('wplms_course_curriculum_section',$id);
$course_curriculum = bp_course_get_full_course_curriculum($id);
if(!empty($course_curriculum)){
echo '<table class="table">';
foreach($course_curriculum as $lesson){
switch($lesson['type']){
case 'unit':
?>
<tr class="course_lesson">
<td class="curriculum-icon"><i class="icon-<?php echo vibe_sanitizer($lesson['icon'],'text'); ?>"></i></td>
<td><?php echo apply_filters('wplms_curriculum_course_lesson',(!empty($lesson['link'])?'<a href="'.$lesson['link'].'">':''). $lesson['title']. (!empty($lesson['link'])?'</a>':''),$lesson['id'],$id); ?></td>
<td><?php echo vibe_sanitizer($lesson['labels']); ?> </td>
<td><?php echo vibe_sanitizer($lesson['duration']); ?></td>
</tr>
<?php
do_action('wplms_curriculum_course_unit_details',$lesson);
break;
case 'quiz':
?>
<tr class="course_lesson">
<td class="curriculum-icon"><i class="icon-<?php echo vibe_sanitizer($lesson['icon'],'text'); ?>"></i></td>
<td><?php echo apply_filters('wplms_curriculum_course_quiz',(($lesson['link'])?'<a href="'.$lesson['link'].'">':''). $lesson['title'].(isset($lesson['free'])?$lesson['free']:'') . (!empty($lesson['link'])?'</a>':''),$lesson['id'],$id); ?></td>
<td><?php echo vibe_sanitizer($lesson['labels']); ?> </td>
<td><?php echo vibe_sanitizer($lesson['duration']); ?></td>
</tr>
<?php
do_action('wplms_curriculum_course_quiz_details',$lesson);
break;
case 'section':
?>
<tr class="course_section">
<td colspan="4"><?php echo vibe_sanitizer($lesson['title'],'text'); ?></td>
</tr>
<?php
break;
}
}
echo '</table>';
}else{
?>
<div class="message"><?php echo _x('No curriculum found !','Error message for no curriculum found in course curriculum ','vibe'); ?></div>
<?php
}
?>
</div>
<?php
$html = ob_get_clean();
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment