[wp-trac] [WordPress Trac] #23307: shortcode_parse_atts may return empty string

WordPress Trac noreply at wordpress.org
Mon Jan 28 11:08:51 UTC 2013


#23307: shortcode_parse_atts may return empty string
-----------------------------+--------------------------
 Reporter:  GaryJ            |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Shortcodes
  Version:                   |   Severity:  minor
 Keywords:                   |
-----------------------------+--------------------------
 See http://core.trac.wordpress.org/browser/tags/3.5.1/wp-
 includes/shortcodes.php#L243 .

 If there are no attributes in a shortcode e.g. `[foobar]`, then
 shortcode_parse_atts returns an empty string. This is not reflected in the
 long description or `@return` tag.

 Ideally though, it should return an empty array, so that it's not only
 consistent, but writing a shortcode function can type hint the `$atts`
 argument to be an array e.g.

 {{{
 add_shortcode( 'foo', 'my_shortcode' );
 function my_shortcode( array $atts ) {
    ...
 }
 }}}

 This might also be combined with checking if the incoming `$text` is
 empty, and returning an empty array immediately.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23307>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list