You are here

function cf_theme_safe_css in Common Functionality 7.2

A wrapper around drupal_clean_css_identifier that allows underscores.

Justification: Drupals core css cleanup code does not properly handle all allowed css, namely underscores. This is a quick-way to ensure that all non-word characters are removed from a string to be used in css.

Parameters

string $string: The string to cleanup.

Return value

string|false FALSE is returned if the preg_replace() functions returns something other than a string.

Related topics

File

modules/cf_theme/cf_theme.module, line 829
Common Functionality - Theme module.

Code

function cf_theme_safe_css($string) {
  $replacement = drupal_clean_css_identifier($string, array(
    ' ' => '-',
    '_' => '_',
    '/' => '-',
    '[' => '-',
    ']' => '',
  ));
  if (is_string($replacement)) {
    return $replacement;
  }
  return FALSE;
}