Skip to content

Commit

Permalink
Merge pull request #4 from MEOM/feature/markup
Browse files Browse the repository at this point in the history
Add Cookiebot attributes in HTML
  • Loading branch information
samikeijonen authored Mar 30, 2023
2 parents 7729f8a + 3d1caa8 commit 3808c2e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion inc/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ function render_block( $block_content, $block ) {
$cookie_text .= sprintf( __( 'Oops! This video will not be shown because you have disabled the marketing cookies. To see the video, <a href="%s">accept marketing cookies</a>.', 'meom-cookiebot-embed' ), 'javascript:Cookiebot.renew()' );
$cookie_text .= '</p></div>';

$block_content = str_replace( '</figure>', $cookie_text . '</figure>', $block_content );
$block_content = str_replace( 'src=', 'data-cookieconsent="marketing" data-cookieblock-src=', $block_content );

// If there is <figcaption>, add the cookie text before it.
$figcaption_check = strpos( $block_content, '<figcaption' );
if ( false !== $figcaption_check ) {
$block_content = str_replace( '<figcaption', $cookie_text . '<figcaption', $block_content );
} else {
$block_content = str_replace( '</figure>', $cookie_text . '</figure>', $block_content );
}
}

return $block_content;
Expand Down

0 comments on commit 3808c2e

Please sign in to comment.