Hey @madtownlems,
thanks for reaching out!
I was 99% sure there was a filter for that, but it turns out there isn’t one! π
Let me add one, and I’ll come back to you with an example that produces your desired filename structure!
Cheers,
Patrick
@madtownlems you can (with 3.5.1) change the filename of the ZIP file with the following filter:
add_filter( 'ss_zip_filename', function( $zip_filename, $archive_dir, $options ) {
// Get site name and turn it into a nice dash-separated label while preserving case
$site_name = get_bloginfo( 'name' );
if ( ! $site_name ) {
$site_name = 'Site';
}
// Replace whitespace/underscores with dashes
$site_name = preg_replace( '/[\s_]+/', '-', $site_name );
// Remove anything that isn't a letter, number, or dash
$site_name = preg_replace( '/[^A-Za-z0-9\-]/', '', $site_name );
// Collapse multiple dashes
$site_name = preg_replace( '/-+/', '-', $site_name );
// Trim leading/trailing dashes
$site_name = trim( $site_name, '-' );
// Multisite-aware blog/site ID (on single site this is typically 1)
$blog_id = function_exists( 'get_current_blog_id' ) ? (int) get_current_blog_id() : 1;
// Use WordPress timezone for date/time
$ts = current_time( 'timestamp' );
$date = date_i18n( 'Y-m-d', $ts );
// Build the filename
$zip_filename = sprintf(
'simply-static-%s-ID(%d)-%s-(%d).zip',
$site_name,
$blog_id,
$date,
$ts
);
return $zip_filename;
}, 10, 3 );
Heya – thanks!
I just tried this as written, and it made my “click here to download” link be ONLY “simply-static…. .zip” – no domain name or folder or anything π
As a result, I can’t actually find it was able to write the zip anywhere, or where.
I’m not sure if you’re intention was to have the filter edit only the FILE name, or the entire directory path (but I would have thought just the FILE name). I couldn’t find anywhere in the debug log that actually says where the zip is supposed to be saved.
@madtownlems my bad, there is a bug in how we construct the path in the previous code snippet – here is updated (working) one:
add_filter( 'ss_zip_filename', function( $zip_filename, $archive_dir, $options ) {
// Get site name
$site_name = get_bloginfo( 'name' );
if ( ! $site_name ) {
$site_name = 'Site';
}
// Transliterate accents and create a URL-safe slug with dashes
// This preserves ASCII letters/numbers and replaces spaces with dashes
$site_name = remove_accents( $site_name );
$site_name = sanitize_title_with_dashes( $site_name ); // lower-case, dash-separated
// Fallback if it ends up empty (e.g., only symbols/emojis)
if ( '' === $site_name ) {
$site_name = 'site';
}
// Multisite-aware blog/site ID (on single site this is typically 1)
$blog_id = function_exists( 'get_current_blog_id' ) ? (int) get_current_blog_id() : 1;
// Use WordPress timezone for date/time
$ts = current_time( 'timestamp' );
$date = date_i18n( 'Y-m-d', $ts );
// Build a safe basename (no parentheses)
$basename = sprintf(
'simply-static-%s-%d-%s-%d.zip',
$site_name,
$blog_id,
$date,
$ts
);
// Return the full path inside the provided archive directory
$zip_filename = trailingslashit( wp_normalize_path( $archive_dir ) ) . $basename;
return $zip_filename;
}, 10, 3 );
Now we’re cooking – thanks! π₯