Filter: bricks/element/render_attributes
Starting with Bricks 1.3.7 you may manipulate the HTML** **attributes of a given element using the following filter:
add_filter( 'bricks/element/render_attributes', function( $attributes, $key, $element ) { if ( isset( $element->settings['my_setting'] ) && $element->settings['my_setting'] == 'xpto' ) { $attributes[ $key ]['data-xpto'] = 'my data'; }
return $attributes;}, 10, 3 );The filter callback receives 3 arguments:
$attributes- an associative array of the element attributes, grouped by the $key identifier$key- the HTML element identifier to render attributes for$element- the Bricks element object (since Bricks 1.5)
Since Bricks 1.4, if you need to get access to the $is_frontend value (whether the element is rendering in the frontend or in the builder), please use the global function bricks_is_frontend().
Since Bricks 1.5, the $settings and $name arguments are deprecated. You may use the callback 3rd argument to get those: $element->settings and $element->name.
Was this helpful?
A quick vote and short notes help us improve these docs faster.
Leave a note for us
Please do not include passwords, license keys, or personal data. We store submitted notes to improve the docs.
Thanks for sharing feedback. We're using it to improve these docs.