WP_Theme_JSON::is_safe_css_declaration()protected staticWP 5.9.0

Checks that a declaration provided by the user is safe.

{} It's a 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.

Code of WP_Theme_JSON::is_safe_css_declaration() WP 6.0

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 ) );
}