【发布时间】:2017-11-11 20:35:57
【问题描述】:
我在这里尝试了许多已回答的问题...
比如删除<?php之前和?>之后的空格
根本不工作 我还是卡住了..
下面是我的代码..
add_action( 'admin_notices', 'fii' );
function fii(){
// parent plugin
if ( ! is_plugin_active( 'xxx/aaa.php' ) and current_user_can( 'activate_plugins' ) ) {
echo '<div class="notice notice-warning"><p>You need install xxxx plugin</p></div>';
}
}
register_activation_hook( __FILE__, 'fii' );
问题是当激活我的插件时,wordpress 会给我这样的错误信息..
“插件在激活期间生成了 281 个字符的意外输出。如果您发现“标头已发送”消息、联合提要问题或其他问题,请尝试停用或删除此插件。”
但是当我在 fii 函数中关闭我的 echo 时,它很好”
add_action( 'admin_notices', 'fii' );
function fii(){
// parent plugin
if ( ! is_plugin_active( 'xxx/aaa.php' ) and current_user_can( 'activate_plugins' ) ) {
//echo '<div class="notice notice-warning"><p>You need install xxxx plugin</p></div>';
}
}
register_activation_hook( __FILE__, 'fii');
我的回声有什么问题??
【问题讨论】:
-
你的问题一定出在别处,代码有效,而且你的回显不是281个字符。
-
你为什么要将 fii 分配给 admin_notices 以及激活钩子?