I've written a quick little plugin to grab some custom query_vars, do some manipulation, and store the output in a CSV file. It works great for pages and posts, but ... it seems that queries to wp-content/uploads don't actually go through WordPress, and I want to grab those, too.
I'm thinking of two different approaches:
per the answer to this question, maybe write a custom rewrite rule, and pass the request into WordPress iff it's a query for wp-content/uploads and there exists a query string; or,
write a standalone PHP program that processes the request from a custom rewrite rule, without worrying about spinning up WordPress.
The problem with (1) is that ... the Internet is a wild and whacky place. While I imagine there will be far fewer requests for wp-content/upload content without query strings than with, it still could end up being a ton of extra load on the server, depending on what happens out there in the wild.
The problem with (2) is, I have to either figure out how to figure out wp_upload_dir
and plugin_dir_path
without spinning up wordpress, or I have to stick everything outside of the wordpress hierarchy.
At the moment, I can do the latter, as this is just a quick little hack for one of my sites, but ... it feels so wrong. Is there a better way to do this?