Archived topic
add_filter for footer Elements Block
5 replies · Started by Manuel on April 18, 2022
Hi,
i am using Email Address Encoder to protect email addresses from robots.
But actually it doesnt work for my Element footer block. It's possible to add a filter for scanning additional parts of the website:
add_filter( '%filter-name%', 'eae_encode_emails' ); (https://encoder.till.im/guide#filtering-content)
So my question is if there is a filter for the element block that I can use?
Hi there,
how is the email being added ? Can i see the site ?
Hi David,
I have just added the information.
Email is added via headline element
You can try the render_block filter:
https://developer.wordpress.org/reference/functions/render_block/
not sure if you want to make that callback directly on that filter or make the callback on the block content - see example of that here:
https://generatepress.com/forums/topic/dynamic-image-open-link-in-new-window/#post-1975136
Thanks for that hint. It works like a charm. I ended up doing it like that:
add_filter( 'render_block', function( $block_content, $block ) {
if ( 'generateblocks/headline' === $block['blockName'] ) {
$block_content = eae_encode_emails( $block_content );
}
return $block_content;
}, 10, 2 );
Awesome - glad to hear that!