Make WordPress Core


Ignore:
Timestamp:
02/12/2024 04:06:47 PM (15 months ago)
Author:
swissspidy
Message:

Shortcodes: Always return an array in shortcode_parse_atts().

Previously, shortcode_parse_atts() would return the input (an empty string) if a shortcode had no attributes, even though the documentation said otherwise.

Always returning an (empty) array reduces confusion and improves developer experience as the return value does not have to be manually checked in the shortcode itself.

Props: nicolefurlan, swissspidy, johnbillion, bedas.
Fixes #59249.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r57524 r57597  
    23552355 */
    23562356function img_caption_shortcode( $attr, $content = '' ) {
    2357     if ( ! $attr ) {
    2358         $attr = array();
    2359     }
    2360 
    23612357    // New-style shortcode with the caption inside the shortcode with the link and image tags.
    23622358    if ( ! isset( $attr['caption'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.