Ticket #29500: 29500.1.diff
File 29500.1.diff, 1.8 KB (added by , 10 years ago) |
---|
-
tests/phpunit/tests/export/functions.export.php
41 41 throw new Exception( 'baba' ); 42 42 } 43 43 } 44 45 46 47 class Test_Export_Filter extends WP_UnitTestCase { 48 49 public function setUp() { 50 require_once( ABSPATH . '/wp-admin/includes/export.php' ); 51 } 52 53 /** 54 * Always return test.xml 55 * @return string 56 */ 57 public function filename_filter( $filename ) { 58 return 'test.xml'; 59 } 60 61 /** 62 * Test that get_export_filename() will return the filtered filname. 63 */ 64 public function test_get_export_filename_returns_filtered_string() { 65 add_filter( 'export_filename', array( $this, 'filename_filter' ) ); 66 $this->assertEquals( get_export_filename(), 'test.xml' ); 67 remove_filter( 'export_filename', array( $this, 'filename_filter' ) ); 68 } 69 } 70 No newline at end of file -
src/wp-admin/includes/export.php
40 40 do_action( 'export_wp', $args ); 41 41 42 42 $sitename = sanitize_key( get_bloginfo( 'name' ) ); 43 if ( ! empty( $sitename) ) $sitename .= '.';43 if ( ! empty( $sitename ) ) $sitename .= '.'; 44 44 $filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml'; 45 /** 46 * Filter the export filename. 47 * 48 * @since 4.1.0 49 * 50 * @param string $filename The name of the file to export data. 51 */ 52 $filename = apply_filters( 'export_filename', $filename ); 45 53 46 54 header( 'Content-Description: File Transfer' ); 47 55 header( 'Content-Disposition: attachment; filename=' . $filename );