I’m working on a plugin and having some difficulties getting a new table created. I get the “The plugin generated x characters of unexpected output during activation” error. Is there a way of viewing the actual error? I believe that a redirect is involved in this process, hence the reason I don’t see the actual error output. I have all error reporting and logging on, but still I get nothing.
Leave a Reply
You must be logged in to post a comment.
Interestingly the ability to display errors and output from a plugin on activation seems to be build in to WordPress. If you take a look at
wp-admin/plugins.php
there’s a case in the$action
switch statement that sayserror_scrape
— hinted at in Lars’ answer.Looks like this:
As you can see, it mimics the plugin activation senario, but it doesn’t actually activate the plugin. It includes the plugin file, calls the activate hook, then exits. It does all this without output buffering so you can see what’s happening.
SO, if that’s already there, we just need to expose it. A bit of digging in
wp-admin/plugins.php
shows we need a nonce to verify. So we can copy that and study how the plugins list table builds its activation links. Then simply add an error scrape link on the inactive plugins. Click it, and see your errors.Just hook into
plugin_action_links
and add the link:Here is the above wrapped up in a plugin.
Interesting question, so I had a look on Google and some guy named Jason had a solution:
From http://www.squarepenguin.com/wordpress/?p=6 that has more details as well.
I just found a way, all props to itzco and hungrycoder. I’ve added the hook parameters.