WordPress.org

Make WordPress Core

Ticket #3632: gzip-export.diff

File gzip-export.diff, 1.9 KB (added by DerFichtl, 6 years ago)

gzip export feature

  • wp-admin/export.php

     
    55$parent_file = 'edit.php'; 
    66 
    77if ( isset( $_GET['download'] ) ) {      
    8         export_wp( $_GET['author'] ); 
     8        export_wp( $_GET['author'], $_GET['compress'] ); 
    99        die(); 
    1010} 
    1111 
     
    3737</select> 
    3838</td> 
    3939</tr> 
     40<tr> 
     41        <th><?php _e('Compress:'); ?></th> 
     42        <td> 
     43                <input type="checkbox" name="compress" value="1" /> <?php _e('as gzip'); ?> 
     44        </td> 
     45</tr> 
    4046</table> 
    4147<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" /> 
    4248<input type="hidden" name="download" value="true" /> 
  • wp-admin/includes/export.php

     
    33// version number for the export format.  bump this when something changes that might affect compatibility. 
    44define('WXR_VERSION', '1.0'); 
    55 
    6 function export_wp($author='') { 
     6function export_wp($author='', $compress = false) { 
    77global $wpdb, $post_ids, $post; 
    88 
    99do_action('export_wp'); 
    1010 
     11 
     12 
     13function ob_gzhandler_export($buffer, $mode) { 
     14    return gzencode($buffer, $mode); 
     15} 
     16 
    1117$filename = 'wordpress.' . date('Y-m-d') . '.xml'; 
     18if ($compress) { 
     19        $filename .= '.gz'; 
     20        header('Content-Type: application/x-gzip; charset=' . get_option('blog_charset'), true); 
     21        ob_start('ob_gzhandler_export'); 
     22} else { 
     23        header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); 
     24} 
    1225 
    1326header('Content-Description: File Transfer'); 
    1427header("Content-Disposition: attachment; filename=$filename"); 
    15 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); 
    1628 
     29 
     30 
     31 
     32 
     33 
    1734$where = ''; 
    1835if ( $author and $author != 'all' ) { 
    1936        $author_id = (int) $author;