我们在使用wordpress建站的过程当中,有些客户要求后台可以使用中文用户名来进行注册和登录。借鉴wp-includes/formatting.PHP中sanitize_user函数的写法,可以使用下面的方法实现。
切换到模板目录,打开 functions.PHP 文件,添加如下代码:
Crayon-5c891d4e4ea9a822073184" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">functions.PHP
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-mixed-highlight" title="Contains Mixed Languages">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">
Crayon-nums " data-settings="show"> Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"> Crayon-num" data-line="Crayon-5c891d4e4ea9a822073184-1">1 Crayon-num" data-line="Crayon-5c891d4e4ea9a822073184-3">3 Crayon-num" data-line="Crayon-5c891d4e4ea9a822073184-5">5 Crayon-num" data-line="Crayon-5c891d4e4ea9a822073184-7">7 Crayon-num" data-line="Crayon-5c891d4e4ea9a822073184-9">9 Crayon-num" data-line="Crayon-5c891d4e4ea9a822073184-11">11 Crayon-num" data-line="Crayon-5c891d4e4ea9a822073184-13">13 Crayon-num" data-line="Crayon-5c891d4e4ea9a822073184-15">15 | Crayon-code">