• I have recently installed WordPress v. 2.9.1.

    Then I decided to create a plug-in myself,
    to handle a top navigation and some pages.

    At first hand sight it looked like working, but
    then I tried to update one of my pages
    (the original wordpress page) and I recievede
    following errormessage:

    Warning: Cannot modify header information - headers already sent by (output started at /domains/www.xxx.xx/wp-content/plugins/topmenu/topmenu.php:1) in /domains/www.xxx.xx/wp-includes/pluggable.php on line 868

    I have tried searching the web for any solutions but they all referred to the wordpress-topic which says that you have to be sure no extra spaces are included. I therefore opened the pages told in a text-editor
    but no help it was.

    I have tried to install another plug-in to see if it was my own code that provoked the error, but anyway it still gave me that ugly error.

    Can anyone help me to fix this error?
    or shall I program a menu beside wordpress?

    Kind Regards
    Michael Thulin

Viewing 9 replies - 1 through 9 (of 9 total)
  • Looks like you have some non-php text (maybe a blank line, or a space at the start of the line) as the first line of topmenu.php. The first line must start with <?php.

    Thread Starter michaelthulin

    (@michaelthulin)

    I am aware of that.

    But as I said – even when I copy one of the other existing plugins,
    the problem is still there.

    I’m sorry, I don’t understand what you mean by ‘copy one of the other plugins’. Did you mean copying a different plugin and naming it topmenu.php, or deleting topmenu.php and using a plugin with a different name?

    How about pasting the first 5 lines of topmenu.php in a reply? May not help, but won’t hurt either.

    Thread Starter michaelthulin

    (@michaelthulin)

    <?php
    /*
    Plugin Name: test
    Plugin URI: http://xxx.xx
    Description: Test description
    Version: 1.0
    Author: Michael Thulin
    Author URI: http://xxx.xx
    */
    if (!class_exists("testclass")) {
        class testclass {
            function testfunction() {
    			function addHeaderCode() {
                ?>
    <!-- thulin Was Here -->
                <?php
    
    			}
            }
        }
    }
    
    if (class_exists("testclass")) {
        $dl_pluginSeries = new testclass();
    }
    
    if (isset($dl_pluginSeries)) {
        add_action('wp_head', array(&$dl_pluginSeries, 'addHeaderCode'), 1);
    }
    ?>

    OK, just to clarify, when you installed another plugin and it still gave you an error, did it still say topmenu.php in the error message?

    I copied your code into my plugins directory and I don’t get the ‘headers sent’ error. I do get this:

    Warning:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'testclass::addHeaderCode' was given in /usr/local/apache/htdocs/wordpress/ysmagazine/wp-includes/plugin.php on line 339

    addHeaderCode is nested inside testfunction so it isn’t being found.

    The original error states that the headers were sent by topmenu.php. That’s were I’d look for the problem.

    The key is right here in the message..

    output started at /domains/www.xxx.xx/wp-content/plugins/topmenu

    “Output” ie. something has been output, before the headers were sent.. (you cant output before sending headers).

    Disable or fix whichever plugin that is..

    Thread Starter michaelthulin

    (@michaelthulin)

    was trying out some code for a plug-in tutorial.
    I have tried to copy Akismet into the topmenu.php and I still get the same error therefore I thought that it actually was a problem.

    But even tho I installed a plugin with following comment:

    /*
    Plugin Name: test
    Plugin URI: http://xxx.xx
    Description: Test description
    Version: 1.0
    Author: Michael Thulin
    Author URI: http://xxx.xx
    */

    (nothing more)

    and the same error still appeared – why’s that?

    Hi,

    It is usually due to spaces, new lines, or other garbage at opening/closing PHP file <?php tag or after a closing ?> tag in wp-config.php. It can be other file too so need to check error message as it may list file name where the error occurred.

    One can either upload error file from the backup or edit erroneous file. To edit the file one need to check below mentioned points:

    1. Download the file mentioned in the error message.
    2. Open that file in a plain text editor
    3. Check that the very first characters are <?php
    4. Check that the very last characters are ?>
    5. Place the cursor between the ? and >
    6. Now press the DELETE key on your computer and keep that key pressed for at least 15 seconds.
    7. Now type > and
    8. Save without pressing any other key at all.

    That’s it!

    Thanks,

    Shane G.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Cannot modify header information’ is closed to new replies.