mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
I18N: Introduce sanitization function for locale.
Introduce the `sanitize_locale_name()` for sanitizing user input of locales. Props xknown, timothyblynjacobs, ocean90, peterwilsoncc. git-svn-id: https://develop.svn.wordpress.org/trunk@55760 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2433,6 +2433,29 @@ function sanitize_html_class( $classname, $fallback = '' ) {
|
||||
return apply_filters( 'sanitize_html_class', $sanitized, $classname, $fallback );
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips out all characters not allowed in a locale name.
|
||||
*
|
||||
* @since 6.2.1
|
||||
*
|
||||
* @param string $locale_name The locale name to be sanitized.
|
||||
* @return string The sanitized value.
|
||||
*/
|
||||
function sanitize_locale_name( $locale_name ) {
|
||||
// Limit to A-Z, a-z, 0-9, '_', '-'.
|
||||
$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $locale_name );
|
||||
|
||||
/**
|
||||
* Filters a sanitized locale name string.
|
||||
*
|
||||
* @since 6.2.1
|
||||
*
|
||||
* @param string $sanitized The sanitized locale name.
|
||||
* @param string $locale_name The locale name before sanitization.
|
||||
*/
|
||||
return apply_filters( 'sanitize_locale_name', $sanitized, $locale_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts lone & characters into `&` (a.k.a. `&`)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user