WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] New Plugin Screws Up Header - Please Help. (2 posts)

  1. Joe Hall
    Member
    Posted 5 years ago #

    Hello all,
    As some of you may know. I am currently working on my first plugin! I am having a great time doing it, however, I keep getting errors when I activate. The errors are found in the admin section of WordPress. All of the errors follow the format below. My plugin modifies the header on the blog to include some custom JavaScript. It appears that the plugin is also trying to modify the headers in the admin section. Can anyone tell me how to get it not to attempt to modify admin headers?

    My warnings and code are below.

    WARNINGS:

    Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/laughingduck/wp-content/plugins/MyPlugin/MyPlugin.php:52) in /home/user/public_html/laughingduck/wp-login.php on line 202
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/laughingduck/wp-content/plugins/MyPlugin/MyPlugin.php:52) in /home/user/public_html/laughingduck/wp-login.php on line 214
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/laughingduck/wp-content/plugins/MyPlugin/MyPlugin.php:52) in /home/user/public_html/laughingduck/wp-includes/pluggable.php on line 557
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/laughingduck/wp-content/plugins/MyPlugin/MyPlugin.php:52) in /home/user/public_html/laughingduck/wp-includes/pluggable.php on line 694

    CODE:

    <php?
    
    function addHeaderCode() {
        ?>
    
    <script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/MyPlugin/js/MyPluginJS.js"></script>
    
       <?php
    }
    
    add_action('wp_head', 'addHeaderCode');
    
    ?>

    PS: above code is complete with out plugin header info.

  2. Joe Hall
    Member
    Posted 5 years ago #

    Issue resolved! Apparently there was a line break some where in the code!

Topic Closed

This topic has been closed to new replies.

About this Topic