I’m developing WordPress plugins. When I activate my plugin, I’m getting the following message:
The plugin generated 293 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 plugin is working very well but I don’t know why I’m getting this message. My plugin is : http://wordpress.org/extend/plugins/facebook-send-like-button/
My guess is you get a PHP error, which generates output before the headers are sent. If you have
E_NOTICE
enabled, calling$_POST['foo']
may generate a “Notice: undefined variable” error if that variable is not set.Best practice: never assume anything about GET, POST, COOKIE and REQUEST variables. Always check first using
isset()
orempty()
.This is typically caused by spaces or new lines before the opening
<?php
tag or after the closing?>
tag.Check out this page to see some solutions: How do I solve the Headers already sent warning problem?
UPDATE
After examining your plugin code, the one thing I noticed is that you don’t have a closing PHP tag. On the last line, add
?>
In the beginning of your activation function put a
ob_start();
and at the end put atrigger_error(ob_get_contents(),E_USER_ERROR);
Then try activating your plugin, and you can then see what the ‘generated 293 characters of unexpected output‘ really are. From then on debugging this will be easier (either remove new line characters or resolve some errors).
I have faced the same problem before, for me it was extra white space. After I removed all those white spaces the plugin could activate without any error/warning.
I know this is an old question and it does have an accepted answer. There are a lot of answers that cover what the activation issue could potentially be. However, none of the answers really get at the core issue of HOW to debug issues with plugin activation.
If you’re going to develop WP plugins, you may as well use the correct tools for the job. One of those is the Debug Bar. This is a plugin that helps you debug issues in WP. If you are a plugin developer, it should be in your toolbox.
The Debug Bar has a number of add-ons – plugins for the plugin, if you will. One of those is Debug Bar Plugin Activation, which will show you the PHP error generated when the plugin activates. Once you know what the PHP error is that causes the headers to be sent, then you know where you need to look to correct it. Trust me, knowing what the error is can save you a ton of time instead of trying to figure out what the error could be.
I’m not positive this is the problem, but I’m pretty sure of it.
You need to use a valid callback as the second argument in
register_activation_hook()
:As far as I can tell, you haven’t defined
twl_tablo_olustur()
anywhere. This would certainly explain the unexpected output (PHP error generated from trying to call a non-existent function), and would explain why it works fine in all other circumstances.I tend to get these messages a lot when I’m outputting plugin / theme debug messages, especially when I’m outputting stuff before wp_header gets called.
If you’re outputting any characters, then I believe (could be wrong here) that there’s an implicit header declaration, so when the normal header() call occurs, you get the error as you can’t have 2 header declarations.
You can use ob_start() to buffer the output, which should remove the error – have a look at the comments here: http://php.net/manual/en/function.header.php
Looking at the last revision of the plugin (381724) the problem is Too many spaces
every time you want to create this structure:
in your code use TAB and not spaces.
Here is you code where i replaced all spaces with tabs and i do not get any messages at activation:
You remove the php close tag ( ?> ) from end of every file. and also remove all blank space after php close tag ( ?> )
when you activate the plugin just check if table already exist or not .
i removed the issue by the code
My issue was that the file was saved as a UTF-8 file. Saving it with Codepage 1252 resolved the error.