summaryrefslogtreecommitdiffstats
path: root/core/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/functions.php')
-rw-r--r--core/functions.php16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/functions.php b/core/functions.php
index 2e36524..89ed2f5 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -326,13 +326,17 @@ function description($string, $length = 200, $replace = ' […]') {
#===============================================================================
# Generate a valid slug URL part from a string
#===============================================================================
-function makeSlugURL($string) {
- $string = mb_strtolower($string);
- $string = str_replace(['ä', 'ö', 'ü', 'ß'], ['ae', 'oe', 'ue', 'ss'], $string);
- $string = preg_replace('/[^a-z0-9\-]/', '-', $string);
- $string = preg_replace('/-+/', '-', $string);
+function makeSlugURL($string, $separator = '-') {
+ $string = strtr(mb_strtolower($string), [
+ 'ä' => 'ae',
+ 'ö' => 'oe',
+ 'ü' => 'ue',
+ 'ß' => 'ss'
+ ]);
+
+ $string = preg_replace('#[^[:lower:][:digit:]]+#', $separator, $string);
- return trim($string, '-');
+ return trim($string, $separator);
}
#===============================================================================