function _bootstrap_add_class
8.x-3.x deprecated.php | _bootstrap_add_class($class, array &$element, $property = 'attributes') |
7.x-3.x common.inc | _bootstrap_add_class($class, array &$element, $property = 'attributes') |
Adds a class to an element's render array.
Parameters
string|array $class: An individual class or an array of classes to add.
array $element: The individual renderable array element. It is possible to also pass the $variables parameter in [pre]process functions and it will logically determine the correct path to that particular theme hook's classes array. Passed by reference.
string $property: Determines which attributes array to retrieve. By default, this is the normal attributes, but can be "wrapper_attributes" or "input_group_attributes".
Related topics
Source includes/common.inc (line 574)
function _bootstrap_add_class($class, array &$element, $property = 'attributes') {
// Retrieve the element's classes.
$classes = &_bootstrap_get_classes($element, $property);
// Convert the class to an array.
if (!is_array($class)) {
$class = array($class);
}
// Iterate over all classes to add.
foreach ($class as $_class) {
// Ensure the class to add does not yet already exist.
if (!in_array($_class, $classes)) {
$classes[] = $_class;
}
}
}