[wp-trac] [WordPress Trac] #50683: Parse content for shortcodes instead of using regex
WordPress Trac
noreply at wordpress.org
Mon Mar 30 22:30:00 UTC 2026
#50683: Parse content for shortcodes instead of using regex
-------------------------------------------------+-------------------------
Reporter: cfinke | Owner: (none)
Type: enhancement | Status: reviewing
Priority: normal | Milestone: Future
| Release
Component: Shortcodes | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs- | Focuses:
test-info |
-------------------------------------------------+-------------------------
Comment (by dmsnell):
In recent months I’ve come to the opinion that we //must// declare
Shortcode processing as a step ahead of HTML parsing. There is a
particular construction common in some shortcodes that illustrate this
point..
{{{
<p>This site contains [post-count before="<span class='post-count'>"
after="</span>"] posts</p>
}}}
Now this example raises questions regarding translation, but looking those
aside, it embeds HTML inside its shortcode arguments. We can only use the
HTML API to find this if we break spec-compliance to find these. That is
not something that I believe will help WordPress as it will make it near
impossible to maintain that spec-compliance through the test suite we’ve
established. It would be a huge step backwards.
Pending any actual behavioral changes (i.e. backwards-compatibility
breaks) this would imply we have to handle Shortcodes before processing
HTML. I believe that the associated PRs and patches do this, but I wanted
to leave this note in the open about it. To my knowledge, this is not
spec’d in WordPress and different existing flows probably handle these
before //or// after processing HTML.
For example, if the goal is to extract the first three paragraphs of a
post…we have to process all shortcodes //before// truncating the document.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50683#comment:47>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list