Make WordPress Core

Ticket #18666: allow-arabic-usernames.php

File allow-arabic-usernames.php, 982 bytes (added by SergeyBiryukov, 14 years ago)
Line 
1<?php
2/*
3Plugin Name: Allow Arabic Usernames
4Plugin URI: http://core.trac.wordpress.org/ticket/5918
5Description: Allows users to register with Arabic usernames.
6Author: Sergey Biryukov
7Author URI: http://profiles.wordpress.org/sergeybiryukov/
8Version: 0.1
9*/ 
10
11function 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}
28add_filter('sanitize_user', 'aau_sanitize_user', 10, 3);
29?>