wordpress如何让用户发布文章 wordpress怎么让手机和电脑一样
创始人
2025-01-12 20:02:18
:

  今天介绍新的方法,借鉴了wp-includes/formatting.php中sanitize_user函数的写法,同样是将以下php代码复制到当前主题目录下的functions.php中,即可让WordPress支持使用中文用户名注册和登录:

  function ludou_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

  // 网上很多教程都是直接将$strict赋值false,

  // 这样会绕过字符串检查,留下隐患

  if ($strict) {

  $username = preg_replace ('|[^a-z\p{Han}0-9 _.\-@]|iu', '', $username);

  }

  $username = trim( $username );

  // Consolidate contiguous whitespace

  $username = preg_replace( '|\s+|', ' ', $username );

  return $username;

  }

  add_filter ('sanitize_user', 'ludou_sanitize_user', 10, 3);

相关内容

热门资讯

东软集团等成立康养公司 含AI... 人民财讯2月10日电,企查查APP显示,近日,福州福见康养有限公司成立,经营范围包含:养老服务;人工...
Naver计划推出AI购物代理... 新榜讯 2月10日讯,韩国互联网头部平台Naver官宣迈入“AI电商”时代,其计划推出一款面向购物场...
AI回答别成“AI推销” 本图由AI生成 什么牌子的净水器质量好?北京周边两日游选哪家旅行社?……如今,面对这些问题,越来越多...
Check Point:AI时... Check Point:AI时代策马加速,网络安全需同步升级 随着春节临近,人工智能正推动互联网生态...