Created
December 10, 2019 19:04
-
-
Save saltnpixels/4dbc53eb16ba7612ede444b6c33ea006 to your computer and use it in GitHub Desktop.
Render_block_filter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test_filter( $block_content, $block ) { | |
if ( empty( trim( $block_content ) ) ) { | |
return $block_content; | |
} | |
if ( $block['blockName'] == 'core/paragraph' ) { | |
return sprintf( | |
'<section class="block-%1$s">%2$s</section>', | |
sanitize_title( $block['blockName'] ), | |
$block_content | |
); | |
} | |
return $block_content; | |
} | |
add_filter( 'render_block', 'test_filter', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment