diff --git src/wp-admin/includes/export.php src/wp-admin/includes/export.php
index 397e9e7..24d24b2 100644
|
|
|
16 | 16 | define( 'WXR_VERSION', '1.2' ); |
17 | 17 | |
18 | 18 | /** |
| 19 | * Returns the export download filename. |
| 20 | */ |
| 21 | function get_export_filename() { |
| 22 | $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
| 23 | if ( ! empty($sitename) ) $sitename .= '.'; |
| 24 | $filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml'; |
| 25 | $filename = apply_filters( 'export_filename', $filename ); |
| 26 | return $filename; |
| 27 | } |
| 28 | |
| 29 | /** |
19 | 30 | * Generates the WXR export file for download |
20 | 31 | * |
21 | 32 | * @since 2.1.0 |
… |
… |
function export_wp( $args = array() ) { |
39 | 50 | */ |
40 | 51 | do_action( 'export_wp', $args ); |
41 | 52 | |
42 | | $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
43 | | if ( ! empty($sitename) ) $sitename .= '.'; |
44 | | $filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml'; |
| 53 | $filename = get_export_filename(); |
45 | 54 | |
46 | 55 | header( 'Content-Description: File Transfer' ); |
47 | 56 | header( 'Content-Disposition: attachment; filename=' . $filename ); |
diff --git tests/phpunit/tests/export.php tests/phpunit/tests/export.php
new file mode 100644
index 0000000..ed56214
-
|
+
|
|
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Test Export functions |
| 5 | * |
| 6 | * @group wpdb |
| 7 | */ |
| 8 | class Tests_Export extends WP_UnitTestCase { |
| 9 | |
| 10 | public function setUp() { |
| 11 | require_once( ABSPATH . '/wp-admin/includes/export.php' ); |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Always return test.xml |
| 16 | * @return string |
| 17 | */ |
| 18 | public function filename_filter( $filename ) { |
| 19 | return 'test.xml'; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Test that get_export_filename() will return the filtered filname. |
| 24 | */ |
| 25 | public function test_get_export_filename_returns_filtered_string() { |
| 26 | add_filter( 'export_filename', array( $this, 'filename_filter' ) ); |
| 27 | $this->assertEquals( get_export_filename(), 'test.xml' ); |
| 28 | remove_filter( 'export_filename', array( $this, 'filename_filter' ) ); |
| 29 | } |
| 30 | |
| 31 | } |