fix(checkout): use available_domains for auto-generated site URLs#1072
Conversation
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.
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change enhances site domain field configuration during checkout signup. The "Available Domains" field description is expanded, its visibility condition is updated to show when auto-generate is enabled or domain selection is enabled, and domain-parsing logic injects a hidden ChangesSite Domain Field Configuration and Generation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: Turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 👉 Get your free trial and get 200 agent minutes per Slack user (a $50 value). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 14 minutes and 19 seconds.Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
inc/checkout/signup-fields/class-signup-field-site-url.php (1)
298-318: 💤 Low valueImplementation looks correct; minor duplication with
get_domain_options().The logic correctly injects a hidden
site_domainfield when auto-generate is enabled and available domains are configured. The guards for empty values are sound.Consider extracting the domain parsing logic to reuse with
get_domain_options()(lines 422-424), which performs similar parsing but with slightly different ordering:// Line 309 (new code) array_filter(array_map('trim', explode(PHP_EOL, $attributes['available_domains']))) // Lines 422-424 (existing) $domains = array_filter(explode(PHP_EOL, $domain_options)); $domains = array_map(fn($item) => trim((string) $item), $domains);Both work correctly, but a shared helper would ensure consistent behavior and reduce duplication.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@inc/checkout/signup-fields/class-signup-field-site-url.php` around lines 298 - 318, Extract the duplicate domain-parsing logic into a single helper (e.g., a private method parse_domains(string $raw): array) and use it from both the new site_domain injection code (where $attributes['available_domains'] is parsed and $checkout_fields['site_domain'] is set) and from get_domain_options(); the helper should explode by PHP_EOL, trim each item, filter out empties, and return the resulting array so both places call parse_domains($attributes['available_domains'] or $domain_options) instead of doing inline array_map/array_filter.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@inc/checkout/signup-fields/class-signup-field-site-url.php`:
- Around line 298-318: Extract the duplicate domain-parsing logic into a single
helper (e.g., a private method parse_domains(string $raw): array) and use it
from both the new site_domain injection code (where
$attributes['available_domains'] is parsed and $checkout_fields['site_domain']
is set) and from get_domain_options(); the helper should explode by PHP_EOL,
trim each item, filter out empties, and return the resulting array so both
places call parse_domains($attributes['available_domains'] or $domain_options)
instead of doing inline array_map/array_filter.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fd2ca4e9-41bf-467e-be66-3035442ca680
📒 Files selected for processing (1)
inc/checkout/signup-fields/class-signup-field-site-url.php
|
Performance Test Results Performance test results for 929f933 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
…erate 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)
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
DISPATCH_CLAIM nonce=dfa2d5f37937103130eb803b4b69c9e0 runner=superdav42 ts=2026-05-02T23:11:26Z max_age_s=1800 version=3.14.1 |
SummaryWhen Changes
TestingVerified end-to-end: checkout on aidevops.sh v3.13.95 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 2d 2h and 8 tokens on this as a headless worker. Merged via PR #1072 to main. |
…ion in Signup_Field_Site_Url (#1080) PR #1072 review feedback: the inline domain-parsing logic in get_domain_options() (array_filter/array_map/explode) was duplicated. Extract it into a private parse_domains() method so both the auto-generate path and the domain-selection path share a single, consistent implementation. Also removes the blank line before the empty-domain guard (human reviewer suggestion at PR #1072 line 317). Resolves #1075
Summary
When
auto_generate_site_urlis enabled on a checkout form, the site URL field previously ignored theavailable_domainsconfiguration and fell back to$current_site->domain(the network primary domain). This caused domain-mapped checkout sites (e.g.ultimateagentwp.ai) to create subsites under the wrong domain (mygratis.siteinstead ofultimateagentwp.ai), breaking same-domain SSO and creating a confusing user experience.Changes
site_domainfield: When auto-generate is on andavailable_domainsis configured, a hiddensite_domainfield is now emitted with the first available domain. The checkout session picks this up viarequest_or_session('site_domain')and passes it towu_get_site_domain_and_path().!auto_generate_site_url && enable_domain_selection). Updated description to explain the auto-generate behavior.Testing
Verified end-to-end: checkout on
ultimateagentwp.ai→ subsite created asusername.ultimateagentwp.ai(notusername.mygratis.site) → SSO auto-login works → AI agent admin page loads successfully.aidevops.sh v3.13.95 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 2d 2h and 8 tokens on this as a headless worker.
Summary by CodeRabbit