LLMS_Lesson::get_available_date( string $format = '' )
Get the date a course became or will become available according to element drip settings
Description Description
If there are no drip settings, the published date of the element will be returned.
Parameters Parameters
- $format
-
(string) (Optional) Date format (passed to date_i18n()). Default is empty string. When not specified the WP Core date + time formats will be used.
Default value: ''
Return Return
(string)
Source Source
File: includes/models/model.llms.lesson.php
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | public function get_available_date( $format = '' ) { if ( ! $format ) { $format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' ); } $drip_method = $this ->get( 'drip_method' ); $days = $this ->get( 'days_before_available' ) * DAY_IN_SECONDS; // Default availability is the element's post date. $available = $this ->get_date( 'date' , 'U' ); switch ( $drip_method ) { // Available on a specific date / time. case 'date' : $date = $this ->get( 'date_available' ); $time = $this ->get( 'time_available' ); if ( ! $time ) { $time = '12:00 AM' ; } $available = strtotime ( $date . ' ' . $time ); break ; // Available # of days after enrollment in course. case 'enrollment' : $student = llms_get_student(); if ( $student ) { $available = $days + $student ->get_enrollment_date( $this ->get( 'parent_course' ), 'enrolled' , 'U' ); } break ; case 'prerequisite' : if ( $this ->has_prerequisite() ) { $student = llms_get_student(); if ( $student ) { $date = $student ->get_completion_date( $this ->get( 'prerequisite' ), 'U' ); if ( $date ) { $available = $days + $date ; } } } break ; // Available # of days after course start date. case 'start' : $course = $this ->get_course(); $course_start_date = $course ? $course ->get_date( 'start_date' , 'U' ) : '' ; if ( $course_start_date ) { $available = $days + $course_start_date ; } break ; } return date_i18n( $format , $available ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.7.0 | Replaced the call to the deprecated LLMS_Lesson::get_parent_course() method with LLMS_Lesson::get( 'parent_course' ) . |
3.36.2 | Add available number of days to the course start date only if there's a course start date. |
3.16.0 | Introduced. |