GH#769: Fix domain mapping option_home filter, rewrite flush after duplication, and SSL scheme hardening#771
GH#769: Fix domain mapping option_home filter, rewrite flush after duplication, and SSL scheme hardening#771superdav42 wants to merge 1 commit intomainfrom
Conversation
…dening
Fixes three related domain mapping bugs reported in GH#769:
1. Add missing option_home filter in Domain_Mapping::register_filters() so
get_option('home') returns the mapped domain URL instead of the raw
subdomain. Fixes broken CPT permalinks, Elementor iframe preview, and
admin AJAX on sites with custom domain mapping.
2. Add flush_rewrite_rules_for_new_site() hook on wu_duplicate_site (priority
20) in Elementor_Compat. Clears stale rewrite rules copied verbatim from
the template site, preventing 404s on CPT URLs after site duplication.
3. Harden fix_new_site_url_scheme() to fall back to FORCE_SSL_ADMIN or
is_ssl() when get_home_url() returns http:// during site creation (race
condition on LiteSpeed/Cloudflare setups). Prevents subsites being created
with http:// siteurl/home on HTTPS networks.
Fixes #769
Completion Summary
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAddresses three domain mapping and site duplication bugs: adds missing Changes
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 docstrings
🧪 Generate unit tests (beta)
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. 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: |
|
Closing as duplicate of #770. PR #770 was submitted by the issue reporter (kenedytorcatt) before this worker was dispatched, covers the same fixes, and has all CI checks passing. Merging #770 instead. aidevops.sh v3.6.167 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 17m and 4,947 tokens on this as a headless worker. Overall, 3m since this issue was created. |
|
Performance Test Results Performance test results for a912f51 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:
|
Summary
Fixes three related domain mapping bugs causing 404 errors on custom post types, broken Elementor preview, and mixed content issues on subsites with mapped domains.
Bug 1: Missing
option_homefilter (CRITICAL)register_filters()ininc/class-domain-mapping.phpaddedoption_siteurlbut notoption_home. This meantget_option('home')returned the raw subdomain URL instead of the mapped domain, breaking:Fix: Added
add_filter('option_home', [$this, 'mangle_url'], 20)after the existingoption_siteurlfilter at line 493.Bug 2: No
flush_rewrite_rules()afterwu_duplicate_siteWhen UM duplicates a template site,
rewrite_rulesis copied verbatim. If the template's rules were generated with a different CPT slug, all cloned subsites keep stale rules causing 404s.Fix: Added
flush_rewrite_rules_for_new_site()method inElementor_Compathooked onwu_duplicate_siteat priority 20 (afterregenerate_css). Uses the sameswitch_to_blog/restore_current_blogpattern as the existingregenerate_cssmethod.Bug 3:
fix_new_site_url_scheme()race conditionOn LiteSpeed + Cloudflare setups,
get_home_url()can returnhttp://during site creation before SSL redirect kicks in, causing subsites to be created withhttp://siteurl/home.Fix: Added fallback in
fix_new_site_url_scheme()to checkFORCE_SSL_ADMINconstant oris_ssl()whenget_home_url()returnshttp://.Files Changed
EDIT: inc/class-domain-mapping.php:493— addoption_homefilterEDIT: inc/compat/class-elementor-compat.php:34,67— addflush_rewrite_rules_for_new_sitehook and methodEDIT: inc/compat/class-general-compat.php:489— harden SSL scheme detectionRuntime Testing
Risk level: Medium — domain mapping filters and site initialization hooks.
Self-assessed: Changes follow existing patterns exactly (
option_siteurl→option_home,regenerate_css→flush_rewrite_rules_for_new_site, existing SSL check → hardened with fallback). No new logic paths introduced. Theflush_rewrite_rules(true)call is the standard WordPress approach for this scenario.No runtime environment available for integration testing. The reporter confirmed the same fixes work in their production mu-plugin workaround.
Resolves #769
aidevops.sh v3.6.167 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 2m and 6,725 tokens on this as a headless worker.
Summary by CodeRabbit
Release Notes