最近用火车头写了 采集规则,但是在发布到wordpress之后,发现插入时ed2k magnet torrent thunder等字符被自动过滤了,其实这是wordpress的自动保护体制。
具体代码在wp-includes目录内找到post.php,搜索以下内容:
$postarr = sanitize_post($postarr, 'db'); //这行注释掉,就可以了。
但是这样做整体后台就会失去保护了,下面我们提供另外一种方法,在脚本执行插入时添加代码如下:
kses_remove_filters(); //停止过滤字符
$post_ID = wp_insert_post( $my_post);//wordpress自带的插入功能
kses_init_filters();//重新开启过滤字符
注意:此处只要是安全性能的过滤,比如PHP的’单引号等字符。
这样就不会影响整体影响使用啦~







![Mysql innodb 系统表损坏带来的问题[Warning] InnoDB: Cannot open table XXX/wp_downloads from the internal data dictionary of InnoDB though the .frm file for the table exists. 终极解决办法](https://nrcs.xyz/wp-content/themes/begin/prune.php?src=https://nrcs.xyz/wp-content/uploads/2023/09/e4165-2023-09-28_102533.png&w=280&h=210&a=&zc=1)




评论