WP_Theme_JSON::is_safe_css_declaration()protected staticWP 5.9.0

Checks that a declaration provided by the user is safe.

Method of the class: WP_Theme_JSON{}

No Hooks.

Return

true|false.

Usage

$result = WP_Theme_JSON::is_safe_css_declaration( $property_name, $property_value );
$property_name(string) (required)
Property name in a CSS declaration, i.e. the color in color: red.
$property_value(string) (required)
Value in a CSS declaration, i.e. the red in color: red.

Changelog

Since 5.9.0 Introduced.

WP_Theme_JSON::is_safe_css_declaration() code WP 6.6.2

protected static function is_safe_css_declaration( $property_name, $property_value ) {
	$style_to_validate = $property_name . ': ' . $property_value;
	$filtered          = esc_html( safecss_filter_attr( $style_to_validate ) );
	return ! empty( trim( $filtered ) );
}