How do you add your own custom attributes to the popup outer wrapper? Here I am sharing a simple snippet. You will add it to the theme’s functions.php file or any 3rd party snippet plugin.
add_filter( 'bricks/popup/attributes', 'add_popup_custom_attributes', 10, 2);
function add_popup_custom_attributes( $attributes, $popup_id ) {
if( $popup_id == '7042' ) {
//* adds custom class
$attributes['class'][] = 'my-class';
//* add data attribute
$attributes['data-my-attr'] = 'mydatavalue';
}
return $attributes;
}
bricks/popup/attributes is a filter. It is accepting the two parameters: attributes in array format and popup id in integer/string format.
In the above code, I targeted the specific popup with the popup ID. You will replace the ID 7042 with your popup id. Here I am adding a custom CSS class and data attribute. You will change it as per your requirement.