WP_Theme_JSON_Resolver::get_file_path_from_theme( string $file_name, bool $template = false )
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
-
(string) (Required) Name of the file.
- $template
-
(bool) (Optional) Use template theme directory.
Default value: false
Return
(string) The whole file path or empty if the file doesn't exist.
Source
File: wp-includes/class-wp-theme-json-resolver.php
private 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 : ''; }
Expand full source code Collapse full source code View on Trac View on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Adapted to work with child themes, added the $template argument. |
5.8.0 | Introduced. |