function icomoon_preprocess_icon in Icomoon 7
Implements hook_preprocess_icon().
File
- ./
icomoon.module, line 102 - icomoon.module Integrates the Icomoon service as an icon provider for Icon API.
Code
function icomoon_preprocess_icon(&$variables) {
if (!empty($variables['bundle']['provider']) && $variables['bundle']['provider'] === 'icomoon') {
$icon =& $variables['icon'];
$classes =& $variables['attributes']['class'];
$settings = $variables['bundle']['settings'];
// IcoMoon defaults to a 'icon-' prefix if not overridden.
if (empty($settings['prefix']) && empty($settings['useClassSelector']) && $settings['classSelector'] === '.icon') {
$settings['prefix'] = 'icon-';
}
// Alter the class according to any prefix and postfix.
if (!empty($settings['prefix'])) {
$icon = $settings['prefix'] . $icon;
}
if (!empty($settings['postfix'])) {
$icon .= $settings['postfix'];
}
// Replace the default "icon" class if a different one is provided.
if (!empty($settings['useClassSelector']) && !empty($settings['classSelector']) && $settings['classSelector'] !== '.icon') {
$key = array_search('icon', $classes);
if ($key !== FALSE) {
$classes[$key] = str_replace('.', '', $settings['classSelector']);
}
}
// Add an identifier class for this bundle.
$classes[] = 'icomoon';
}
}