WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 6 years ago

Last modified 6 years ago

#21158 closed defect (bug) (invalid)

different result when shortcode atribute without value

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

Description

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 (3)

#1 @mordauk
6 years 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.

#2 @miqrogroove
6 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#3 @DrewAPicture
6 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.