Ideally what I’d like to do is hand a file to a function that returns the file as an attachment of the current post. Just as though it had been uploaded via the thickbox media uploader, but without the hassle of hijacking it’s ugly interface.
Is there a plugin/library/function I can use with my own plugins to achieve this?
You can do that programatically via
wp_insert_attachment()
function.Here is an example at WP Codex: http://codex.wordpress.org/Function_Reference/wp_insert_attachment