wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_strip_custom_css_from_style_array › WordPress Function

Seit7.2.0
Veraltetn/v
› wp_strip_custom_css_from_style_array ( $style )
Zugriff:
  • private
Parameter:
  • (array) $style The block's `style` attribute.
    Erforderlich: Ja
Gibt zurück:
  • (array) The style attribute with all `css` keys removed.
Definiert in:
Codex:

Removes custom CSS from a style attribute and any nested style states.



Quellcode

function wp_strip_custom_css_from_style_array( $style ) {
	if ( ! is_array( $style ) ) {
		return $style;
	}

	unset( $style['css'] );

	foreach ( $style as $key => $value ) {
		if ( is_string( $key ) && is_array( $value ) && ( str_starts_with( $key, ':' ) || str_starts_with( $key, '@' ) ) ) {
			$nested_style = wp_strip_custom_css_from_style_array( $value );
			if ( empty( $nested_style ) ) {
				unset( $style[ $key ] );
			} else {
				$style[ $key ] = $nested_style;
			}
		}
	}

	return $style;
}