[wp-trac] [WordPress Trac] #62694: Title: wpautop Misuse in the "widget_block_content" Filter with Shortcode Block
WordPress Trac
noreply at wordpress.org
Sun Dec 15 09:50:32 UTC 2024
#62694: Title: wpautop Misuse in the "widget_block_content" Filter with Shortcode
Block
--------------------------+------------------------------
Reporter: arl1nd | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 6.7.1
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+------------------------------
Comment (by dilip2615):
Hello @arl1nd you can try this if this suggestion is helpful.
Create a Filter for widget_block_content:
Add this code to your theme's functions.php file or a custom plugin:
If this issue affects multiple shortcodes or needs a global solution, you
can add a generalized filter:
{{{#!php
<?php
add_filter('widget_block_content', 'handle_shortcode_output', 10, 2);
function handle_shortcode_output($content, $block) {
remove_filter('the_content', 'wpautop');
$content = do_shortcode($content);
add_filter('the_content', 'wpautop');
return $content;
}
}}}
This ensures wpautop won't interfere with any shortcode processed within
widget blocks.
Let me know if you need further clarification or adjustments!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62694#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list