WP_REST_Global_Styles_Controller::validate_custom_css( string $css ): true|WP_Error

Validate style.css as valid CSS.

Description

Currently just checks for invalid markup.

Parameters

$cssstringrequired
CSS to validate.

Return

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

Source

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

Changelog

VersionDescription
6.4.0Changed method visibility to protected.
6.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.