Skip to content

Commit

Permalink
add render shortcodes function
Browse files Browse the repository at this point in the history
  • Loading branch information
schlotterer committed Sep 1, 2024
1 parent 9284918 commit aacdb01
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion disable-shortcode-pasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,23 @@ function enqueue_block_editor_assets() {
);
}

add_action('enqueue_block_editor_assets', __NAMESPACE__ . '\\enqueue_block_editor_assets');
add_action('enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_block_editor_assets');

function render_block_with_shortcodes( $block_content, $block ) {
// Apply to reusable blocks and other block types if needed
$blocks_with_shortcodes = [
'core/paragraph',
'core/heading',
'core/quote',
'core/list',
'core/preformatted',
]; // Add more as needed

if ( in_array( $block['blockName'], $blocks_with_shortcodes ) ) {
$block_content = do_shortcode( $block_content );
}

return $block_content;
}
add_filter( 'render_block', __NAMESPACE__ . '\render_block_with_shortcodes', 10, 2 );

0 comments on commit aacdb01

Please sign in to comment.