我不认为有任何关于这方面的官方文件,但你可以看看sanitize_user
中的函数wp-includes/formatting.php
:
function sanitize_user( $username, $strict = false ) {
$raw_username = $username;
$username = wp_strip_all_tags( $username );
$username = remove_accents( $username );
// Kill octets
$username = preg_replace( \'|%([a-fA-F0-9][a-fA-F0-9])|\', \'\', $username );
$username = preg_replace( \'/&.+?;/\', \'\', $username ); // Kill entities
// If strict, reduce to ASCII for max portability.
if ( $strict )
$username = preg_replace( \'|[^a-z0-9 _.\\-@]|i\', \'\', $username );
$username = trim( $username );
// Consolidate contiguous whitespace
$username = preg_replace( \'|\\s+|\', \' \', $username );
return apply_filters( \'sanitize_user\', $username, $raw_username, $strict );
}
您可以挂接到该函数中,并用自己的行为覆盖默认行为。