mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-07 09:26:55 +02:00
Feature custom page options (#1104)
* Add slug util function * Add custom add modals support
This commit is contained in:
committed by
Flavio Copes
parent
c30accdea4
commit
bc011c25c3
@@ -35,4 +35,26 @@ class Utils
|
||||
// If a User with the provided email cannot be found, then load user with that email as the username
|
||||
return User::load($email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a slug of the given string
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
public static function slug($str)
|
||||
{
|
||||
if (function_exists('transliterator_transliterate')) {
|
||||
$str = transliterator_transliterate('Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove;', $str);
|
||||
} else {
|
||||
$str = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str);
|
||||
}
|
||||
|
||||
$str = strtolower($str);
|
||||
$str = preg_replace('/[-\s]+/', '-', $str);
|
||||
$str = preg_replace('/[^a-z0-9-]/i', '', $str);
|
||||
$str = trim($str, '-');
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user