2

I'm developing WordPress plugin and do get this error on activation:

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.

The snippet below illustrates how my plugin looks like:

<?php
/*
Plugin Name: XXXXX
Plugin URI: XXXXX
Description: XXXXX
Version: 1.0
Author: XXXXX
Author URI: XXXXX
License: GNU
*/

echo"test";
?>

What is causing this error and how can I resolve it?

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
  • have you give plugin name same as a file name or folder name ? use following link for create plugin https://codex.wordpress.org/Writing_a_Plugin – Samir Sheikh Apr 08 '16 at 12:15
  • Possible duplicate of [x characters generated by WordPress plugin during activation](https://stackoverflow.com/questions/4074477/x-characters-generated-by-wordpress-plugin-during-activation) – T.Todua Dec 24 '18 at 00:01

1 Answers1

1

A couple of issues:

  1. Your plugin shouldn't directly echo anything. Instead, add your echo to a WordPress hook if you need to test things. For example, replace your echo "test"; with something like:

    add_action( 'init', function() { echo 'test'; });
    
  2. It's recommended to remove the closing ?> tag, to avoid "Headers already sent" notifications.

rnevius
  • 26,578
  • 10
  • 58
  • 86