dozent_has_single_template_in_theme( null $post_type = null )

Check if Dozent LMS single template exists in the current theme.


Description

While load single course template and override, we need to check if there any Dozent LMS post type single template exists in the root. If we found there is a single template, we will not override the template anymore.

Example usage:

dozent_has_single_template_in_theme( 'dozent_course );
dozent_has_single_template_in_theme( 'dozent_assignment );
dozent_has_single_template_in_theme( 'dozent_quiz );
dozent_has_single_template_in_theme( 'dozent_lecture );

Parameters

$post_type

(null) (Optional)

Default value: null


Return

(bool)


Source

File: includes/conditional-functions.php

	function dozent_has_single_template_in_theme( $post_type = null ) {

		if ( ! $post_type ) {
			return false;
		}

		$template_location = trailingslashit( get_stylesheet_directory() ) . "single-{$post_type}.php";
		if ( ! file_exists( $template_location ) ) {
			$template_location = trailingslashit( get_template_directory() ) . "single-{$post_type}.php";
		}

		/**
		 * Filter the default return value of dozent_has_single_template_in_theme() function
		 *
		 * @since DozentLMS 1.0.0
		 *
		 * @param  bool file_exists( $template_location )
		 * @param  string  $post_type  passing post type.
		 */

		return apply_filters( 'dozent_has_single_template_in_theme', file_exists( $template_location ), $post_type );
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.