I am adding the below code for the email notification when my wordpress site fas fatal error or other. But I am not getting the email when I rename the load.php file(i.e when fatal error occurs)
do_action( 'shutdown', $array );
function action_shutdown($array) {
$err = error_get_last();
if ( !$err) {
return;
}
$fatals = array(
E_USER_ERROR => 'Fatal Error',
E_ERROR => 'Fatal Error',
E_PARSE => 'Parse Error',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning'
);
if (isset($fatals[$err['type']])) {
$msg = $fatals[$err['type']] . ': ' . $err['message'] . ' in ';
$msg.= $err['file'] . ' on line ' . $err['line'];
$headers = "From: [email protected]\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
error_log($msg, 1, "[email protected]", $headers);
}
}
add_action( 'shutdown', 'action_shutdown', 10, 1 );
I am adding this code in function.php file of theme. when error occurs on site it will not go inside the called function. but if running without error it is entering the called function. please tell me where i am wrong or using correct function.