Created
April 7, 2023 02:54
-
-
Save interactiveRob/bdfe543f77afb7ca4bacc3be8c5c40b6 to your computer and use it in GitHub Desktop.
WP_HTML_Tag_Processor add_class
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 | |
$hook = "render_block_someBlock"; | |
add_filter( $hook, function($block_content, $block, $instance) { | |
$selector = explode(',', $blockInfo['selector'] ?? ''); | |
$content = new WP_HTML_Tag_Processor( $block_content ); | |
$content->next_tag( $selector ); | |
$content->add_class( 'g-rich-text' ); | |
$block_content = (string) $content; | |
return $block_content; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment