Created
August 23, 2011 01:34
-
-
Save jacine/1164095 to your computer and use it in GitHub Desktop.
Add ARIA roles to blocks
This file contains 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 | |
/** | |
* Implements template_preprocess_block(). | |
*/ | |
function THEME_preprocess_block(&$vars) { | |
$roles = array( | |
'complementary' => array( | |
'aggregator', | |
'help', | |
'locale', | |
'poll', | |
'profile', | |
'node' => array('syndicate'), | |
'system' => array('powered-by', 'help'), | |
'user' => array('new', 'online'), | |
), | |
'navigation' => array( | |
'blog', | |
'book', | |
'comment', | |
'forum', | |
'menu', | |
'menu_block', | |
'node' => array('recent'), | |
'shortcut', | |
'statistics', | |
'system' => array_keys(menu_list_system_menus()), | |
), | |
'search' => array( | |
'search', | |
), | |
'form' => array( | |
'user' => array('login'), | |
), | |
); | |
foreach ($roles as $role => $module) { | |
if (!is_array($role) && in_array($vars['block']->module, $module)) { | |
$vars['attributes_array']['role'] = "$role"; | |
} | |
elseif (is_array($role)) { | |
foreach ($role as $module => $delta) { | |
if ($vars['block']->module == $module && in_array($vars['block']->delta, $delta)) { | |
$vars['attributes_array']['role'] = "$role"; | |
} | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment