function cf_theme_safe_css_string_part in Common Functionality 7.2
Same name and namespace in other branches
- 7 modules/cf_theme/cf_theme.module \cf_theme_safe_css_string_part()
Returns a string with all non-word characters turned into 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. 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.
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.
Related topics
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 858 - Common Functionality - Theme module.
Code
function cf_theme_safe_css_string_part($string) {
$replacement = preg_replace('/(\\W)+/i', '_', $string);
if (is_string($replacement)) {
return $replacement;
}
return FALSE;
}