Created
May 18, 2022 08:58
-
-
Save ragoand/37100b2480343bb37ed8aef324d1c2d0 to your computer and use it in GitHub Desktop.
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 filter | |
add_filter( 'stm_lms_lesson_content', 'stm_lms_override_lesson_content', 10, 3 ); | |
// override lesson content (scorm example) | |
function stm_lms_override_lesson_content( $template, $post_id, $item_id ) { | |
$lesson_type = get_post_meta( $item_id, 'type', true ); | |
if ( $lesson_type === 'scorm' ) { | |
$this->enqueue_scorm_scripts(); | |
$scorm_url = false; | |
$scorm_meta = false; | |
$scorm_package = get_post_meta( $item_id, 'scorm_package', true ); | |
if ( $scorm_package !== '' ) { | |
$scorm_meta = SCORM_Helpers::get_scorm_meta( $item_id ); | |
$scorm_url = SCORM_Helpers::get_iframe_url( $item_id ); | |
} | |
ob_start(); | |
load_template( plugin_dir_path( __DIR__ ) . '../stm-lms-templates/scorm.php', true, | |
[ | |
'course_id' => $post_id, | |
'post_id' => $item_id, | |
'item_id' => $item_id, | |
'scorm_meta' => $scorm_meta, | |
'scorm_url' => $scorm_url | |
] ); | |
$template.= ob_get_contents(); | |
ob_end_clean(); | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment