Filter: bricks/element/render_attributes

Starting at 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, $settings, $name ) {
    if ( $settings['my_setting'] == 'xpto' ) {
        $attributes[ $key ]['data-xpto'] = 'my data';
    return $attributes;
}, 10, 4 );

The filter callback receives 5 arguments:

  • $attributes – an associative array of the element attributes, grouped by the $key identifier
  • $key – the HTML element identifier to render attributes for
  • $settings – the element settings array
  • $name – the element name, e.g. “container” (string)

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().