dozent_get_next_previous_content_id( int $content_ID )
Get the Next and Previous ID of course content;
Parameters
- $content_ID
-
(int) (Required)
Return
(object)
Source
File: includes/core-functions.php
function dozent_get_next_previous_content_id( $content_ID = 0 ) { $content_ID = dozent_get_post_id( $content_ID ); $course_id = dozent_get_course_id_by_content( $content_ID ); $course_contents = dozent_get_course_contents( $course_id ); $previous_id = 0; $next_id = 0; if ( dozent_count( $course_contents ) ) { $ids = wp_list_pluck( $course_contents, 'ID' ); $i = 0; foreach ( $ids as $key => $id ) { $previous_i = $key - 1; $next_i = $key + 1; if ( $id == $content_ID ) { if ( isset( $ids[ $previous_i ] ) ) { $previous_id = $ids[ $previous_i ]; } if ( isset( $ids[ $next_i ] ) ) { $next_id = $ids[ $next_i ]; } break; } $i ++; } } return (object) [ 'previous_id' => $previous_id, 'next_id' => $next_id ]; }
Changelog
Version | Description |
---|---|
DozentLMS 1.0.0 | Introduced. |