ap_get_theme_location( string $file, mixed $plugin = false )
Description #
Get location to a file. First file is being searched in child theme and then active theme and last fall back to AnsPress theme directory.
Parameters #
- $filestring (Required) file name.
- $pluginmixed (Optional) Plugin path. File is search inside AnsPress extension. Default value: false
Source #
File: includes/functions.php
function ap_get_theme_location( $file, $plugin = false ) {
$child_path = get_stylesheet_directory() . '/anspress/' . $file;
$parent_path = get_template_directory() . '/anspress/' . $file;
// Checks if the file exists in the theme first,
// Otherwise serve the file from the plugin.
if ( file_exists( $child_path ) ) {
$template_path = $child_path;
} elseif ( file_exists( $parent_path ) ) {
$template_path = $parent_path;
} elseif ( false !== $plugin ) {
$template_path = $plugin . '/templates/' . $file;
} else {
$template_path = ANSPRESS_THEME_DIR . '/' . $file;
}
/**
* Filter AnsPress template file.
*
* @param string $template_path Path to template file.
* @since 2.4.7
*/
return apply_filters( 'ap_get_theme_location', $template_path );
}
Expand full source code Collapse full source code View on GitHub: includes/functions.php:63
Add your comment