WP_REST_Global_Styles_Controller::validate_custom_css()protectedWP 6.2.0

Validate style.css as valid CSS.

Currently just checks for invalid markup.

Method of the class: WP_REST_Global_Styles_Controller{}

No Hooks.

Return

true|WP_Error. True if the input was validated, otherwise WP_Error.

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_custom_css( $css );
$css(string) (required)
CSS to validate.

Changelog

Since 6.2.0 Introduced.
Since 6.4.0 Changed method visibility to protected.

WP_REST_Global_Styles_Controller::validate_custom_css() code WP 6.6.1

protected function validate_custom_css( $css ) {
	if ( preg_match( '#</?\w+#', $css ) ) {
		return new WP_Error(
			'rest_custom_css_illegal_markup',
			__( 'Markup is not allowed in CSS.' ),
			array( 'status' => 400 )
		);
	}
	return true;
}