theme_get_setting

Versions
5 – 6
theme_get_setting($setting_name, $refresh = FALSE)
7
theme_get_setting($setting_name, $theme = NULL)

Retrieve 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.

▾ 19 functions call theme_get_setting()

bartik_process_maintenance_page in drupal/themes/bartik/template.php
Override or insert variables into the maintenance page template.
bartik_process_page in drupal/themes/bartik/template.php
Override or insert variables into the page template.
garland_form_system_theme_settings_alter in drupal/themes/garland/theme-settings.php
Implements hook_form_system_theme_settings_alter().
garland_preprocess_html in drupal/themes/garland/template.php
Override or insert variables into the html template.
hook_form_system_theme_settings_alter in drupal/modules/system/theme.api.php
Allow themes to alter the theme-specific settings form.
imagecache_profiles_comment_view in contributions/imagecache_profiles/imagecache_profiles.module
Implements hook_comment_view().
shortcut_preprocess_page in drupal/modules/shortcut/shortcut.module
Implements hook_preprocess_page().
system_theme_settings in drupal/modules/system/system.admin.inc
Form builder; display theme configuration for entire site and individual themes.
system_update_7017 in drupal/modules/system/system.install
Change the theme setting 'toggle_node_info' into a per content type variable.
template_preprocess_advanced_help_popup in contributions/advanced_help/advanced_help.module
Fill in a bunch of page variables for our specialized popup page.
template_preprocess_advanced_help_popup in contributions/advanced_help/advanced_help.module
Fill in a bunch of page variables for our specialized popup page.
template_preprocess_comment in drupal/modules/comment/comment.module
Process variables for comment.tpl.php.
template_preprocess_html in drupal/includes/theme.inc
Preprocess variables for html.tpl.php
template_preprocess_maintenance_page in drupal/includes/theme.inc
The variables array generated here is a mirror of template_preprocess_page(). This preprocessor will run its course when theme_maintenance_page() is invoked.
template_preprocess_node in drupal/modules/node/node.module
Process variables for node.tpl.php
template_preprocess_page in drupal/includes/theme.inc
Preprocess variables for page.tpl.php
template_preprocess_username in drupal/includes/theme.inc
Preprocesses variables for theme_username().
template_preprocess_wysiwyg_dialog_page in contributions/wysiwyg/wysiwyg.dialog.inc
Template preprocess function for theme_wysiwyg_dialog_page().
theme_admin_menu_icon in contributions/admin_menu/admin_menu.inc
Render an icon to display in the administration menu.

Code

drupal/includes/theme.inc, line 1114

<?php
function theme_get_setting($setting_name, $theme = NULL) {
  $cache = &drupal_static(__FUNCTION__, array());

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

  if (empty($cache[$theme])) {
    // Set the default values for each global setting.
    // To add new global settings, add their default values below, and then
    // add form elements to system_theme_settings() in system.admin.inc.
    $cache[$theme] = array(
      'default_logo'                     =>  1,
      'logo_path'                        =>  '',
      'default_favicon'                  =>  1,
      'favicon_path'                     =>  '',
      // Use the IANA-registered MIME type for ICO files as default.
      'favicon_mimetype'                 =>  'image/vnd.microsoft.icon',
    );
    // Turn on all default features.
    $features = _system_default_theme_features();
    foreach ($features as $feature) {
      $cache[$theme]['toggle_' . $feature] = 1;
    }

    // Get the values for the theme-specific settings from the .info files of
    // the theme and all its base themes.
    if ($theme) {
      $themes = list_themes();
      $theme_object = $themes[$theme];

      // Create a list which includes the current theme and all its base themes.
      if (isset($theme_object->base_themes)) {
        $theme_keys = array_keys($theme_object->base_themes);
        $theme_keys[] = $theme;
      }
      else {
        $theme_keys = array($theme);
      }
      foreach ($theme_keys as $theme_key) {
        if (!empty($themes[$theme_key]->info['settings'])) {
          $cache[$theme] = array_merge($cache[$theme], $themes[$theme_key]->info['settings']);
        }
      }
    }

    // Get the saved global settings from the database.
    $cache[$theme] = array_merge($cache[$theme], variable_get('theme_settings', array()));

    if ($theme) {
      // Get the saved theme-specific settings from the database.
      $cache[$theme] = array_merge($cache[$theme], variable_get('theme_' . $theme . '_settings', array()));

      // 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 ($features as $feature) {
          if (!in_array($feature, $theme_object->info['features'])) {
            $cache[$theme]['toggle_' . $feature] = NULL;
          }
        }
      }

      // Generate the path to the logo image.
      if ($cache[$theme]['toggle_logo']) {
        if ($cache[$theme]['default_logo']) {
          $cache[$theme]['logo'] = file_create_url(dirname($theme_object->filename) . '/logo.png');
        }
        elseif ($cache[$theme]['logo_path']) {
          $cache[$theme]['logo'] = file_create_url($cache[$theme]['logo_path']);
        }
      }

      // Generate the path to the favicon.
      if ($cache[$theme]['toggle_favicon']) {
        if ($cache[$theme]['default_favicon']) {
          if (file_exists($favicon = dirname($theme_object->filename) . '/favicon.ico')) {
            $cache[$theme]['favicon'] = file_create_url($favicon);
          }
          else {
            $cache[$theme]['favicon'] = file_create_url('misc/favicon.ico');
          }
        }
        elseif ($cache[$theme]['favicon_path']) {
          $cache[$theme]['favicon'] = file_create_url($cache[$theme]['favicon_path']);
        }
        else {
          $cache[$theme]['toggle_favicon'] = FALSE;
        }
      }
    }
  }

  return isset($cache[$theme][$setting_name]) ? $cache[$theme][$setting_name] : NULL;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.