启用插件时,有时会出现错误提示,“The plugin generated xxxx characters of unexpected output during activation”,中文提示为“这个插件在启用的过程中产生了 XXXX 个字符的异常输出。如果您遇到了“headers already sent”错误、联合 feed(如 RSS)出错等问题,请尝试禁用或移除本插件”。如何才能查看具体的错误是什么呢?
解决方法
在这里找到了解决方法,你可以打开插件的主文件,添加下面的代码
add_action('activated_plugin','save_error');
function save_error(){
update_option('plugin_error', ob_get_contents());
}
echo get_option('plugin_error'); |
add_action('activated_plugin','save_error');
function save_error(){
update_option('plugin_error', ob_get_contents());
}
echo get_option('plugin_error');
这段代码将错误信息保存到wp-options表中,option_name是“plugin_error”,要获取这个字段的值只需要调用
get_option('plugin_error'); |
get_option('plugin_error');
这样,启用插件时,除了会显示WordPress默认的那段信息,还会在顶部显示错误。
用update_option()存储字段,是一种添加操作,每产生一条新错误,都会添加到这个字段中,所以最后一条才是最近的错误信息,有点类似错误日志。
如果不想产生数据库操作,还可以将错误信息直接写进一个临时文件中。
add_action('activated_plugin','save_error');
function save_error(){
file_put_contents ( 'C:/text.txt' , ob_get_contents() );
} |
add_action('activated_plugin','save_error');
function save_error(){
file_put_contents ( 'C:/text.txt' , ob_get_contents() );
}
原文出处:http://www.solagirl.net/the-plugin-generated-xxxx-characters-of-unexpected-output-during-activation.html
来源:
https://www.wpdaxue.com/plugin-unexpected-output.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33756.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57