Intercept request to /wp-content/uploads/random.file
I want to intercept requests to public files in WordPress, more specifically all requests to any file located in /wp-content/uploads
. Using request
or even init
filters didn't help, e.g.
add_action('init', function() {
$currentURI = $_SERVER['REQUEST_URI'];
if (strpos($currentURI, '-sab-v') !== false) {
return;
}
});
should catch the request to http://localhost:8080/wp-content/uploads/afghanistan-sab-v1-1-586f2f0eb1464db28d20848756de2671.zip
, but doesn't. The same if I use the request
filter instead. I know the code doesn't do anything, but breakpoints tell me it's not even triggered.
It does of course work for any other WordPress URL, I can successfully intercept all requests except for file downloads.
Anyone got any advice?