[wp-trac] [WordPress Trac] #46412: Make shortcode attributes case-insensitive? shortcode_parse_atts

WordPress Trac noreply at wordpress.org
Mon Mar 4 15:44:12 UTC 2019


#46412: Make shortcode attributes case-insensitive? shortcode_parse_atts
-----------------------------+-----------------------------
 Reporter:  michael.ecklund  |      Owner:  (none)
     Type:  enhancement      |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Shortcodes       |    Version:  5.1
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 **When specifying default attributes in the callback function of my
 registered shortcode:**

 {{{#!php
 <?php
 function some_shortcode_callback( $user_attributes = array() ) {

         $default_attributes = array(
                 'someShortcodeAttribute'  => null,
         );

         $attributes = shortcode_atts( $default_attributes,
 $user_attributes );

         print_r($default_attributes);
         print_r($user_attributes);
         print_r($attributes);

         // ....

 }
 }}}


 **If the user requested this:**

 {{{
 [some_shortcode someShortcodeAttribute="test"]
 }}}


 **I would expect this:**

 {{{
 Array
 (
     [someShortcodeAttribute] =>
 )

 Array
 (
     [someShortcodeAttribute] => test
 )

 Array
 (
     [someShortcodeAttribute] => test
 )
 }}}



 **but instead, I'm getting this:**

 {{{
 Array
 (
     [someShortcodeAttribute] =>
 )

 Array
 (
     [someshortcodeattribute] => test
 )

 Array
 (
     [someShortcodeAttribute] =>
 )
 }}}


 This would always produce the default shortcode attribute and never honor
 the user specified shortcode attribute.

 Which, in my opinion, is wrong. The user requested a camel-case shortcode
 attribute and the shortcode was built to accept camel-case shortcode
 attributes. The result should be a parsed camel-case array key and
 respective value pair.

 Can we remove the `strtolower` calls on the shortcode attributes?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46412>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list