Robert Hickman
Forum Replies Created
-
Forum: Hacks
In reply to: Hook post all core and plugin updatesThanks, automatic_updates_complete looks like what I was looking for.
Calling to command line applications from PHP is not difficult, and I already use this for other things, like converting ABC music notation into images, the main problem was the hook.
I’m running on a VPS and have code in place for managing the git repositories, which has been doing it’s job fine for the past 5 years, in combination with SSH. For me it beats FTP as SSH is more secure, much faster when dealing with many files, and git provides a easy way to roll back if an update breaks something. As of right now, changing this work-flow would be a lot of work with no great benefit.
Forum: Hacks
In reply to: Image Download ButtomThinking about it there most probably is a plug-in in the word-press plug-in repo that already does this. Look for ‘file download’ or related terms.
If you don’t already, I’d recommend learning some PHP. You would need to create a custom plugin, which serves images from php from a url like /image?id=the_image_id. The above code tells the browser to download the file by setting it as an attachment.
You need to take care doing this as it can easily create a security hole. The application I took the code from will only serve a limited number of files defined in a database. Without care, a script like this could allow someone to download any file php has access to, like your wordpress config.
Forum: Hacks
In reply to: Image Download ButtomYou can use something like this in a plug-in, sets headers. Works for pdf anyway.
$path = "path to file"; if(!file_exists($path)) throw new exception("File does not exist"); header("Content-type: File MIME type"); header("Content-disposition: attachment; filename=\"Name of the file\""); header('Content-Transfer-Encoding: binary'); header("Content-length: " . filesize($path)); header('Expires: 0'); // check for IE only headers if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) { header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Pragma: no-cache'); } readfile($path);