Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

salcode/fe-sanitize-title-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanitize Title JavaScript Shortcode

This project is no longer actively maintained. WordPress core has introduced the JavaScript cleanForSlug, which appears to be a good alternative.

cleanForSlug() is available as part of the @wordpress/url npm package.


This WordPress plugin enables the shortcode [sanitize-title-js], which is a demo of the JavaScript function wpFeSanitizeTitle(), which is a JavaScript function that mimics the behavior of the WordPress PHP function sanitize_title().

The function wpFeSanitizeTitle() can be found in this plugin at assets/wp-fe-sanitize-title.js. This JavaScript function is used by supplying a single parameter of type string, which will then be sanitized into a format usable as a URL slug.

Example

wpFeSanitizeTitle( 'Spaces, -Dashes-, and other ch@racter$ are %REMOVED%!' );

will result in

spaces-dashes-and-other-chracter-are-removed

Credits

Sal Ferrarello / @salcode

About

WordPress plugin to demo wpFeSanitizeTitle() JavaScript function

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors