Created
October 15, 2019 13:59
-
-
Save 99manish/ebc25e855598c431d0e96c571ee8f825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('wplms_course_curriculum_section', function() { | |
$course_id = get_the_ID(); | |
$course_curriculum = bp_course_get_curriculum($course_id); | |
if(!empty($course_curriculum)){ | |
$duration = 0; | |
$lecture = 0; | |
foreach($course_curriculum as $key => $item){ | |
if(is_numeric($item)){ | |
$post_type = get_post_type($item); | |
if( $post_type == 'unit' && function_exists('bp_course_get_unit_duration')){ | |
$duration += bp_course_get_unit_duration($item); | |
$lecture += 1; | |
}else if($post_type == 'quiz' && function_exists('bp_course_get_quiz_duration')){ | |
$duration += bp_course_get_quiz_duration($item); | |
} | |
} | |
} | |
if(function_exists('tofriendlytime')){ | |
$duration = apply_filters('wplms_cs_get_course_unit_durations',tofriendlytime($duration),$duration); | |
} | |
echo ' | |
<style> | |
.course_curriculum .add_custom_expand{ | |
grid-template-columns: 1fr 1fr 1fr; | |
display: grid; | |
} | |
.course_curriculum .add_custom_expand .collapse_all {display: none;} | |
</style> | |
<div class="add_custom_expand"> | |
<a class="expand_all" href="javascript:void(0)" >Expand All</a> | |
<a class="collapse_all" href="javascript:void(0)" >Collapse All</a> | |
<span class="lecture_count">'.$lecture.' Lectures</span> | |
<span class="total_duration" >'.$duration.'</span> | |
</div>'; | |
?> | |
<script> | |
jQuery(document).ready(function($) { | |
$(".course_curriculum .expand_all").click(function() { | |
$(".course_curriculum .course_section").addClass('show'); | |
$(".course_curriculum .course_lesson").addClass('show'); | |
$(".course_curriculum .add_custom_expand .collapse_all").show(); | |
$(".course_curriculum .add_custom_expand .expand_all").hide(); | |
}); | |
$(".course_curriculum .collapse_all").click(function() { | |
$(".course_curriculum .course_section").removeClass('show'); | |
$(".course_curriculum .course_lesson").removeClass('show'); | |
$(".course_curriculum .add_custom_expand .collapse_all").hide(); | |
$(".course_curriculum .add_custom_expand .expand_all").show(); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment