Builds the path to the given file and checks that it is readable.
If it isn’t, returns an empty string, otherwise returns the whole file path.
$file_namestringrequired
$templatebooloptional
Default:false
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 : '';
}
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_file_path_from_theme