Builds the path to the given file and checks that it is readable.
Description
If it isn’t, returns an empty string, otherwise returns the whole file path.
Parameters
$file_name
stringrequired- Name of the file.
$template
booloptional- Use template theme directory.
Default:
false
Source
protected static function get_file_path_from_theme( $file_name, $template = false ) {
$path = $template ? get_template_directory() : get_stylesheet_directory();
$candidate = $path . '/' . $file_name;
return is_readable( $candidate ) ? $candidate : '';
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.