8.5.x theme.inc theme_get_setting($setting_name, $theme = NULL)
8.0.x theme.inc theme_get_setting($setting_name, $theme = NULL)
8.1.x theme.inc theme_get_setting($setting_name, $theme = NULL)
8.2.x theme.inc theme_get_setting($setting_name, $theme = NULL)
8.3.x theme.inc theme_get_setting($setting_name, $theme = NULL)
8.4.x theme.inc theme_get_setting($setting_name, $theme = NULL)
8.6.x theme.inc theme_get_setting($setting_name, $theme = NULL)
4.6.x theme.inc theme_get_setting($setting_name, $refresh = FALSE)
4.7.x theme.inc theme_get_setting($setting_name, $refresh = FALSE)
5.x theme.inc theme_get_setting($setting_name, $refresh = FALSE)
6.x theme.inc theme_get_setting($setting_name, $refresh = FALSE)
7.x theme.inc theme_get_setting($setting_name, $theme = NULL)

Retrieves a setting for the current theme or for a given theme.

The final setting is obtained from the last value found in the following sources:

  • the saved values from the global theme settings form
  • the saved values from the theme's settings form

To only retrieve the default global theme setting, an empty string should be given for $theme.


$setting_name: The name of the setting to be retrieved.

$theme: The name of a given theme; defaults to the current theme.

Return value

The value of the requested setting, NULL if the setting does not exist.

10 calls to theme_get_setting()
color.inc in core/themes/bartik/color/color.inc
hook_form_system_theme_settings_alter in core/lib/Drupal/Core/Render/theme.api.php
Allow themes to alter the theme-specific settings form.
SystemBrandingBlock::build in core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
Builds and returns the renderable array for this block plugin.
system_page_attachments in core/modules/system/system.module
Implements hook_page_attachments().
template_preprocess_maintenance_page in core/includes/theme.inc
Prepares variables for maintenance page templates.

... See full list

2 string references to 'theme_get_setting'
ThemeInstaller::install in core/lib/Drupal/Core/Extension/ThemeInstaller.php
Installs a given list of themes.
ThemeInstaller::uninstall in core/lib/Drupal/Core/Extension/ThemeInstaller.php
Uninstalls a given list of themes.


core/includes/theme.inc, line 306
The theme system, which controls the output of Drupal.


function theme_get_setting($setting_name, $theme = NULL) {

  /** @var \Drupal\Core\Theme\ThemeSettings[] $cache */
  $cache =& drupal_static(__FUNCTION__, array());

  // If no key is given, use the current theme if we can determine it.
  if (!isset($theme)) {
    $theme = \Drupal::theme()
  if (empty($cache[$theme])) {

    // Create a theme settings object.
    $cache[$theme] = new ThemeSettings($theme);

    // Get the global settings from configuration.

    // Get the values for the theme-specific settings from the .info.yml files
    // of the theme and all its base themes.
    $themes = \Drupal::service('theme_handler')
    if (isset($themes[$theme])) {
      $theme_object = $themes[$theme];

      // Retrieve configured theme-specific settings, if any.
      try {
        if ($theme_settings = \Drupal::config($theme . '.settings')
          ->get()) {
      } catch (StorageException $e) {

      // If the theme does not support a particular feature, override the global
      // setting and set the value to NULL.
      if (!empty($theme_object->info['features'])) {
        foreach (_system_default_theme_features() as $feature) {
          if (!in_array($feature, $theme_object->info['features'])) {
              ->set('features.' . $feature, NULL);

      // Generate the path to the logo image.
      if ($cache[$theme]
        ->get('logo.use_default')) {
          ->set('logo.url', file_url_transform_relative(file_create_url($theme_object
          ->getPath() . '/logo.svg')));
      elseif ($logo_path = $cache[$theme]
        ->get('logo.path')) {
          ->set('logo.url', file_url_transform_relative(file_create_url($logo_path)));

      // Generate the path to the favicon.
      if ($cache[$theme]
        ->get('features.favicon')) {
        $favicon_path = $cache[$theme]
        if ($cache[$theme]
          ->get('favicon.use_default')) {
          if (file_exists($favicon = $theme_object
            ->getPath() . '/favicon.ico')) {
              ->set('favicon.url', file_url_transform_relative(file_create_url($favicon)));
          else {
              ->set('favicon.url', file_url_transform_relative(file_create_url('core/misc/favicon.ico')));
        elseif ($favicon_path) {
            ->set('favicon.url', file_url_transform_relative(file_create_url($favicon_path)));
        else {
            ->set('features.favicon', FALSE);
  return $cache[$theme]