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)

#11
A common way to assign the register_activation_hook is using a static method of a class. This ensures that your plugin activation function name won't collide with other plugins.

class Foo_Plugin
{
public static function plugin_activation() {
// activation logic
}
}
This function needs to be public and not private. A mistake is easily made though, so this could be a reason for your problems when getting this kind of error.

You would then register the activation with this code in the main plugin file.

register_activation_hook( __FILE__, array( 'Foo_Plugin', 'plugin_activation' ) );
Reply

#12
The error message `The plugin generated *X* characters of unexpected output during activation` is not very helpful or at least not quite enough.

To help locate the issue, add these to `wp-config.php`:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

Then check `wp-content/debug.log` for more detailed error messages as to the origin of the error.
Reply

#13
In my case it was due to Undefined index, Just enable the debug log to check whats causing it, then you can resolve it easily.

For those who don't know how to enable the Debug log, Add these lines in your wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', true );
define( 'WP_DEBUG_LOG', true );
You can see the errors properly in the debug file created in wp-content
Reply

#14
I had the same problem. I noticed that there were new lines at the beginning of the file. So I removed them and the errors disappeared. Try removing the new lines at the beginning of your files. That may help.
Reply

#15
My problem was that in the main php file, i had appended at the end of the file a javascript function. It seems that wordpress hooks such of a function in the head element. I externalised that function into a java script file.


Before:


<?php
/**
* Plugin Name: yyy
* Description: yyy
* Author: yyy
* Author URI: yyy
* Version: yyy
*/

/* many functions here */


function insert_in_header() {
echo '<script type="text/javascript">',
"perform_redirection(", '"', get_option('root'), '"', ", ", '"', get_option('redirect_to'), '");',
'</script>';
}
add_action('wp_head', 'insert_in_header');
?>
<--! PROBLEMS HERE-->
<script type = "text/javascript">
function perform_redirections(root, redirectionLink) {
// code here
}
</script>


After:


<?php
/**
* Plugin Name: yyy
* Description: yyy
* Author: yyy
* Author URI: yyy
* Version: yyy
*/

/* many functions here */

function insert_in_header() {
// in headscripts.js i put the perform_redirection function
echo '<script type="text/javascript" src="', plugins_url('js/headscripts.js', __FILE__ ), '"> </script>';
echo '<script type="text/javascript">',
"perform_redirection(", '"', get_option('root'), '"', ", ", '"', get_option('redirect_to'), '");',
'</script>';
}
add_action('wp_head', 'insert_in_header');
?>



Reply

#16
For me there was some kind of error which was being swallowed and not caught during debug

If ound this article here which explains how to determin what this `output` actually is

`$unexpectedOutput= ob_get_contents();`

now you have it, you can echo it or inspect it during debug to find out what the hells going wrong, for me it was a prolem with a database script.

[![enter image description here][1]][1]

Credit to the article below

[To see links please register here]



[1]:
Reply

#17
just make the function static which your are calling on activation hook
Reply

#18
For beginner level developer its must be empty line break after "?>" closing of php tags.
Try removing all empty line break after this.
Reply

#19
Opening the PHP file in Notepad and saving it with ANSI encoding did the trick for me. It did not cause the issue to happen again even when I opened and saved it later in Visual Studio Code.

Thanks to [Todd][1]


[1]:

[To see links please register here]

Reply

#20
After trying every answer and still coming short, I figured out my issue which was different to all answers here.

Basically, the unexpected characters were coming from my error log on the MAMP server. The errors weren't displaying on frontend or Wordpress installation error log, even with ```WP_DEBUG```, ```WP_DEBUG_DISPLAY``` and ```display_errors = On``` in the php.ini

I eventually knew it was an error causing the umm error, so I dug a bit deeper and found some errors in my ```php_error.log``` which is located in ```MAMP/logs/php/php_error.log```

Fixed the errors and the message from wordpress went away on activation.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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