2

I'm about to go crazy :/

<?php
/*
Plugin Name: TEST Plugin
Description: test desc
Author: test
Author URI: test
Plugin URI: test
*/
echo"test";
?>

Error : The plugin generated 4 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

random_user_name
  • 25,694
  • 7
  • 76
  • 115
  • Possible duplicate of [The plugin generated X characters of unexpected output during activation (WordPress)](https://stackoverflow.com/questions/4074477/the-plugin-generated-x-characters-of-unexpected-output-during-activation-wordpr) – T.Todua Dec 24 '18 at 00:06

2 Answers2

2

remove unnecessary white space or line break that will remove the error also remove last

?>

Try bellow code

<?php
/*
    Plugin Name: TEST Plugin
    Description: test desc
    Author: test
    Author URI: test
    Plugin URI: test
*/
ob_start();
echo 'test';
ob_clean();
Shafi
  • 91
  • 8
1

Your plugin cannot simply echo "test" in the file. That is what is generating the unexpected output.

Remove that.

All output that a plugin generates should be inside of functions, which typically get called by using one of the many WordPress Hooks.

Here's a super-simple, (and useless) example:

<?php
/*
Plugin Name: TEST Plugin
Description: test desc
Author: test
Author URI: test
Plugin URI: test
*/

// Hooks into the WordPress wp_head action
add_action('wp_head', 'my_wp_head_function');

// Runs when the WordPress init action runs
function my_wp_head_function() {
    echo "test";
}

// ... etc

// Also - DO omit the closing PHP tag.  That is now considered best practice
random_user_name
  • 25,694
  • 7
  • 76
  • 115