DanRoller
Forum Replies Created
-
Forum: Hacks
In reply to: Is full control of http response possible?Solved. Thanks, I owe you another pint!
And I learned a bit in the process.Thanks again.
Forum: Hacks
In reply to: Is full control of http response possible?Here is the context.
This is a simple business application (converted from asp.net/sqlserver) in which multiple people in an organization create items, track activity, and upload documents in support of that activity. Image a standalone application that can be launched within wordpress.
Those uploaded documents are stored outside of the wordpress path and by clinking a link within the application, the document is retrieved. If it is a word doc/pdf/…, then the browser prompts you to open or save.
In addition, extracting tabular data from the application can be done by clicking a link that generates a tab-separated values output suitable for an application like Excel. Again the user is prompted for open or save.
In both of these situations, the plugin must tailor the http headers and the entire data stream so the user’s pc browser can ask about loading the right application. A wordpress theme is for a human to see in the browser, but this response is for an application such as MS Word.
All of this works (setting mime types etc), except that the data stream in my wordpress version, starts with whatever text the theme generates. I need absolutely no leading characters in that data stream.
You refer to having “Worst case, you could bypass the entire theme by requesting your own php page that does what you need. “. I don’t know how to do that in WordPress. In my case, it would need generate a zero length string. Please advise and I will give it a try.
Thanks
Forum: Hacks
In reply to: Is full control of http response possible?The http header problem was definitely solved but I was fooled thinking I was done.
My problem is that the entire contents of the wordpress the html stream is still written before my plugin’s output.
All of my ob_clean efforts didn’t solve that.And the pdf reader didn’t mind!
I have played with removing all menus, but there is so many other items.
I’m stuck here and would appreciate any help.
Forum: Hacks
In reply to: Is full control of http response possible?Thanks, with that it turned out to be easy!
My entry routine now has the following.
function xxx_httpheaders(){ if ( isset( $_GET['sc_menu'] ) && $_GET['sc_menu'] == 'ShowAttachment' ) { ob_end_clean(); header('Content-Description: File Transfer'); header('Content-Type: ' . $_GET['mimetype'] ); header('Content-Disposition: attachment; filename=' . $_GET['fname'] ); header('Content-Transfer-Encoding: binary'); header("Cache-control: private"); header('Pragma: private'); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); } } add_action( 'admin_init', 'xxx_httpheaders', 1 );and my ShowAttachment.php writes out the doc/txt/xls/… file.
Thanks again.