Capture error messages on plugin activation
During the test & development of Frontier Post i have several times seen the message:
The plugin generated ??? 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.
Problem is to catch the unexpected output – I created a small private plugin to write it to a logfile in the uploads directory:
<?php
/*
Plugin Name: Frontier capture activation output
Plugin URI: http://wpfrontier.com/
Description: Captures unexpected output from plugin activation
Author: finnj
Version: 1.0.0
Author URI: http://www.wpfrontier.com
*/
// Capture plugin activatio error messages
add_action('activated_plugin','fpt_save_error');
function fpt_save_error($tmp_plugin)
{
$out_txt = PHP_EOL.date("Y/m/d H:i").' Plugin activation: '.$tmp_plugin.' ---messages--->'.PHP_EOL;
$out_txt .= ob_get_contents();
$out_txt .= PHP_EOL.'<---- end plugin activation ---'.PHP_EOL;
file_put_contents(ABSPATH. 'wp-content/uploads/plugin_activation.log', $out_txt, FILE_APPEND);
}
?>
You can copy the code, and save it as your own plugin, or add the code to your functions.php in your child theme.
Comments
Capture error messages on plugin activation — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>