Wordpress - WordPress Plugin Development - Headers Already Sent Message

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 ?>


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() or empty().

if ( isset( $_POST['foo'] ) ) {
    $foo = (string) $_POST['foo'];
    // apply more sanitizations here if needed
}

In the beginning of your activation function put a ob_start(); and at the end put a trigger_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).