Index: trunk/phase3/includes/Html.php |
— | — | @@ -432,13 +432,31 @@ |
433 | 433 | // values. Implode/explode to get those into the main array as well. |
434 | 434 | if ( is_array( $value ) ) { |
435 | 435 | // If input wasn't an array, we can skip this step |
436 | | - $value = implode( ' ', $value ); |
| 436 | + |
| 437 | + $newValue = array(); |
| 438 | + foreach ( $value as $k => $v ) { |
| 439 | + if ( is_string( $v ) ) { |
| 440 | + // String values should be normal `array( 'foo' )` |
| 441 | + // Just append them |
| 442 | + if ( !isset( $value[$v] ) ) { |
| 443 | + // As a special case don't set 'foo' if a |
| 444 | + // separate 'foo' => true/false exists in the array |
| 445 | + // keys should be authoritive |
| 446 | + $newValue[] = $v; |
| 447 | + } |
| 448 | + } elseif ( $v ) { |
| 449 | + // If the value is truthy but not a string this is likely |
| 450 | + // an array( 'foo' => true ), falsy values don't add strings |
| 451 | + $newValue[] = $k; |
| 452 | + } |
| 453 | + } |
| 454 | + $value = implode( ' ', $newValue ); |
437 | 455 | } |
438 | 456 | $value = explode( ' ', $value ); |
439 | 457 | |
440 | 458 | // Normalize spacing by fixing up cases where people used |
441 | 459 | // more than 1 space and/or a trailing/leading space |
442 | | - $value = array_diff( $value, array( '', ' ') ); |
| 460 | + $value = array_diff( $value, array( '', ' ' ) ); |
443 | 461 | |
444 | 462 | // Remove duplicates and create the string |
445 | 463 | $value = implode( ' ', array_unique( $value ) ); |