On this page
WP_Theme_JSON::is_safe_css_declaration( string $property_name, string $property_value ): bool
Checks that a declaration provided by the user is safe.
Parameters
$property_namestring Required-
Property name in a CSS declaration, i.e. the
colorincolor: red. $property_valuestring Required-
Value in a CSS declaration, i.e. the
redincolor: red.
Return
bool
Source
File: wp-includes/class-wp-theme-json.php. View all references
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 ) );
}
Related
Uses
| Uses | Description |
|---|---|
| safecss_filter_attr() wp-includes/kses.php | Filters an inline style attribute and removes disallowed rules. |
| esc_html() wp-includes/formatting.php | Escaping for HTML blocks. |
Changelog
| Version | Description |
|---|---|
| 5.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/is_safe_css_declaration