WordPress.org

Make WordPress Core

Ticket #9045: 9045_shortcode.diff

File 9045_shortcode.diff, 1.5 KB (added by hailin, 6 years ago)

patch

  • C:/xampp/htdocs/wordpress_trunk/wp-includes/shortcodes.php

     
    88 * 
    99 * [shortcode /] 
    1010 * [shortcode foo="bar" baz="bing" /] 
     11 * [shortcode 12345 foo="bar" baz="bing" /] 
    1112 * [shortcode foo="bar"]content[/shortcode] 
    1213 * 
    1314 * Shortcode tags support attributes and enclosed content, but does not entirely 
     
    199200 * Retrieve all attributes from the shortcodes tag. 
    200201 * 
    201202 * The attributes list has the attribute name as the key and the value of the 
    202  * attribute as the value in the key/value pair. This allows for easier 
    203  * retrieval of the attributes, since all attributes have to be known. 
     203 * attribute as the value in the key/value pair.  
     204 * In addition, use default numeric index for unpaired attributes   
     205 * This allows for easier retrieval of the attributes, since all attributes have to be known. 
    204206 * 
    205207 * @since 2.5 
    206208 * 
     
    224226                        elseif (isset($m[8])) 
    225227                                $atts[] = stripcslashes($m[8]); 
    226228                } 
    227         } else { 
    228                 $atts = ltrim($text); 
     229        }  
     230         
     231        $unpaired_attrs = preg_replace( $pattern, '', $text );  
     232        $unpaired_attrs = trim( $unpaired_attrs );  
     233        if ( empty($unpaired_attrs) ) 
     234                return $atts; 
     235         
     236        if ( preg_match_all('/(\w+)\s*/', $unpaired_attrs, $unpaired_matches, PREG_SET_ORDER) ) { 
     237                foreach( $unpaired_matches as $m ) 
     238                        $atts[] = $m[1];  
    229239        } 
     240         
    230241        return $atts; 
    231242} 
    232243