LLMS_Template_Loader::template_loader( string $template )

Check if content should be restricted and include overrides where appropriate triggers various actions based on content restrictions


Description Description


Parameters Parameters

$template

(string) (Required)


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/class.llms.template.loader.php

	public function template_loader( $template ) {

		$page_restricted = llms_page_restricted( get_the_ID() );
		$post_type = get_post_type();

		// blog should bypass checks, except when sitewide restrictions are enabled
		if ( is_home() && 'sitewide_membership' == $page_restricted['reason'] && $page_restricted['is_restricted'] ) {

			// generic content restricted action
			do_action( 'lifterlms_content_restricted', $page_restricted );

			// specific content restriction action
			do_action( 'llms_content_restricted_by_' . $page_restricted['reason'], $page_restricted );

			// prints notices on the blog page when there's not redirects setup
			add_action( 'loop_start', 'llms_print_notices', 5 );

			return $template;

		} elseif ( $page_restricted['is_restricted'] ) {

			// generic content restricted action
			do_action( 'lifterlms_content_restricted', $page_restricted );

			// specific content restriction action
			do_action( 'llms_content_restricted_by_' . $page_restricted['reason'], $page_restricted );

			// the actual content of membership and courses is handled via separate wysiwyg areas
			// so for these post types we'll return the regular template
			if ( 'course' === $post_type || 'llms_membership' === $post_type ) {
				return $template;
			} // End if().
			else {
				$template = 'single-no-access.php';
			}
		} elseif ( is_post_type_archive( 'course' ) || is_page( llms_get_page_id( 'llms_shop' ) ) ) {

			$template = 'archive-course.php';

		} elseif ( is_tax( array( 'course_cat', 'course_tag', 'course_difficulty', 'course_track', 'membership_tag', 'membership_cat' ) ) ) {

			global $wp_query;
			$obj = $wp_query->get_queried_object();
			$template = 'taxonomy-' . $obj->taxonomy . '.php';

		} elseif ( is_post_type_archive( 'llms_membership' ) || is_page( llms_get_page_id( 'memberships' ) ) ) {

			$template = 'archive-llms_membership.php';

		} elseif ( is_single() && ( get_post_type() == 'llms_certificate' || get_post_type() == 'llms_my_certificate' ) ) {

			$template = 'single-certificate.php';

		} else {

			return $template;

		} // End if().

		// check for an override file
		$override = llms_get_template_override( $template );
		$template_path = $override ? $override : LLMS()->plugin_path() . '/templates/';
		return $template_path . $template;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: