Ticket #3632: 3632.diff

File 3632.diff, 2.7 KB (added by solarissmoke, 2 years ago)
  • wp-admin/includes/export.php

     
    2626        global $wpdb, $post; 
    2727 
    2828        $defaults = array( 'content' => 'all', 'author' => false, 'category' => false, 
    29                 'start_date' => false, 'end_date' => false, 'status' => false, 
     29                'start_date' => false, 'end_date' => false, 'status' => false, 'gzip' => false 
    3030        ); 
    3131        $args = wp_parse_args( $args, $defaults ); 
    3232 
    3333        do_action( 'export_wp' ); 
    3434 
    3535        $sitename = sanitize_key( get_bloginfo( 'name' ) ); 
    36         if ( ! empty($sitename) ) $sitename .= '.'; 
     36        if ( ! empty($sitename) )  
     37                $sitename .= '.'; 
    3738        $filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml'; 
     39        if( $args['gzip'] ) 
     40                $filename .= '.gz'; 
    3841 
    3942        header( 'Content-Description: File Transfer' ); 
    4043        header( 'Content-Disposition: attachment; filename=' . $filename ); 
    41         header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); 
     44        $content_type = $args['gzip'] ? 'application/x-gzip' : 'text/xml'; 
     45        header( "Content-Type: $content_type; charset=" . get_option( 'blog_charset' ), true ); 
    4246 
    4347        if ( 'all' != $args['content'] && post_type_exists( $args['content'] ) ) { 
    4448                $ptype = get_post_type_object( $args['content'] ); 
     
    287291                        echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . "</category>\n"; 
    288292                } 
    289293        } 
     294         
     295        function export_gzip_handler( $buffer ) { 
     296                return gzencode( $buffer );  
     297        } 
     298         
     299        if( $args['gzip'] ) 
     300                ob_start( 'export_gzip_handler' ); 
    290301 
    291302        echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n"; 
    292303 
     
    413424</channel> 
    414425</rss> 
    415426<?php 
    416 } 
     427} 
     428 No newline at end of file 
  • wp-admin/export.php

     
    8383        } else { 
    8484                $args['content'] = $_GET['content']; 
    8585        } 
     86         
     87        if( isset( $_GET['gzip'] ) ) 
     88                $args['gzip'] = true; 
    8689 
    8790        export_wp( $args ); 
    8891        die(); 
     
    199202<p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p> 
    200203<?php endforeach; ?> 
    201204 
     205<h3><?php _e( 'Compression' ); ?></h3> 
     206<p><label><input type="checkbox" name="gzip" value="gzip" /> <?php _e( 'Compress the XML file using gzip compression (this will create a smaller file for download)' ); ?></label></p> 
     207 
    202208<?php submit_button( __('Download Export File'), 'secondary' ); ?> 
    203209</form> 
    204210</div> 
    205211 
    206 <?php include('admin-footer.php'); ?> 
     212<?php include('admin-footer.php'); ?> 
     213 No newline at end of file