I'm getting this message each time I activate my plugin:
The plugin generated 80 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
The only way I was able to suppress the message was to wrap my activation function code within an if statement (please refer to snippets below).
Here, a snippet of my plugin code when I get the error described above:
function myPlugin( $post ) {
echo "Whatever is here throws an unexpected output alert when the plugin isa activated";
}
register_activation_hook( __FILE__, 'myPlugin' );
Following, my wrapping the function in my plugin within an if statement; it suppresses the previous error as discussed above:
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' );
What actually cause that error and how can I effectively complete my plugin with my logics without having to encounter it?
Is there any better way to handle this?
I had the same problem. I noticed that there were new lines at the beginning of the file. So I removed them and the errors disappeared. Try removing the new lines at the beginning of your files. That may help.
Had the same error, but only with 6 characters ) so... in my case I had empty lines after PHP closing tag ?> - that will cause this error too.
i also got this problem when i activate my plugin
The plugin generated 1 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
Typically this is caused by spaces or new lines before the opening tag. Once I removed these, the error went away.
now my plugin error gone.