Make WordPress Core

Opened 22 months ago

Last modified 3 months ago

#21158 new defect (bug)

different result when shortcode atribute without value

Reported by: thomask Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.4
Component: Shortcodes Keywords:
Focuses: Cc:


imagine those two shortcodes

[shortcode attribute]
[shortcode attribute=value]

IMO they should have the same result, just the second should have some value to the attribute and the first should have NULL or false

But if you do

add_shortcode( 'shortcode', 'my_shortcode' );
function my_shortcode( $atts ) { print_r ($atts); }

the first shortcode results in

array (
  0 => 'attribute',

while the second in

array (
  'attribute' => 'value',

I'm not sure, maybe it is intentional, i have not found any description, what should shortcode attribute without value do. But imo it should work as i have described as it is the only way how it could clear some predefined value (the only other way is to set it to empty string, which may not always be the same as NULL or FALSE).

Change History (1)

comment:1 mordauk3 months ago

I can't think of any reason why it should ever be anyway but your second example. If the attribute has no value, the value of the array key should just be null, false, or an empty string.

Note: See TracTickets for help on using tickets.