function om_string_name in OM Maximenu 8
Same name and namespace in other branches
- 6 inc/om_maximenu.utils.inc \om_string_name()
- 7 inc/om_maximenu.utils.inc \om_string_name()
Converts string either to a title or a class
22 calls to om_string_name()
- om_maximenu_admin in inc/
om_maximenu.admin.inc - Admin Form - Simple Editing
- om_maximenu_asset_loader in inc/
om_maximenu.render.inc - Loads styles and js
- om_maximenu_blocks_attach in inc/
om_maximenu.blocks.inc - Block list in table format
- om_maximenu_blocks_get in inc/
om_maximenu.blocks.inc - Adding Blocks
- om_maximenu_classes in inc/
om_maximenu.utils.inc - Classes aggregator
File
- inc/
om_maximenu.utils.inc, line 25 - OM Maximenu Admin Utilities
Code
function om_string_name($string = NULL, $class = TRUE) {
// for the purpose of just showing the classes and title
// any tags are stripped off
$string = trim(strip_tags($string));
// if there are slashes
$string = stripslashes($string);
// ignores characters other than a-z, A-Z, 0-9
$string_class = preg_replace('/[^a-zA-Z0-9-]+/', ' ', $string);
// allows all characters
$string_title = $string;
// space and underscore are converted depending on use
$pattern = '/[ _]+/';
$string = $class == FALSE ? ucwords(preg_replace($pattern, ' ', $string_title)) : strtolower(preg_replace($pattern, '-', $string_class));
// if result is none for non-class
if (empty($string) && $class == FALSE) {
$string = 'Script Link';
}
return $string;
}