Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 705 Vote(s) - 3.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The plugin generated X characters of unexpected output during activation (WordPress)

#1
I'm getting this message each time I activate my plugin:

> The plugin generated 80 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 only way I was able to suppress the message was to wrap my activation function code within an *if* statement (please refer to snippets below).

Here, a snippet of my plugin code when I get the error described above:

function myPlugin( $post ) {
echo "Whatever is here throws an unexpected output alert when the plugin isa activated";
}
register_activation_hook( __FILE__, 'myPlugin' );

Following, my wrapping the function in my plugin within an *if* statement; it suppresses the previous error as discussed above:

function myPlugin( $post ) {
global $pagenow;
if ( is_admin() && $pagenow !== 'plugins.php' ) {
echo "No more alerts when its wrapped this way";
}
}
}
register_activation_hook( __FILE__, 'myPlugin' );

What actually cause that error and how can I effectively complete my plugin with my logics without having to encounter it?

Is there any better way to handle this?
Reply

#2
I think there may be two issues here that are causing the problem. First is that I don't think wordpress expects any output when the plugin activation hook is called so it may be complaining about that. Second is that plugin activation hooks are called fairly early in the wordpress program flow, so, it's probably being called before headers are sent. If ANY output is generated before calling `header()` then PHP usually complains.

Usually the plugin activation routine is reserved for basic setup of the plugin, calls to things like `set_option()` and the like.
Reply

#3
I had the same error - 3 characters of unexpected output and was lead here. For people in my scenario another cause of this message can be the file type being encoded as UTF with BOM.

BOM encoding was causing the error, and while the plug-in activated it would render incorrectly in internet explorer because of this.

The solution is to use Notepad++ and choose 'Convert to UTF without BOM', or if you are using visual studio, there is an explanation of how to change encoding

[To see links please register here]

Reply

#4
Had the same error, but only with 6 characters )
so... in my case I had empty lines after PHP closing tag ?> - that will cause this error too.
Reply

#5
check [here](

[To see links please register here]

) to see more info you can use:





<?php
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
If (is_plugin_active('wshops/init.php'))
{
//Run your plugin includes files or functions
}

in your init php file.
Reply

#6
I battled this problem for a long time. Typically this is caused by spaces or new lines before the opening `<?php` tag or after the closing `?>` tag. Once I removed these, the error went away.

Also, never assume anything about `GET`, `POST`, `COOKIE` and `REQUEST` variables. Always check first using `isset()` or `empty()`.
Reply

#7
sometime it is because you use `<?php ;?>` unnecessary or use it like shown below

;?>

<?php

this extra line between closing and starting tag may also cause this error, simple remove that line/space
Reply

#8
This problem can be solved by removing extra whitespaces. I solved this problem for my code. You can remove extra whitespaces easily in Adove Dreamweaver.

First, goto edit->Find and Replace. Or press Ctrl+F. Check "Use Regular Expression" button from "option" section.

Fill "find" field with the below code

[\r\n]{2,}

Fill "Replace" field with the below code

\n

Now click on "Replace All" button.
Hope It will work.
Reply

#9
i also got this problem when i activate my plugin

The plugin generated 1 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.

Typically this is caused by spaces or new lines before the opening <?php tag or after the closing ?> tag. Once I removed these, the error went away.

now my plugin error gone.
Reply

#10
I was having the same issue, i tried to remove the code and did everything but still the same problem

the real solution for me was the following.

1. at the end of the file which contains the header of the plugin i removed closing php ?> and the problem will be solved
2. at the end of the plugin file which contains the header of the plugin remove the extra line breaks after the closing php ?>


my plugin file ended at line 69 and there were 7 more spaced after the last php code so in the editor the file was up to 66, my error was "The plugin generated 7 characters of unexpected...." when i removed extra lines up to 69 the was error gone,

Thanks
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through