| 485 | * Split up multiple enclosures into a list of attributes. |
| 486 | * |
| 487 | * @since 4.4.0 |
| 488 | * |
| 489 | * @param string $input The enclosed content, including any attribute delimiters. |
| 490 | * @param string $tag The name of the parent shortcode. |
| 491 | * @return array List of attributes and their value, where the first item is the primary content. |
| 492 | */ |
| 493 | function shortcode_parse_enclosures( $input, $tag ) { |
| 494 | $tag = preg_quote( $tag ); |
| 495 | |
| 496 | // Regex group arranged so that we split on the delimeters, but then only capture the name portion. :) |
| 497 | $textarr = preg_split( "/\[$tag:([^=]*)=\]/", $input, -1, PREG_SPLIT_DELIM_CAPTURE ); |
| 498 | |
| 499 | // Check for multiple enclosures. |
| 500 | $c = count( $textarr ); |
| 501 | if ( 1 == $c ) { |
| 502 | return $textarr; |
| 503 | } |
| 504 | |
| 505 | // List multiple enclosures, starting with the primary content. |
| 506 | $encl = array( $textarr[0] ); |
| 507 | for ( $i = 1; $i < $c; $i += 2 ) { |
| 508 | // Now $i is the name's index and $i+1 is the value's index. |
| 509 | if ( ! empty( $textarr[ $i ] ) ) { |
| 510 | $encl[ strtolower( $textarr[ $i ] ) ] = $textarr[ $i + 1 ]; |
| 511 | } else { |
| 512 | $encl[] = $textarr[ $i + 1 ]; |
| 513 | } |
| 514 | } |
| 515 | return $encl; |
| 516 | } |
| 517 | |
| 518 | /** |