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
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: ''
Return Return
(string)
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 ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.2.2 | Introduced. |