[wp-trac] [WordPress Trac] #47863: Fix odd, unexpected output from shortcode_parse_attts

WordPress Trac noreply at wordpress.org
Mon Aug 12 10:14:52 UTC 2019


#47863: Fix odd, unexpected output from shortcode_parse_attts
--------------------------------------+-----------------------------
 Reporter:  mauteri                   |       Owner:  SergeyBiryukov
     Type:  defect (bug)              |      Status:  reviewing
 Priority:  normal                    |   Milestone:  5.3
Component:  Shortcodes                |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-----------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:6 mauteri]:
 > Could that standard now be dated since shorthand arrays in PHP was
 introduced in PHP 5.4 and maybe the WordPress standard should be updated
 to reflect what is possible in the new minimum version of PHP?

 The [https://make.wordpress.org/core/2019/07/12/php-coding-standards-
 changes/ PHP Coding Standards Changes] post linked above explains the
 reasoning:
 >> **Short Array Syntax**
 >> A little less controversial, but still with varying opinions, was the
 proposal to require short array syntax ( `[ 1, 2, 3 ]` ) instead of long
 array syntax ( `array( 1, 2, 3 )` ) for declaring arrays.
 >>
 >> While I’m personally partial to short array syntax, there were two
 particularly convincing arguments for using long array syntax:
 >>
 >> * It’s easier to distinguish from other forms of braces, particularly
 for those with vision difficulties.
 >> * It’s much more descriptive for beginners.
 >>
 >> So, this change to the coding standards is the opposite of what was
 originally proposed, but is ultimately the more inclusive option.
 >>
 >> **Coding Standards Change**
 >> Arrays must be declared using long array syntax in WordPress Core.


 > Also, I found the `$text` parameter naming to be a bit odd. Just from
 seeing the name of the function `shortcode_parse_atts` seems it should
 ONLY accept shortcodes to have their atts parsed (which made it very odd
 to me when it messed that up in the first place).  Seems a better name for
 that argument would be `$shortcode` to make it very clear that a shortcode
 should be passed to it to have its atts parsed.

 Based on the current usage in core (a string of shortcode attributes,
 rather than a full shortcode), I would keep the `$text` name as is and
 clarify in the documentation that it can also be a shortcode. That said, I
 wouldn't object too strongly to changing the name.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47863#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list