插件在激活过程中生成了意外输出的X字符(WordPress)每次我激活插件时都会收到这样的消息:该插件在激活过程中产生了80字符的意外输出。如果您注意到“已发送的标题”消息、联合提要的问题或其他问题,请尝试禁用或删除此插件。我能够抑制消息的唯一方法是将激活函数代码包装在如果语句(请参阅下面的片段)。在这里,当我得到上面描述的错误时,我的插件代码片段:function myPlugin( $post ) {
echo "Whatever is here throws an unexpected output alert when the plugin isa activated";}register_activation_hook( __FILE__, 'myPlugin' );下面,我在插件中将函数包装在如果语句;它取消前面讨论的错误:function myPlugin( $post ) {
global $pagenow;
if ( is_admin() && $pagenow !== 'plugins.php' ) {
echo "No more alerts when its wrapped this way";
}
}}register_activation_hook( __FILE__, 'myPlugin' );究竟是什么导致了这个错误,我如何才能有效地完成我的逻辑插件而不必遇到它呢?有什么更好的方法来处理这件事吗?
3 回答
![?](http://img1.sycdn.imooc.com/5458622b000117dd02200220-100-100.jpg)
不负相思意
TA贡献1777条经验 获得超10个赞
header()
set_option()
![?](http://img1.sycdn.imooc.com/545863aa00014aa802200220-100-100.jpg)
慕标琳琳
TA贡献1830条经验 获得超9个赞
- 3 回答
- 0 关注
- 573 浏览
添加回答
举报
0/150
提交
取消