Need help: wp_head add data-atrributes to <header>

Need some help if anyone can point the error. I have written a small plugin that ads a custom field to pages and depending on the saved value in the admin ads a data attribute to the section. However I can’t seem to make it add the data attribute on the front. Is there something related to Bricks? In Breakdance there was a feature that allowed functions in the theme file to interact with the code generated by Breakdance. Is there something similar here or is my code just wrong? thank you.
function start_modify_header()
{
ob_start();
}
function end_modify_header()
{
$html = ob_get_clean();
if (is_page()) {
global $post;
$header_overlay = get_post_meta($post->ID, ‘header_overlay’, true);
if ($header_overlay) {
$html = str_replace(‘<header’, ‘<header data-header-overlay="’ . esc_attr($header_overlay) . ‘"’, $html);
}
}
echo $html;
}
add_action(‘wp_head’, ‘start_modify_header’);
add_action(‘wp_footer’, ‘end_modify_header’);

You can use the bricks/header/attributes hook.

See Filter: bricks/header/attributes – Bricks Academy.

Thank you. I will have a look and try it.