Created
May 22, 2019 03:37
-
-
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
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
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