• Howdy!

    I think it would be great if the exported zip’s filename contained the actual Title of the site, rather than (or in addition to) the Site ID. And while I appreciate the timestamp, I’d also think a more human-readable date could be useful as well. I’ll assume you want to leave “simply-static” in there for branding/marketing purposes. πŸ™‚

    A sample export filename, in my dream world, would be something like:

    simply-static-My-Awesome-Site-ID(blog_id)-2025-11-03-(timestamp-for-completeness).zip

    Relatively minor in the grand scheme of things, of course, but just something I thought I’d share that would be helpful as I can continue to experiment with Simply Static.

    Or perhaps this could be customizable with a filter?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author patrickposner

    (@patrickposner)

    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

    Plugin Author patrickposner

    (@patrickposner)

    @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 );
    Thread Starter Jason LeMahieu (MadtownLems)

    (@madtownlems)

    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.

    Plugin Author patrickposner

    (@patrickposner)

    @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 );
    Thread Starter Jason LeMahieu (MadtownLems)

    (@madtownlems)

    Now we’re cooking – thanks! πŸ”₯

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.