Last active
February 19, 2021 06:40
-
-
Save MrVibe/6ea9f2124f1c05e08ab27c68315f9da6 to your computer and use it in GitHub Desktop.
Unit timings print on certificate
This file contains hidden or 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_shortcode('certificate_course_unit_timings',function($atts,$content=null){ | |
$return = ''; | |
$course_id = ; | |
$user_id = ; | |
$course_curriculum = bp_course_get_curriculum( $course_id ); | |
$unit_timing = array(); | |
$init = WPLMS_Unit_Timings_Init::Instance_WPLMS_Unit_Timings_Init(); | |
foreach ($course_curriculum as $unit_id) { | |
if( is_numeric($unit_id) ){ | |
$unit_timing[] = array('unit'=>get_the_title($unit_id),'time'=>$init->get_course_unit_time_spent( $user_id,$course_id,$unit_id )); | |
} | |
} | |
if(!empty($unit_timing)){ | |
foreach ($unit_timing as $unit) { | |
$return .='<div><label>'.$unit['unit'].'</label><span>'.tofriendlytime($unit['time']).'</span></div>'; | |
} | |
} | |
return $return; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment