I’d like to have a my plugin hook a php function to a specific URL, so that when the URL is accessed (GET or POST), the function is called. I don’t particularly care what the URL is, just that it is a fixed value I can document.
One solution I have: “http://example.com/wp-content/plugins/myfunc.php” appears to work, and doesn’t need any setup other than putting myfunc.php into place, at least with my current setup. It feels wrong, though. It’s also called completely outside the WP system, which I don’t like much, since I’ll need to get into WP DB.
I’d also like to avoid anything that requires external configuration of the webserver, like mod_rewrite or URL aliases. The whole point is that the user be able to install the plugin and be done with it.
What’s my purpose? Silly, possibly. I’m writing a plugin to show what’s currently playing in my local MPD. I’d like to be able to run a script on the MPD server that POSTS to WP to update a database entry, which the WP widget/plugin can display. The plugin can’t access MPD directly (firewall, and I’m not particularly interested in exposing that port), and to make this generally useful, I’m trying to avoid hacks like FTP or SCP file transfers, etc.
- The topic ‘hook plugin function to specific URL’ is closed to new replies.