Created
January 12, 2024 19:39
-
-
Save contemplate/ad0f08b1fbf87789cfac6f7dbb0f5bab to your computer and use it in GitHub Desktop.
LearnDash Course Grid v1: Add Scheduled Date Lock for Lessons & Topics
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
//For Use with Elementor Lesson List & topic List Grid widgets | |
add_filter( 'learndash_course_grid_html_output', 'learndash_course_grid_add_avilable_date', 10, 4 ); | |
function learndash_course_grid_add_avilable_date( $data, $post, $shortcode_atts, $user_id ) { | |
if ( 'sfwd-topic' == $post->post_type || 'sfwd-lessons' == $post->post_type ) { | |
$course_id = $shortcode_atts['course_id']; | |
if( $course_id ){ | |
$attributes = learndash_get_course_step_attributes( $post->ID, $course_id, $user_id ); | |
$is_sample = ( isset( $lesson->sample ) ? $post->sample : false ); | |
$ld_lesson_has_access = sfwd_lms_has_access( $post->ID, $user_id ); | |
$ld_available_date = learndash_course_step_available_date( $post->ID, $course_id, $user_id, true ); | |
$atts_access_marker = ( isset( $ld_lesson_has_access ) && ! $ld_lesson_has_access && ! $is_sample ) || ( ! empty( $ld_available_date ) && ! $is_sample ) ? '<span class="lms-is-locked-ico" data-balloon="' . esc_attr( $attributes[0]['label'] ) . '"><i class="ld-icon ld-icon-calendar"></i></span>' : ''; | |
$ld_date_add = $atts_access_marker.'<div class="caption">'; | |
$data = str_replace( '<div class="caption">', $ld_date_add, $data ); | |
} | |
} | |
return $data; | |
} | |
/* | |
* Add CSS to Site: | |
------------------- | |
.lms-is-locked-ico { | |
position: absolute; | |
z-index: 9; | |
top: 0; | |
width: 100%; | |
height: 100%; | |
background: rgba(0,0,0,0.5); | |
color: #fff; | |
padding: 20%; | |
text-align: center; | |
font-size: 100%; | |
} | |
.lms-is-locked-ico .ld-icon { | |
padding: 10px; | |
border: 1px solid #fff; | |
border-radius: 100%; | |
margin: 0 0 10px 0; | |
} | |
.lms-is-locked-ico::after { | |
content: attr(data-balloon); | |
display: block; | |
font-weight: bold; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet and CSS works well for creating a Lesson or Topic List using the LearnDash Elementor Addon which shows the available date when Lesson or Topics will be avilable