1 icon.inc | _icon_from_theme($icon_name, $theme = NULL) |
Checks if the current theme provides an icon.
Do not call this function directly. Use icon() instead.
@private
Parameters
string $icon_name: The icon name to be located.
Return value
string|void: The path to the icon if found.
See also
icon()
File
- core/
includes/ icon.inc, line 145 - Provides the Backdrop API for placing icons.
Code
function _icon_from_theme($icon_name, $theme = NULL) {
$theme = isset($theme) ? $theme : $GLOBALS['theme_key'];
// Check if the theme provides a non-default icon path.
$theme_icon_directory = theme_get_setting('icon_directory', $theme);
// Otherwise just check in the theme "icons" directory.
if (!$theme_icon_directory) {
$theme_icon_directory = 'icons';
}
// Append the filename and extension, and check for a theme-provided icon.
$theme_icon_path = backdrop_get_path('theme', $theme) . '/' . $theme_icon_directory . '/' . $icon_name . '.svg';
// If the icon exists in this theme return it.
if (file_exists($theme_icon_path)) {
return $theme_icon_path;
}
// If icon does not exist in this theme, but this theme has a base theme,
// check that location for an icon. Loop recursively through all base themes.
$themes = list_themes();
$theme_info = $themes[$theme];
if (isset($theme_info->info['base theme'])) {
return _icon_from_theme($icon_name, $theme_info->info['base theme']);
}
}