LLMS_Template_Loader::template_loader( string $template )
Check if content should be restricted and include overrides where appropriate.
Description Description
Triggers actions based on content restrictions.
Parameters Parameters
- $template
-
(string) (Required) The template to load.
Return Return
(string)
Source Source
File: includes/class.llms.template.loader.php
* @return string
*/
public function template_loader( $template ) {
$page_restricted = llms_page_restricted( get_the_ID() );
$this->maybe_print_notices_on_sales_page_redirect();
if ( $page_restricted['is_restricted'] ) {
/**
* Generic action triggered when content is restricted.
*
* @since Unknown
*
* @see llms_content_restricted_by_{$page_restricted['reason']} A specific hook triggered by a specific restriction reason.
*
* @param array $page_restricted Restriction information from `llms_page_restricted()`.
*/
do_action( 'lifterlms_content_restricted', $page_restricted );
/**
* Action triggered when content is restricted for the specified reason.
*
* The dynamic portion of this hook, `{$page_restricted['reason']}` refers to the restriction reason
* code generated by `llms_page_restricted()`.
*
* @since Unknown
*
* @see llms_content_restricted A generic hook triggered at the same time.
*
* @param array $page_restricted Restriction information from `llms_page_restricted()`.
*/
do_action( "llms_content_restricted_by_{$page_restricted['reason']}", $page_restricted );
if ( is_home() && 'sitewide_membership' === $page_restricted['reason'] ) {
// Prints notices on the blog page when there's not redirects setup.
add_action( 'loop_start', 'llms_print_notices', 5 );
}
}
$forced_template = $this->maybe_force_php_template( $template );
/**
* When restricting single content use a lower priority so to always override
* theme builders like Divi and Elementor (Pro).
* see https://github.com/gocodebox/lifterlms/issues/2063.
*/
if ( llms_template_file_path( 'single-no-access.php' ) === $forced_template ) {
/**
* Filters the template loading priority for single restricted content.
*
* @since 6.4.0
*
* @param int $priority The filter callback priority.
*/
$template_loader_restricted_cb_priority = apply_filters( 'llms_template_loader_restricted_priority', 100 );
add_filter( 'template_include', array( $this, 'maybe_force_php_template' ), $template_loader_restricted_cb_priority );
} else {
$template = $forced_template;
}
return $template;
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 6.4.0 | Defer single content restricted template loading. |
| 5.8.0 | Refactor: moved the template guessing in a specific method. |
| 4.10.1 | Refactor to reduce code duplication and replace usage of llms_shop with courses for catalog check. |
| 3.37.2 | Make sure to print notices on sales page redirect. |
| 3.16.11 | Unknown. |
| 1.0.0 | Introduced. |