Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions inc/class-domain-mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ public function register_mapped_filters(): void {
add_filter('site_url', [$this, 'mangle_url'], -10, 4);
add_filter('home_url', [$this, 'mangle_url'], -10, 4);
add_filter('option_siteurl', [$this, 'mangle_url'], 20);
add_filter('option_home', [$this, 'mangle_url'], 20); // @since 2.4.1 - Fix get_option('home') returning raw subdomain URL

add_filter('theme_file_uri', [$this, 'mangle_url']);
add_filter('stylesheet_directory_uri', [$this, 'mangle_url']);
Expand Down
25 changes: 25 additions & 0 deletions inc/compat/class-elementor-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Elementor_Compat {
public function init(): void {

add_action('wu_duplicate_site', [$this, 'regenerate_css']);
add_action('wu_duplicate_site', [$this, 'flush_rewrite_rules_for_new_site'], 20); // @since 2.4.1 - Flush stale rewrite rules copied from template site

add_filter('wu_should_redirect_to_primary_domain', [$this, 'maybe_prevent_redirection']);

Expand Down Expand Up @@ -66,6 +67,30 @@ public function regenerate_css($site): void {
restore_current_blog();
}

/**
* Flushes rewrite rules on the newly duplicated site.
*
* When UM duplicates a template site, the rewrite_rules option is copied
* verbatim. If the template's rules were generated with a different CPT slug,
* all cloned subsites keep stale rules, causing 404s on CPT URLs.
*
* @since 2.4.1
* @param array $site Info about the duplicated site.
* @return void
*/
public function flush_rewrite_rules_for_new_site($site): void {

if ( ! isset($site['site_id'])) {
return;
}

switch_to_blog((int) $site['site_id']);

flush_rewrite_rules(true);

restore_current_blog();
}

/**
* Prevents redirection to primary domain when in Elementor preview mode.
*
Expand Down
13 changes: 13 additions & 0 deletions inc/compat/class-general-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,19 @@
$network_home = get_home_url($network->site_id);
$scheme = wp_parse_url($network_home, PHP_URL_SCHEME);

/*
* Fallback: if get_home_url() returns http:// during site creation
* (race condition before SSL redirect kicks in), check FORCE_SSL_ADMIN
* or the actual request scheme as a secondary signal.
*
* @since 2.4.1
*/
if ('https' !== $scheme) {
if ( (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN) || is_ssl() ) {

Check warning on line 502 in inc/compat/class-general-compat.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Found usage of constant FORCE_SSL_ADMIN. Use force_ssl_admin() instead.
$scheme = 'https';
}
}

if ('https' === $scheme) {
$url = 'https://' . $site->domain . $site->path;

Expand Down
Loading