Permalinks::course_content_permalink( $post_link,  $post )


Source

File: classes/Permalinks.php

	function course_content_permalink( $post_link, $post ) {
		$post = get_post( $post );

		global $wpdb;

		$course_base_slug  = dozent_course_base_slug();
		$lecture_base_slug = dozent_lecture_base_slug();
		$quiz_base_slug    = dozent_quiz_base_slug();

		$course_post_name = 'sample-course';


		$course_id = (int) dozent_get_course_id_by_content( $post->ID );

		if ( $course_id ) {
			$course_slug = $wpdb->get_var( "select post_name from {$wpdb->posts} where ID = {$course_id}" );

			if ( $course_slug ) {
				$course_post_name = $course_slug;
			}
		}

		if ( is_object( $post ) && $post->post_type == 'dozent_lecture' ) {
			return home_url( "/{$course_base_slug}/{$course_post_name}/{$lecture_base_slug}/" . $post->post_name . '/' );

		} else if ( is_object( $post ) && $post->post_type === 'dozent_quiz' ) {

			return home_url( "/{$course_base_slug}/{$course_post_name}/{$quiz_base_slug}/" . $post->post_name . '/' );
		}

		return $post_link;
	}