Skip to content

Instantly share code, notes, and snippets.

@DumahX
Created July 26, 2022 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DumahX/ba9a4cf1b5d04a2f53ea758d048dff79 to your computer and use it in GitHub Desktop.
Save DumahX/ba9a4cf1b5d04a2f53ea758d048dff79 to your computer and use it in GitHub Desktop.
Add breadcrumbs to Courses with Classroom Mode enabled
<?php
function add_course_breadcrumbs($content) {
global $post;
if(is_single()) {
if(isset($post) && is_a($post, 'WP_Post') && in_array($post->post_type, memberpress\courses\models\Lesson::lesson_cpts())) {
$current_lesson = new memberpress\courses\models\Lesson($post->ID);
$current_section = $current_lesson->section();
if($current_section !== false) {
$current_course = $current_section->course();
$options = \get_option('mpcs-options');
\ob_start();
require(\MeprView::file('/lessons/courses_breadcrumbs'));
$breadcumbs = \ob_get_clean();
$content = $breadcumbs . $content;
}
}
}
return $content;
}
add_filter('the_content', 'add_course_breadcrumbs');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment