Created
March 1, 2012 00:13
-
-
Save rosemarydotworld/1945947 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//give blocks semantic html ids and theme hook suggestions | |
function wmux_preprocess_block(&$vars) { | |
$semantic_block_id = wmux_id_safe($vars['block']->subject); | |
$vars['semantic_block_id'] = $semantic_block_id; | |
$vars['theme_hook_suggestions'][] = 'block__' . $semantic_block_id; | |
} | |
function wmux_id_safe($string) { | |
if (is_numeric($string)) { | |
$string = 'n'. $string; | |
} | |
return strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $string)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved by Sam Richard. Here's what I should have been doing on line 14:
Notice the underscore in the place of the dash.