Skip to content
Snippets Groups Projects
Commit 690deeb4 authored by aydreeihn's avatar aydreeihn
Browse files

Merge remote-tracking branch 'kevin/issue/page-name-slugify' into features_prs/develop-next

parents 6f4853fd 2928f162
Branches
Tags
No related merge requests found
...@@ -739,6 +739,13 @@ class Format { ...@@ -739,6 +739,13 @@ class Format {
// Thanks, http://stackoverflow.com/a/2955878/1025836 // Thanks, http://stackoverflow.com/a/2955878/1025836
/* static */ /* static */
function slugify($text) { function slugify($text) {
// convert special characters to entities
$text = htmlentities($text, ENT_NOQUOTES, 'UTF-8');
// removes entity suffixes, leaving only un-accented characters
$text = preg_replace('~&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);~', '$1', $text);
$text = preg_replace('~&([A-za-z]{2})(?:lig);~', '$1', $text);
// replace non letter or digits by - // replace non letter or digits by -
$text = preg_replace('~[^\p{L}\p{N}]+~u', '-', $text); $text = preg_replace('~[^\p{L}\p{N}]+~u', '-', $text);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment