locate_noptin_template( string $template_name, string $template_path = 'noptin', string|bool $default_path = '' )

Locates a template and returns the path for inclusion.


Description Description

This is the load order:

 yourtheme       /   $template_path  /   $template_name
 yourtheme       /   noptin-$template_name
 $default_path   /   $template_name

Top ↑

Parameters Parameters

$template_name

(string) (Required) The template's file name.

$template_path

(string) (Optional) (default: 'noptin').

Default value: 'noptin'

$default_path

(string|bool) (Optional) (default: 'templates') False to not load a default.

Default value: ''


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/functions.php

function locate_noptin_template( $template_name, $template_path = 'noptin', $default_path = '' ) {

	// Look within passed path within the theme - this is priority.
	$template = locate_template(
		array(
			trailingslashit( $template_path ) . $template_name,
			"noptin-$template_name",
		)
	);

	// Get default template.
	if ( ! $template && false !== $default_path ) {

		if ( empty( $default_path ) ) {
			$default_path = get_noptin_plugin_path( 'templates' );
		}

		if ( file_exists( trailingslashit( $default_path ) . $template_name ) ) {
			$template = trailingslashit( $default_path ) . $template_name;
		}
	}

	// Return what we found.
	return apply_filters( 'locate_noptin_template', $template, $template_name, $template_path, $default_path );
}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.2Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation