lifterlms_template_my_memberships_loop( LLMS_Student $student = null )
Get course tiles for a student’s memberships
Parameters Parameters
- $student
-
(LLMS_Student) (Optional) LLMS_Student (current student if none supplied). Default
null
.Default value: null
Return Return
(void)
Source Source
File: includes/functions/llms.functions.templates.dashboard.php
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | if ( ! function_exists( 'llms_template_my_favorites_loop' ) ) { /** * Get student's favorites. * * @since 7.5.0 * * @param LLMS_Student $student Optional. LLMS_Student (current student if none supplied). Default `null`. * @param array $favorites Optional. Array of favorites (current student's favorites if none supplied). Default `null`. * @return void */ function llms_template_my_favorites_loop( $student = null, $favorites = null ) { $student = llms_get_student( $student ); if ( ! $student ) { return ; } $favorites = $favorites ?? $student ->get_favorites(); if ( ! $favorites ) { printf( '<p>%s</p>' , esc_html__( 'No favorites found.' , 'lifterlms' ) ); } else { // Adding Parent Course IDs in Favorites for each lesson. foreach ( $favorites as $key => $favorite ) { $lesson = new LLMS_Lesson( $favorite ->post_id ); $favorite ->parent_course = $lesson ->get( 'parent_course' ); } // Grouping Favorites by Parent Course ID. $favorites = array_reduce ( $favorites , function ( $carry , $item ) { $carry [ $item ->parent_course ][] = $item ; return $carry ; |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.14.8 | Unknown. |
3.14.0 | Introduced. |