Is there an equivalent of the PHP function sanitize_key in Gutenberg?

Use import { cleanForSlug } from "@wordpress/editor"; in your block.js file to import the function in and then use the it like cleanForSlug(stringToClean) to create the ID’s.

Leave a Comment