Register attributes by ID.
The Beans HTML “attributes” functions make it really easy to modify, replace, extend, remove or hook into registered attributes.
Since this function uses beans_apply_filters(), the $id argument may contain sub-hook(s).
beans_add_attributes( string $id, string|array $attributes = array() )
Return: (string) The HTML attributes.
Parameters
Name | Type | Required | Default | Description |
---|---|---|---|---|
$id | string | true | - | A unique string used as a reference. The $id argument may contain sub-hook(s). |
$attributes | string|array | false | array() | Query string or array of attributes. The array key defines the attribute name and the array value define the attribute value. Setting the array value to '' will display the attribute value as empty (e.g. class=""). Setting it to 'false' will only display the attribute name (e.g. data-example). Setting it to 'null' will not display anything. |
$var | mixed | true | - | Additional variables passed to the functions hooked to $id. |
Source
function beans_add_attributes( $id, $attributes = array() ) {
$args = func_get_args();
$args[0] = $id . '_attributes';
if ( ! isset( $args[1] ) ) {
$args[1] = array();
}
$args[1] = wp_parse_args( $args[1] );
$attributes = call_user_func_array( 'beans_apply_filters', $args );
return beans_esc_attributes( $attributes );
}