1 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 default global settings specified in this function
  • the default theme-specific settings defined in any base theme's .info file
  • the default theme-specific settings defined in the theme's .info file
  • 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.

Parameters

$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.:

File

core/includes/theme.inc, line 1445
The theme system, which controls the output of Backdrop.

Code

function theme_get_setting($setting_name, $theme = NULL) {
  $configs = &backdrop_static(__FUNCTION__, array());

  // If no key is given, use the current theme if we can determine it.
  if (!isset($theme)) {
    $theme = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : '';
  }

  if (empty($configs[$theme])) {
    $configs[$theme] = config($theme . '.settings');
    $configs[$theme]->load();
  }

  // If the setting is not found in config, load the default from the theme's
  // info file.
  $value = $configs[$theme]->get($setting_name);
  if (is_null($value)) {
    $themes = list_themes();
    $theme_info = $themes[$theme];
    $value = isset($theme_info->info['settings'][$setting_name]) ? $theme_info->info['settings'][$setting_name] : NULL;
  }

  // Loop up through any base themes.
  if (is_null($value) && isset($theme_info->info['base theme'])) {
    $value = theme_get_setting($setting_name, $theme_info->info['base theme']);
  }

  return $value;
}