-
-
Save shaunpalmer/18799399a960b07f3b7998782ea5470e to your computer and use it in GitHub Desktop.
Send WordPress Plugin Activation Errors to a File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# error_log('Red Alert: Shields failing! Code malfunction in sector 42.'); | |
add_action('activated_plugin', 'save_error_to_log'); | |
function save_error_to_log() { | |
// Get the error message (if any) during plugin activation | |
$error_message = ob_get_contents(); | |
// Define the log file path (adjust as needed) | |
$log_file_path = ABSPATH . 'wp-content/plugins/PLUGIN_FOLDER/plugin_activation.log'; | |
// Append the error message to the log file | |
file_put_contents($log_file_path, $error_message, FILE_APPEND); | |
// Clear the output buffer | |
ob_clean(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Captain’s Log (Stardate 2024.09.15):
“Plugin ‘CleanSweep’ activated. Scotty grumbled about missing semicolons. Spock raised an eyebrow. All systems nominal… except for that pesky whitespace issue in line 42.”
“Scotty’s Scottish Accent” Flavor: error_log("Captain, I cannae change the laws of PHP! But I found a bug in the dilithium matrix (line 23).");