Lecture


Source

File: classes/Lecture.php

class Lecture {

	public function __construct() {

		add_action( 'template_redirect', [ $this, 'complete_lecture' ] );

	}

	public function complete_lecture() {
		$lecture_id = (int) sanitize_text_field( dozent_array_get( 'complete_lecture', $_GET ) );

		if ( $lecture_id ) {
			dozent_complete_content( $lecture_id );

			$next_url_id           = $lecture_id;
			$next_previous_content = dozent_get_next_previous_content_id( $lecture_id );
			if ( $next_previous_content->next_id ) {
				$next_url_id = $next_previous_content->next_id;
			}

			$next_url = get_the_permalink( $next_url_id );
			wp_redirect( $next_url );
		}

	}

}

Methods