-
-
Save rayhanuddin2019/7806f9400696f19b2e903654d17ce327 to your computer and use it in GitHub Desktop.
Gutenberg override core block
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
<?php | |
// https://developer.wordpress.org/reference/hooks/render_block/ | |
add_filter( 'render_block', 'foo_core_gallery_filter', 10, 3); | |
function foo_core_gallery_filter( $block_content, $block ) { | |
// use blockName to only affect the desired block | |
if( "core/calendar" !== $block['blockName'] ) { | |
return $block_content; | |
} | |
// $block_content contains all the data passed to the block callback function | |
// $block contains the serialized block markup | |
// Here you have all content over the block. Either wrap it in your container or totally replace the content | |
$output = '<h2 class="foo-gallery">'; | |
$output .= 'GALLERY'; | |
$output .= '</h2>'; | |
// return the new content of the block | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment