From 21cdf2ff8f86821b6fe2f82764a963a70bb9dac7 Mon Sep 17 00:00:00 2001 From: David Stone Date: Sat, 2 May 2026 15:53:17 -0600 Subject: [PATCH 1/3] fix(checkout): use available_domains for auto-generated site URLs When auto_generate_site_url is enabled, the checkout previously ignored the available_domains config and fell back to $current_site->domain (the network primary). This meant domain-mapped checkout sites (e.g. ultimateagentwp.ai) created subsites under the wrong domain (mygratis.site instead of ultimateagentwp.ai). Now when auto-generate is on and available_domains is configured, a hidden site_domain field is emitted with the first available domain. Also makes the Available Domains textarea visible in admin when auto-generate is enabled. --- .../class-signup-field-site-url.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/inc/checkout/signup-fields/class-signup-field-site-url.php b/inc/checkout/signup-fields/class-signup-field-site-url.php index e0fb59a55..58b4d82d2 100644 --- a/inc/checkout/signup-fields/class-signup-field-site-url.php +++ b/inc/checkout/signup-fields/class-signup-field-site-url.php @@ -242,11 +242,11 @@ public function get_fields() { 'order' => 30, 'type' => 'textarea', 'title' => __('Available Domains', 'ultimate-multisite'), - 'desc' => __('Enter one domain option per line.', 'ultimate-multisite'), + 'desc' => __('Enter one domain option per line. When auto-generate is enabled, the first domain is used as the base for new subsites.', 'ultimate-multisite'), 'value' => $current_site->domain . PHP_EOL, 'tab' => 'content', 'wrapper_html_attr' => [ - 'v-show' => '!auto_generate_site_url && enable_domain_selection', + 'v-show' => 'auto_generate_site_url || enable_domain_selection', ], 'html_attr' => [ 'rows' => 4, @@ -295,6 +295,28 @@ public function to_fields_array($attributes) { 'value' => 'autogenerate', ], ]; + + /* + * When available_domains is configured, inject a hidden site_domain + * field so the checkout session uses the correct base domain instead + * of falling back to $current_site->domain (the network primary). + * + * This is critical for domain-mapped checkout sites (e.g. a checkout + * on ultimateagentwp.ai should create subsites under + * ultimateagentwp.ai, not under the network primary mygratis.site). + */ + if (! empty($attributes['available_domains'])) { + $domains = array_filter(array_map('trim', explode(PHP_EOL, $attributes['available_domains']))); + + if (! empty($domains)) { + $checkout_fields['site_domain'] = [ + 'type' => 'hidden', + 'id' => 'site_domain', + 'value' => $domains[0], + ]; + } + } + if (! empty($attributes['display_url_preview_with_auto'])) { $content = wu_get_template_contents('legacy/signup/steps/step-domain-url-preview'); From 5cb9718517f415a5bd8117b949118c3261ea95e1 Mon Sep 17 00:00:00 2001 From: David Stone Date: Sat, 2 May 2026 16:24:48 -0600 Subject: [PATCH 2/3] refactor: split available_domains into single text input for auto-generate mode When auto_generate_site_url is enabled, only one domain is allowed so show a single-line text input instead of a textarea. The textarea is kept for the manual domain-selection mode (multiple domains). - available_domains: text input, shown when auto-generate is on - available_domains_multi: textarea, shown when domain selection is on - Simplified hidden site_domain injection (no more newline splitting) --- .../class-signup-field-site-url.php | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/inc/checkout/signup-fields/class-signup-field-site-url.php b/inc/checkout/signup-fields/class-signup-field-site-url.php index 58b4d82d2..438bd1014 100644 --- a/inc/checkout/signup-fields/class-signup-field-site-url.php +++ b/inc/checkout/signup-fields/class-signup-field-site-url.php @@ -239,14 +239,25 @@ public function get_fields() { ], ], 'available_domains' => [ + 'order' => 30, + 'type' => 'text', + 'title' => __('Available Domain', 'ultimate-multisite'), + 'desc' => __('The domain used as the base for auto-generated subsite URLs.', 'ultimate-multisite'), + 'value' => $current_site->domain, + 'tab' => 'content', + 'wrapper_html_attr' => [ + 'v-show' => 'auto_generate_site_url', + ], + ], + 'available_domains_multi' => [ 'order' => 30, 'type' => 'textarea', 'title' => __('Available Domains', 'ultimate-multisite'), - 'desc' => __('Enter one domain option per line. When auto-generate is enabled, the first domain is used as the base for new subsites.', 'ultimate-multisite'), + 'desc' => __('Enter one domain option per line.', 'ultimate-multisite'), 'value' => $current_site->domain . PHP_EOL, 'tab' => 'content', 'wrapper_html_attr' => [ - 'v-show' => 'auto_generate_site_url || enable_domain_selection', + 'v-show' => '!auto_generate_site_url && enable_domain_selection', ], 'html_attr' => [ 'rows' => 4, @@ -305,16 +316,14 @@ public function to_fields_array($attributes) { * on ultimateagentwp.ai should create subsites under * ultimateagentwp.ai, not under the network primary mygratis.site). */ - if (! empty($attributes['available_domains'])) { - $domains = array_filter(array_map('trim', explode(PHP_EOL, $attributes['available_domains']))); - - if (! empty($domains)) { - $checkout_fields['site_domain'] = [ - 'type' => 'hidden', - 'id' => 'site_domain', - 'value' => $domains[0], - ]; - } + $domain = trim(wu_get_isset($attributes, 'available_domains', '')); + + if (! empty($domain)) { + $checkout_fields['site_domain'] = [ + 'type' => 'hidden', + 'id' => 'site_domain', + 'value' => $domain, + ]; } if (! empty($attributes['display_url_preview_with_auto'])) { @@ -372,8 +381,8 @@ public function to_fields_array($attributes) { ]; } - if ($attributes['available_domains'] && $attributes['enable_domain_selection']) { - $options = $this->get_domain_options($attributes['available_domains']); + if (! empty($attributes['available_domains_multi']) && $attributes['enable_domain_selection']) { + $options = $this->get_domain_options($attributes['available_domains_multi']); $checkout_fields['site_domain'] = [ 'name' => __('Domain', 'ultimate-multisite'), From f7aea7bfb499be9f41b814177381cad63f254d59 Mon Sep 17 00:00:00 2001 From: David Stone Date: Sat, 2 May 2026 16:39:31 -0600 Subject: [PATCH 3/3] remove too much ai comemnts --- inc/checkout/signup-fields/class-signup-field-site-url.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/inc/checkout/signup-fields/class-signup-field-site-url.php b/inc/checkout/signup-fields/class-signup-field-site-url.php index 438bd1014..7659c6bf4 100644 --- a/inc/checkout/signup-fields/class-signup-field-site-url.php +++ b/inc/checkout/signup-fields/class-signup-field-site-url.php @@ -312,9 +312,6 @@ public function to_fields_array($attributes) { * field so the checkout session uses the correct base domain instead * of falling back to $current_site->domain (the network primary). * - * This is critical for domain-mapped checkout sites (e.g. a checkout - * on ultimateagentwp.ai should create subsites under - * ultimateagentwp.ai, not under the network primary mygratis.site). */ $domain = trim(wu_get_isset($attributes, 'available_domains', ''));