[wp-trac] [WordPress Trac] #62694: Title: wpautop Misuse in the "widget_block_content" Filter with Shortcode Block
WordPress Trac
noreply at wordpress.org
Sat Dec 14 23:30:18 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 | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
The `widget_block_content` filter introduces invalid HTML when processing
content from the Shortcode block. Specifically, when a shortcode returns a
block-level element like a `<div>`, it is improperly wrapped in `<p>`
tags, resulting in invalid markup.
== Steps to Reproduce ==
1. Create a simple shortcode in your theme or plugin:
{{{#!php
<?php
add_shortcode( 'my_test_shortcode', function() {
return '<div>something amazing...</div>';
} );
}}}
2. Go to ''Appearance > Widgets'' in the WordPress admin area.
3. Add a ''Shortcode block'' and use `[my_test_shortcode]` as its content.
4. Save and view the output on the front-end. Notice that the `<div>`
returned by the shortcode is wrapped in `<p>` tags, resulting in:
{{{#!html
<p><div>something amazing...</div></p>
}}}
== Expected Behavior ==
The shortcode output should render the block-level `<div>` without
additional wrapping `<p>` tags, maintaining valid HTML structure.
== Proposed Solution ==
Consider modifying the `widget_block_content` filter to handle shortcodes
correctly and respect block-level elements, preventing improper wrapping
by `wpautop`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62694>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list