WP_Theme_JSON_Resolver::get_file_path_from_theme( string $file_name )

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.

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.

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 ) {
		/*
		 * 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;
	}

Changelog

Version Description
5.8.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_file_path_from_theme