更新个站点,评论居然炸了..

此方法用来解决依赖Kartos主题站点评论报错的BUG

 

站点报错如下:

Fatal error: Uncaught ArgumentCountError: Too few arguments to function Walker_Comment::filter_comment_text(), 1 passed in /www/wwwroot/wordpress/wp-includes/class-wp-hook.php on line 287 and exactly 2 expected in /www/wwwroot/wordpress/wp-includes/class-walker-comment.php:267 Stack trace: #0 /www/wwwroot/wordpress/wp-includes/class-wp-hook.php(287): Walker_Comment->filter_comment_text('<p>\xE2\x80\x9D\xE5\x88\x9D\xE5\xA7\x8B\xE5\x8C\x96...') #1 /www/wwwroot/wordpress/wp-includes/plugin.php(212): WP_Hook->apply_filters('<p>\xE2\x80\x9D\xE5\x88\x9D\xE5\xA7\x8B\xE5\x8C\x96...', Array) #2 /www/wwwroot/wordpress/wp-content/themes/kratos-pjax/inc/ua.php(432): apply_filters('comment_text', '\xE2\x80\x9D\xE5\x88\x9D\xE5\xA7\x8B\xE5\x8C\x96\xE5\xA4\xB1...') #3 /www/wwwroot/wordpress/wp-content/themes/kratos-pjax/inc/ua.php(436): user_agent_display_comment() #4 /www/wwwroot/wordpress/wp-includes/class-wp-hook.php(289): user_agent('\xE2\x80\x9D\xE5\x88\x9D\xE5\xA7\x8B\xE5\x8C\x96\xE5\xA4\xB1...') #5 /www/wwwroot/wordpress/wp-includ in /www/wwwroot/wordpress/wp-includes/class-walker-comment.php on line 267

此报错主要为:/wordpress/wp-includes/class-walker-comment.php on line 267

解决办法如下:

找到/wordpress/wp-content/themes/kratos-pjax/inc/ua.php

上面我用的kratos-pjax主题,所以文件夹是这个,如果使用的其他大佬做的二开,请找到相应文件夹

进入ua.php后,找到第432行:

if(empty($_POST['comment_post_ID'])||is_admin()) echo apply_filters('comment_text',$comment->comment_content);
}

修改为

if(empty($_POST['comment_post_ID'])||is_admin()) echo apply_filters('get_comment_text',$comment->comment_content);
}

然后,将439行注释掉

//add_filter('comment_text','user_agent');

好了,保存结束。

点赞
  1. mm说道:

    只要有评论ui直接乱了

    1. 嫣折羽说道:

      嗯,这个BUG应该是wordpress站点更新所造成的,也不是什么大问题

      1. mm说道:

        好兄弟追番的源码可以发我一份吗

        1. 嫣折羽说道:

          找不到了。。很久之前弄得了

发表评论

电子邮件地址不会被公开。必填项已用 * 标注