Skip to content

Instantly share code, notes, and snippets.

@sblomberg
Created July 27, 2016 18:12
Show Gist options
  • Save sblomberg/8339a09e9da14d837d691057554eec5c to your computer and use it in GitHub Desktop.
Save sblomberg/8339a09e9da14d837d691057554eec5c to your computer and use it in GitHub Desktop.
Log plugin activation errors to a file
<?php
// Add this to the bottom of wp-config.php to log plugin activation errors:
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 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment