Skip to content

Commit fb8478c

Browse files
committed
fix: fall back to subdomain for blogname when title is empty on duplication
When $args->title arrives empty (e.g. via WooCommerce checkout flow), the duplicated site kept the template's blogname instead of the customer's site name. Now falls back to the subdomain portion of the site's domain, ensuring the blogname always reflects the new site.
1 parent 458bc0c commit fb8478c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

inc/helpers/class-site-duplicator.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,14 @@ protected static function process_duplication($args) {
323323

324324
// Ensure the requested title is applied after duplication, since the
325325
// table copy may overwrite the blogname option set during site creation.
326-
if (! empty($args->title)) {
327-
update_blog_option($args->to_site_id, 'blogname', $args->title);
328-
}
326+
// When no title was provided (e.g. WooCommerce checkout flow), fall back
327+
// to the subdomain portion of the site's domain so the duplicated site
328+
// doesn't keep the template's blogname.
329+
$new_title = ! empty($args->title)
330+
? $args->title
331+
: preg_replace('/\..*$/', '', $args->domain);
332+
333+
update_blog_option($args->to_site_id, 'blogname', $new_title);
329334

330335
/**
331336
* Allow developers to hook after a site duplication happens.

0 commit comments

Comments
 (0)