Last active
September 20, 2022 19:27
-
-
Save justintadlock/ff27b00de0b28726b3336cde8d01806b to your computer and use it in GitHub Desktop.
Converts piped "preset" colors from global styles to their var() equivalents.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Converts piped "preset" colors from global styles to their var() equivalents. | |
// Borrowed from `wp_render_elements_support_styles()` | |
function jt_format_color_preset( $color ) { | |
if ( strpos( $color, 'var:preset|color|' ) !== false ) { | |
$index = strrpos( $color, '|' ) + 1; | |
$name = substr( $color, $index ); | |
$color = "var(--wp--preset--color--$name)"; | |
} | |
return esc_html( $color ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: