Run script on page/image load?
-
Hello. I am not exactly sure if this is the place to write my question, but i’m in the midst of doing a website rebuild, with admittedly limited knowledge, and lots of peculiar requirements.
As of now, we have a rather complex system where our main theme integrates a lot of functions and handles a lot of the operation. The codebase is unmaintainable, it was last updated many years ago, and breaks with PHP 8, which means it is time to start from scratch.
One of the functions the theme seems to handle, is a script that generates watermarks on-the-fly as soon as any given user loads the page or relevant image. The file itself seems to handle everything once given a certain URL. This means that if the user is logged in, and gets the full URL to an image, a version is made specifically for them. This version seems to also be created if they just access the post containing the image. Attempts at reverse engineering the theme to search for calls to the specific file have been futile as there are no include or require clauses explicitly calling the file. So with that ouf of the question, i feel a different approach is needed. Namely, salvage the file that contains the logic and find a way to strap it somewhere anytime an user requests a post or image URL.
Does WordPress provide a way for a plugin to run a file at all times for non-admin users that visit any post/image of the website? Alternatively, what is the most appropiate way to call a script on page load for such users? The file containing the main logic seems standalone, so it’s a matter of calling it so it can get the parameters it requests for ( or latch into WP to fetch the contents directly without them being passed to it )
- The topic ‘Run script on page/image load?’ is closed to new replies.