You are here

function cf_theme_safe_css_string_part in Common Functionality 7

Same name and namespace in other branches
  1. 7.2 modules/cf_theme/cf_theme.module \cf_theme_safe_css_string_part()

Returns a string with all non-word characters turned into underscores.

Why: 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. This function is intended to be used to only create part of a string as done throughout the cf_theme_* functions to generate css names, such as: at-www_drupal_org.

Parameters

string $string: The string to cleanup.

array $function_history: (optional) An array of function names, ie: array('0' => 'my_function_name').

Return value

string|false A string with all non-word characters turned into underscores. FALSE is returned if the preg_replace() functions returns something other than a string.

1 call to cf_theme_safe_css_string_part()
cf_theme_get_variables in modules/cf_theme/cf_theme.module
Returns an array of variables to be used by a given theme.

File

modules/cf_theme/cf_theme.module, line 512

Code

function cf_theme_safe_css_string_part($string, array $function_history = array()) {
  $replacement = preg_replace('/(\\W)+/i', '_', $string);
  if (is_string($replacement)) {
    return $replacement;
  }
  return FALSE;
}