WP_Theme_JSON_Resolver::get_file_path_from_theme()protected staticWP 5.8.0

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.

Метод класса: WP_Theme_JSON_Resolver{}

Хуков нет.

Возвращает

Строку. The whole file path or empty if the file doesn't exist.

Использование

$result = WP_Theme_JSON_Resolver::get_file_path_from_theme( $file_name, $template );
$file_name(строка) (обязательный)
Name of the file.
$template(true|false)
Use template theme directory.
По умолчанию: false

Список изменений

С версии 5.8.0 Введена.
С версии 5.9.0 Adapted to work with child themes, added the $template argument.

Код WP_Theme_JSON_Resolver::get_file_path_from_theme() WP 6.1.1

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 : '';
}