Changeset 61603
- Timestamp:
- 02/09/2026 05:08:13 PM (2 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/class-wp-duotone.php (modified) (3 diffs)
-
tests/phpunit/tests/block-supports/duotone.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-duotone.php
r61457 r61603 547 547 * @since 6.3.0 548 548 * 549 * @param string $duotone_attr The duotone attribute from a block.550 * @return string The slug of the duotone preset or an empty string if no slug is found .549 * @param string|string[] $duotone_attr The duotone attribute from a block. 550 * @return string The slug of the duotone preset or an empty string if no slug is found (including when an array was passed). 551 551 */ 552 552 private static function get_slug_from_attribute( $duotone_attr ) { 553 if ( ! is_string( $duotone_attr ) ) { 554 return ''; 555 } 556 553 557 // Uses Branch Reset Groups `(?|…)` to return one capture group. 554 558 preg_match( '/(?|var:preset\|duotone\|(\S+)|var\(--wp--preset--duotone--(\S+)\))/', $duotone_attr, $matches ); … … 567 571 * 568 572 * @param string $duotone_attr The duotone attribute from a block. 569 * @ return bool True if the duotone preset present and valid.573 * @param string|string[] $duotone_attr The duotone attribute from a block. 570 574 */ 571 575 private static function is_preset( $duotone_attr ) { 576 if ( ! is_string( $duotone_attr ) ) { 577 return false; 578 } 579 572 580 $slug = self::get_slug_from_attribute( $duotone_attr ); 573 581 $filter_id = self::get_filter_id( $slug ); … … 1051 1059 } 1052 1060 // If it has a duotone filter preset, save the block name and the preset slug. 1061 // Only process if it's a string (preset reference), not an array (custom colors). 1062 if ( ! is_string( $duotone_attr ) ) { 1063 continue; 1064 } 1065 1053 1066 $slug = self::get_slug_from_attribute( $duotone_attr ); 1054 1067 -
trunk/tests/phpunit/tests/block-supports/duotone.php
r61008 r61603 94 94 'css-var-spaces' => array( 'var(--wp--preset--duotone-- ', '' ), 95 95 'pipe-slug-spaces' => array( 'var:preset|duotone| ', '' ), 96 'array-of-colors' => array( array( '#000000', '#ffffff' ), '' ), 97 'empty-array' => array( array(), '' ), 96 98 ); 97 99 } … … 165 167 'css-var-missing-end-parenthesis' => array( 'var(--wp--preset--duotone--blue-orange', false ), 166 168 'invalid' => array( 'not a valid attribute', false ), 169 'array-of-colors' => array( array( '#000000', '#ffffff' ), false ), 170 'empty-array' => array( array(), false ), 167 171 ); 168 172 }
Note: See TracChangeset
for help on using the changeset viewer.