| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: Allow Arabic Usernames |
|---|
| 4 | Plugin URI: http://core.trac.wordpress.org/ticket/5918 |
|---|
| 5 | Description: Allows users to register with Arabic usernames. |
|---|
| 6 | Author: Sergey Biryukov |
|---|
| 7 | Author URI: http://profiles.wordpress.org/sergeybiryukov/ |
|---|
| 8 | Version: 0.1 |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | function aau_sanitize_user($username, $raw_username, $strict) { |
|---|
| 12 | $username = wp_strip_all_tags( $raw_username ); |
|---|
| 13 | $username = remove_accents( $username ); |
|---|
| 14 | // Kill octets |
|---|
| 15 | $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); |
|---|
| 16 | $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities |
|---|
| 17 | |
|---|
| 18 | // If strict, reduce to ASCII and Arabic characters for max portability. |
|---|
| 19 | if ( $strict ) |
|---|
| 20 | $username = preg_replace( '|[^a-z\p{Arabic}0-9 _.\-@]|iu', '', $username ); |
|---|
| 21 | |
|---|
| 22 | $username = trim( $username ); |
|---|
| 23 | // Consolidate contiguous whitespace |
|---|
| 24 | $username = preg_replace( '|\s+|', ' ', $username ); |
|---|
| 25 | |
|---|
| 26 | return $username; |
|---|
| 27 | } |
|---|
| 28 | add_filter('sanitize_user', 'aau_sanitize_user', 10, 3); |
|---|
| 29 | ?> |
|---|