WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing Wordpress plugins. When i activate my plugin, i'm getting a 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.

Plugin 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/

share|improve this question
if debugging is enabled, you might get this if php outputted a warning. – Milo May 6 '11 at 13:46
Check if you left any white space after php close tags at the end of your plugin php files. – Sisir Dec 26 '11 at 9:16
up vote 5 down vote accepted

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
share|improve this answer

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?


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

share|improve this answer
PHP files do not need the closing ?> tag. In fact, one way to guarantee that it won't cause Headers already sent issues is to leave the closing tag out. – John P Bloch May 6 '11 at 15:03
This was my issue. I had a bunch of blank lines after my closing ?>. – Cam Jackson Aug 29 '11 at 4:18

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.

share|improve this answer

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).

share|improve this answer

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

share|improve this answer

Looking at the last revision of the plugin (381724) the problem is Too many spaces

every time you want to create this structure:

function blabla(){
   <= space

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:

Plugin Name: Facebook Send Button By Teknoblogo.com
Plugin URI: http://www.teknoblogo.com/facebook-gonder-butonu-eklenti
Description: Adds Facebook's Send and Like buttons to your posts ! Author : <a href="http://www.teknoblogo.com">teknoblogo.com</a>
Version: 1.3
Author: Eray Alakese
Author URI: http://www.teknoblogo.com
License: GPL2

wp_register_script('fgb_script', "http://connect.facebook.net/en_US/all.js#xfbml=1");

function fgb_ayarlari_yap()
    add_option('fgb_yer', 'u');
    add_option('fgb_buton', 'snl');
    add_option('fgb_manual', 'hayir');
register_activation_hook( __FILE__, 'fgb_ayarlari_yap' );
function fgb_ayarlari_sil()
register_deactivation_hook( __FILE__, 'fgb_ayarlari_sil' );

function fgb_ekle($content)
    $fgb_yer = get_option('fgb_yer'); 
    $fgb_buton_opt = get_option('fgb_buton'); 
    $fgb_manual = get_option('fgb_manual');
    $fgb_perma  = rawurlencode(get_permalink());
    $fgb_send_button = "<fb:send href=\"$fgb_perma\" font=\"\"></fb:send>";
    $fgb_like_button = "<fb:like href=\"$fgb_perma\" send=\"false\" width=\"450\" show_faces=\"true\" font=\"\"></fb:like>";
    $fgb_snl_button = "<fb:like href=\"$fgb_perma\" send=\"true\" width=\"450\" show_faces=\"true\" font=\"\"></fb:like>";
    if($fgb_buton_opt == "send")
        $fgb_buton = $fgb_send_button;
    elseif($fgb_buton_opt == "like")
        $fgb_buton = $fgb_like_button;
    elseif($fgb_buton_opt == "snl")
        $fgb_buton = $fgb_snl_button;
        echo "Buton türü alınamadı!";

    if ($fgb_manual=="hayir"){
        if ($fgb_yer == "u")
            $content = $fgb_buton."<br />".$content;
        elseif ($fgb_yer == "a")
            $content = $content."<br />".$fgb_buton;
        return $content;
        echo $fgb_buton;
if (get_option('fgb_manual')=="hayir"){ add_filter( "the_content", "fgb_ekle" ); }

add_action('admin_menu', 'fgb_admin_menu');
function fgb_admin_menu() {
    add_options_page('Facebook Send Button', 'Facebook Send Button', 'manage_options', 'fgb', 'fgb_admin_options');
function fgb_admin_options() {
    if (!current_user_can('manage_options'))  {
        wp_die( __('You do not have sufficient permissions to access this page.') );
    echo '<div class="wrap">';
    <h2>Facebook Send & Like Button</h2>
      echo "<h3>saved</h3>";
      update_option('fgb_yer', $_POST["fgb_yer"]);
      update_option('fgb_buton', $_POST["fgb_buton"]);    
      update_option('fgb_manual', $_POST["fgb_manual"]);

        $fgb_admin_yer = get_option('fgb_yer');
        $fgb_admin_buton = get_option('fgb_buton');
        $fgb_admin_manual = get_option('fgb_manual');
    <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="POST">
    Show Facebook buttons <select name="fgb_yer">
        <option value="u" <?php if($fgb_admin_yer == "u"){echo "SELECTED";}?>>before content</option>
        <option value="a" <?php if($fgb_admin_yer == "a"){echo "SELECTED";}?>>after content</option>
    </select> and i want <select name="fgb_buton">
        <option value="snl" <?php if($fgb_admin_buton=="snl"){echo "SELECTED";}?>>send and like buttons together</option>
        <option value="send" <?php if($fgb_admin_buton=="send"){echo "SELECTED";}?>>just send button</option>
        <option value="like" <?php if($fgb_admin_buton=="like"){echo "SELECTED";}?>>just like button</option>
    </select> . <br />
    <input type="radio" value="hayir" name="fgb_manual" <?php if($fgb_admin_manual=="hayir"){echo "CHECKED";}?> /> put buttons for me, AUTOMATICALLY <br />
    <input type="radio" value="evet" name="fgb_manual" <?php if($fgb_admin_manual=="evet"){echo "CHECKED";}?> /> i can put them, MANUALLY <br />

    <input type="submit" class="button-primary" name="fgb_gonder" value="<?php _e('Save Changes') ?>" />
    <br />If you use <strong>manuel insertion</strong> , you have to add this code to your theme : 
    <strong>&lt;?php if(function_exists('fgb_ekle')) {   fgb_ekle(); }?&gt;</strong>

    <hr />
    <em>If you like this plugin, please <a href="http://wordpress.org/extend/plugins/facebook-send-like-button/">vote</a> .
    Author : <a href="http://www.teknoblogo.com">Eray Alakese</a>
    You can <a href="mailto:info@teknoblogo.com">mail me</a> for bugs, thanks.</em>

    echo '</div>';
share|improve this answer
That shouldn't have anything to do with it. Spaces and tabs inside your functions is acceptable and does not produce this error. – Matthew Muro May 6 '11 at 14:04
inside a function you are correct but if the function outputs something directly eg: function blabla(){?> <input> <?php code... ?> output something <?php code.. } then that's not the case. – Bainternet May 6 '11 at 14:10
@MatthewMuro: if you leave the space inside a function its okey but if you leave any white space/line break after php closing tags ?> then you will get header already send error because those extra white spaces will prints out when php engine parse it. – Sisir Dec 26 '11 at 9:19

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.

share|improve this answer
thank you. But register_activation_hook(__FILE__,'twl_tablo_olustur'); this code from old version. In new version (you can check, v1.3) it's updated, but still same error. – Eray May 7 '11 at 8:41

My issue was that the file was saved as a UTF-8 file. Saving it with Codepage 1252 resolved the error.

share|improve this answer
Sorry, that’s wrong. Everything in WordPress is UTF-8 encoded, Windows-1252 will break the site the moment you use a non-ASCII character. – toscho Jun 5 '12 at 23:55

protected by Pieter Goosen Jan 13 at 10:25

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.