// Regex for CSS value borrowed from `safecss_filter_attr`, and used here
// because we only want to match against the value, not the CSS attribute.
if ( is_array( $gap ) ) { foreach ( $gap as $key =>
$value ) { // Make sure $value is a string to avoid PHP 8.1 deprecation error in preg_match() when the value is null.
$value =
is_string( $value ) ?
$value : '';
$value =
$value &&
preg_match( '%[\\\(&=}]|/\*%',
$value ) ? null :
$value;
// Get spacing CSS variable from preset value if provided.
if ( is_string( $value ) &&
str_contains( $value, 'var:preset|spacing|'
) ) { $index_to_splice =
strrpos( $value, '|'
) + 1;
$slug =
_wp_to_kebab_case( substr( $value,
$index_to_splice ) );
$value = "var(--wp--preset--spacing--
$slug)";
} $gap[ $key ] =
$value;
} } else { // Make sure $gap is a string to avoid PHP 8.1 deprecation error in preg_match() when the value is null.
$gap =
is_string( $gap ) ?
$gap : '';
$gap =
$gap &&
preg_match( '%[\\\(&=}]|/\*%',
$gap ) ? null :
$gap;
// Get spacing CSS variable from preset value if provided.