<?php
/*
Plugin Name: Allow Arabic Usernames
Plugin URI: http://core.trac.wordpress.org/ticket/5918
Description: Allows users to register with Arabic usernames.
Author: Sergey Biryukov
Author URI: http://profiles.wordpress.org/sergeybiryukov/
Version: 0.1
*/ 

function aau_sanitize_user($username, $raw_username, $strict) {
	$username = wp_strip_all_tags( $raw_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 and Arabic characters for max portability.
	if ( $strict )
		$username = preg_replace( '|[^a-z\p{Arabic}0-9 _.\-@]|iu', '', $username );

	$username = trim( $username );
	// Consolidate contiguous whitespace
	$username = preg_replace( '|\s+|', ' ', $username );

	return $username;
}
add_filter('sanitize_user', 'aau_sanitize_user', 10, 3);
?>