[wp-hackers] exporting a file in wp admin

Steve Taylor steve at sltaylor.co.uk
Tue May 25 14:50:57 UTC 2010


This works perfectly, thanks! So obvious really, I should have figured it out...

Steve


On 23 May 2010 16:22, Shinji Hiranaka <shinji.hiranaka at pangaea.tw> wrote:
> Hi Steve,
>
> How about code like below.
>
> ---start---
>
> add_action( 'init', 'before_submit_header' );
>
> function before_submit_header() {
>  if( $_POST['submit'] === 'spreadsheet_download' ) {
>   header( 'Content-Description: File Transfer' );
>   header( 'Content-Type: application/vnd.ms-excel' );
>   header( 'Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT' );
>   header( 'Content-disposition: attachment; filename=download-logs.xls' );
>   header( 'Pragma: no-cache' );
>   echo $spreadsheet;
>   die();
>  }
> }
>
> ---end---


More information about the wp-hackers mailing list