[wp-trac] [WordPress Trac] #31093: Make $tag argument optional for has_shortcode()
WordPress Trac
noreply at wordpress.org
Thu Jan 22 20:36:23 UTC 2015
#31093: Make $tag argument optional for has_shortcode()
------------------------------------------------+--------------------------
Reporter: danielbachhuber | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future
Component: Shortcodes | Release
Severity: normal | Version:
Keywords: has-patch dev-feedback 2nd-opinion | Resolution:
| Focuses:
------------------------------------------------+--------------------------
Comment (by danielbachhuber):
> It is quick enough to check the original string against the result of
strip_shortcodes() over the string.
Clever suggestion — didn't think of that. I pulled and am using the regex
from `has_shortcode()`
> A little in doubt here - how would you expect this to work? If you pass
an array with 2 shortcodes, and one of them is found, would it return true
or false?
Return `true` (aka `OR` condition)
> Not sure if that function should support an array along with a relation
to compare, because one can do that with multiple calls to it, but I
believe the concern would be not to do a regex search multiple times.
Yes, my use case for checking multiple shortcodes at once is so I have one
regex call instead of many.
Regardless, any of these patches would need unit tests.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31093#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list