Skip to content

Instantly share code, notes, and snippets.

@ethangardner
Created September 6, 2016 14:55
Show Gist options
  • Save ethangardner/0580b3d801986effb042cb182d0d8ec8 to your computer and use it in GitHub Desktop.
Save ethangardner/0580b3d801986effb042cb182d0d8ec8 to your computer and use it in GitHub Desktop.
Captures activation errors for WP plugins
<?php
// https://www.toddlahman.com/the-plugin-generated-x-characters-of-unexpected-output-during-activation/
function plugin_activate_save_error() {
ob_clean();
update_option( 'plugin_error', ob_get_contents() );
}
add_action( 'activated_plugin', 'plugin_activate_save_error' );
/* Then to display the error message: */
echo get_option( 'plugin_error' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment