Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

WP_Theme_JSON_Resolver::get_file_path_from_theme( string $file_name )

Builds the path to the given file and checks that it is readable.

Description Description

If it isn’t, returns an empty string, otherwise returns the whole file path.

Top ↑

Parameters Parameters


(string) (Required) Name of the file.

Top ↑

Return Return

(string) The whole file path or empty if the file doesn't exist.

Top ↑

Source Source

File: wp-includes/class-wp-theme-json-resolver.php

	private static function get_file_path_from_theme( $file_name ) {
		 * This used to be a locate_template call. However, that method proved problematic
		 * due to its use of constants (STYLESHEETPATH) that threw errors in some scenarios.
		 * When the theme.json merge algorithm properly supports child themes,
		 * this should also fall back to the template path, as locate_template did.
		$located   = '';
		$candidate = get_stylesheet_directory() . '/' . $file_name;
		if ( is_readable( $candidate ) ) {
			$located = $candidate;
		return $located;

Top ↑

Changelog Changelog

Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.