Created
November 28, 2023 19:52
-
-
Save bacoords/aa3343fcba09963429b9781515acab20 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Render columns block with extra class | |
* | |
* @param string $block_content The block content about to be rendered. | |
* @param array $block The full block, including name and attributes. | |
* @return string | |
*/ | |
function render_columns_block_class( $block_content, $block ) { | |
$columns = count( $block['innerBlocks'] ); | |
$block_content = str_replace( 'wp-block-columns', 'wp-block-columns wp-block-columns-has-' . $columns, $block_content ); | |
return $block_content; | |
} | |
add_filter( 'render_block_core/columns', 'render_columns_block_class', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment