[wp-trac] [WordPress Trac] #35591: Shortcode Attributes Parsing Issue
WordPress Trac
noreply at wordpress.org
Sun Jan 24 12:03:03 UTC 2016
#35591: Shortcode Attributes Parsing Issue
----------------------------+------------------------------
Reporter: markclotfelter | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Shortcodes | Version: 4.4.1
Severity: normal | Resolution:
Keywords: close | Focuses:
----------------------------+------------------------------
Changes (by swissspidy):
* keywords: => close
Comment:
Shortcode attributes are strings, no matter what you pass them. The parser
can't know what you expect to be returned and `expert="123"`is no
different than `expert="abc"`.
In your example, `$atts['expert']` would be `'142'` (a string). If you
need an integer value, just use `(int)` or `absint()`. The same goes for
boolean flags like `foo="true"` or `bar="false"`. You should cast the
types explicitly.
Ps. I wouldn't recommend using `extract()` as it makes debugging more
difficult.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35591#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list