I maintain a bunch of different WordPress sites, and I have noticed a wide variety of default filenames for the XML content export file (Tools-Export-all content). Some of them even use a PHP extension for the downloaded XML file.
How can I set or define the name of the export.xml file? Thanks!
I maintain a bunch of different WordPress sites, and I have noticed a wide variety of default filenames for the XML content export file (Tools-Export-all content). Some of them even use a PHP extension for the downloaded XML file.
How can I set or define the name of the export.xml file? Thanks!
Share Improve this question asked Oct 13, 2019 at 18:30 user3827186user3827186 11 Answer
Reset to default 1By default, the filename is defined in /wp-admin/includes/export.php
:
$sitename = sanitize_key( get_bloginfo( 'name' ) );
if ( ! empty( $sitename ) ) {
$sitename .= '.';
}
$date = gmdate( 'Y-m-d' );
$wp_filename = $sitename . 'WordPress.' . $date . '.xml';
And you can filter it:
$filename = apply_filters( 'export_wp_filename', $wp_filename, $sitename, $date );
So you could make a plugin and add a filter there:
add_filter(
'export_wp_filename',
function( $wp_filename, $sitename, $date )
{
// do something here, and then return a string
}, 10, 3
);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745084347a4610313.html
评论列表(0条)