You are here

function browsersync_get_setting in Browsersync 7

Same name and namespace in other branches
  1. 8.2 browsersync.module \browsersync_get_setting()
  2. 8 browsersync.module \browsersync_get_setting()

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

Parameters

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

mixed $default: (optional) A default value. Defaults to NULL.

string $theme: (optional) The name of a given theme. Defaults to the current theme.

Return value

mixed The value of the requested setting, or the $default value if the setting does not exist.

See also

theme_get_setting()

3 calls to browsersync_get_setting()
browsersync_css_alter in ./browsersync.module
Implements hook_css_alter().
browsersync_form_system_theme_settings_alter in ./browsersync.module
Implements hook_form_system_theme_settings_alter().
browsersync_page_build in ./browsersync.module
Implements hook_page_build().

File

./browsersync.module, line 152
Code for the Browsersync module.

Code

function browsersync_get_setting($setting_name, $default = NULL, $theme = NULL) {
  $cache =& drupal_static('theme_get_setting', 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'] : '';
  }

  // Prefix the setting name with the module's namespace.
  $setting_name = 'browsersync_' . $setting_name;
  if (empty($cache[$theme])) {

    // If the cache has not been filled yet, invoke theme_get_setting to
    // retrieve the value. This will populate the cache and make it available
    // for subsequent requests.
    $setting = theme_get_setting($setting_name, $theme);
  }
  elseif (isset($cache[$theme][$setting_name])) {

    // Retrieve the value from the cache.
    $setting = $cache[$theme][$setting_name];
  }
  else {

    // Use the default value, setting does not exist.
    $setting = $default;
  }
  return $setting;
}