[wp-trac] [WordPress Trac] #58174: A shortcode block that evaluates to nothing, renders as a space in the HTML
WordPress Trac
noreply at wordpress.org
Sat Apr 22 18:17:48 UTC 2023
#58174: A shortcode block that evaluates to nothing, renders as a space in the HTML
--------------------------+------------------------------
Reporter: asafm7 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by asafm7):
Okay, so it is a line break (\n).
It is being added here:
{{{
$content = preg_replace_callback("/$pattern/", 'do_shortcode_tag',
$content);
}}}
In the do_shortcode() function in shortcodes.php.
I made sure the 'do_shortcode_tag' output never contains \n. But still,
after this line, the $content contains \n in place of empty shortcodes. It
doesn't make a lot of sense, but it seems there is some kind of bug with
the native preg_replace_callback() PHP function.
Adding a
{{{
$content = str_replace(">\n", ">", $content);
}}}
fixes the problem.
There is no filter after this point though, so it seems it can't be fixed
without modifying the core code.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58174#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list