Changeset 57597
- Timestamp:
- 02/12/2024 04:06:47 PM (10 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r57524 r57597 2355 2355 */ 2356 2356 function img_caption_shortcode( $attr, $content = '' ) { 2357 if ( ! $attr ) {2358 $attr = array();2359 }2360 2361 2357 // New-style shortcode with the caption inside the shortcode with the link and image tags. 2362 2358 if ( ! isset( $attr['caption'] ) ) { -
trunk/src/wp-includes/shortcodes.php
r57584 r57597 601 601 * 602 602 * @since 2.5.0 603 * @since 6.5.0 The function now always returns an empty array, 604 * even if the original arguments string cannot be parsed or is empty. 603 605 * 604 606 * @param string $text Shortcode arguments list. 605 * @return array |stringArray of attribute values keyed by attribute name.606 * Returns empty array if there are no attributes.607 * Returns the original arguments string if itcannot be parsed.607 * @return array Array of attribute values keyed by attribute name. 608 * Returns empty array if there are no attributes 609 * or if the original arguments string cannot be parsed. 608 610 */ 609 611 function shortcode_parse_atts( $text ) { … … 636 638 } 637 639 } 638 } else {639 $atts = ltrim( $text );640 640 } 641 641 -
trunk/tests/phpunit/tests/shortcode.php
r56548 r57597 106 106 } 107 107 108 /** 109 * @ticket 59249 110 */ 108 111 public function test_noatts() { 109 112 do_shortcode( '[test-shortcode-tag /]' ); 110 $this->assertSame( '', $this->atts ); 113 $this->assertIsArray( $this->atts ); 114 $this->assertEmpty( $this->atts ); 111 115 $this->assertSame( 'test-shortcode-tag', $this->tagname ); 112 116 } … … 182 186 } 183 187 188 /** 189 * @ticket 59249 190 */ 184 191 public function test_noatts_enclosing() { 185 192 do_shortcode( '[test-shortcode-tag]content[/test-shortcode-tag]' ); 186 $this->assertSame( '', $this->atts ); 193 $this->assertIsArray( $this->atts ); 194 $this->assertEmpty( $this->atts ); 187 195 $this->assertSame( 'content', $this->content ); 188 196 $this->assertSame( 'test-shortcode-tag', $this->tagname ); … … 209 217 } 210 218 219 /** 220 * @ticket 59249 221 */ 211 222 public function test_unclosed() { 212 223 $out = do_shortcode( '[test-shortcode-tag]' ); 213 224 $this->assertSame( '', $out ); 214 $this->assertSame( '', $this->atts ); 225 $this->assertIsArray( $this->atts ); 226 $this->assertEmpty( $this->atts ); 215 227 $this->assertSame( 'test-shortcode-tag', $this->tagname ); 216 228 } … … 999 1011 $this->assertSame( 'test-shortcode-tag', $this->tagname ); 1000 1012 } 1013 1014 /** 1015 * @ticket 59249 1016 */ 1017 public function test_shortcode_parse_atts_empty() { 1018 $out = shortcode_parse_atts( '' ); 1019 $this->assertIsArray( $out, 'Return value is not an array' ); 1020 $this->assertEmpty( $out, 'Returned array is not empty' ); 1021 } 1001 1022 }
Note: See TracChangeset
for help on using the changeset viewer.