-
-
Save boonebgorges/83ad69a81052c5ce43001d7c7523a586 to your computer and use it in GitHub Desktop.
redirect logger
This file contains 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 | |
add_filter( | |
'wp_redirect', | |
function( $location ) { | |
$log_entry = sprintf( | |
"[%s] - Redirect URI: %s\nStack Trace: %s\n\n", | |
date( 'Y-m-d H:i:s' ), | |
$location, | |
wp_debug_backtrace_summary() | |
); | |
$upload_dir = wp_upload_dir(); | |
$log_path = $upload_dir['basedir'] . '/redirect-log.txt'; | |
error_log( $log_entry, 3, $log_path ); | |
return $location; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment