Skip to content

Instantly share code, notes, and snippets.

@lucanos
Created May 22, 2019 03:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucanos/66c4e6163e84dd3ce075c7f0fb3bf3ab to your computer and use it in GitHub Desktop.
Save lucanos/66c4e6163e84dd3ce075c7f0fb3bf3ab to your computer and use it in GitHub Desktop.
Adds Classes to Learndash Lessons and Topics based on whether the User has Completed Them or Not
function lucanos_learndash_classes( $classes ) {
global $post;
if( in_array( $post->post_type , array( 'sfwd-lessons' , 'sfwd-topic' ) ) ){
$classes[] = 'learndash';
$progress = learndash_get_course_progress( null, $post->ID );
$classes[] = 'learndash-progress-'.( $progress['this']->completed != 1 ? 'in' : '' ).'complete';
}
return $classes;
}
add_filter( 'post_class' , 'lucanos_learndash_classes' );
add_filter( 'body_class' , 'lucanos_learndash_classes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment