Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何防止在WordPress后期发布中插入特殊字体_Php_Wordpress - Fatal编程技术网

Php 如何防止在WordPress后期发布中插入特殊字体

Php 如何防止在WordPress后期发布中插入特殊字体,php,wordpress,Php,Wordpress,在WordPress中我的博客/文章发布网站上,一些用户发布特殊字体/字符。。像 “IndrėLeonavičiūtė谈论区块链的用户体验” 如果用户在帖子标题中插入这一行,那么我想验证Leonavičiūtė 我发现这个Wordpress函数可以删除重音(string$string) 但如何将其应用于内容 我需要添加一个wp管理员提交后验证,以防止其错误。 请帮帮我 像这样使用内容过滤器 function my_the_content_filter($content) { remove_

在WordPress中我的博客/文章发布网站上,一些用户发布特殊字体/字符。。像

IndrėLeonavičiūtė谈论区块链的用户体验” 如果用户在帖子标题中插入这一行,那么我想验证Leonavičiūtė

我发现这个Wordpress函数可以删除重音(string$string) 但如何将其应用于内容

我需要添加一个wp管理员提交后验证,以防止其错误。
请帮帮我

像这样使用内容过滤器

function my_the_content_filter($content) {
  remove_accents( $content );
  return $content;
}

add_filter( 'the_content', 'my_the_content_filter' );

Hi@RST此操作不起作用,因为$content是数组,remove\u重音(string$string)将与字符串一起使用。我也试过,但有点不对劲,不幸的是没有更新帖子。。函数filter_accents($post_ID,$data){$post_title=$data->post_title;$filtered_title=删除_accents($post_title);$data->post_title=$filtered_title;return$data;}add_操作('wp_insert_post','filter_accents',1,2);我怀疑此筛选器中使用的默认$content是数组,但如果是数组,则应该能够在
foreach
循环中执行remove_accents()函数。它会起作用的。提供一个如何解决问题的描述,而不是转储代码,这将是很有帮助的。
function filter_handler($data , $postarr) {
  $data_title=$data['post_title'];
  $filtered_title = remove_accents( $data_title );
  $data['post_title']=$filtered_title;
  return $data;
}
add_filter( 'wp_insert_post_data', 'filter_handler', '99', 2 );