Skip to content

Commit

Permalink
Check figcaption also.
Browse files Browse the repository at this point in the history
  • Loading branch information
samikeijonen committed Mar 29, 2023
1 parent 5467f07 commit 3d1caa8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion inc/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ function render_block( $block_content, $block ) {
$cookie_text .= '</p></div>';

$block_content = str_replace( 'src=', 'data-cookieconsent="marketing" data-cookieblock-src=', $block_content );
$block_content = str_replace( '</figure>', $cookie_text . '</figure>', $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 3d1caa8

Please sign in to comment.