Skip to content

Commit

Permalink
Fix the multisite option by adding the WORDPRESSDIR constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
crewstyle committed Jan 2, 2022
1 parent 519d0c0 commit 3ff13c9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.0.28 (January 2, 2022)
Fix the `siteurl` multisite option by adding the WORDPRESSDIR constant.

## v0.0.27 (March 6, 2021)
Auto detect https use from site url.
Add options to fully customize WordPress installation, as multisite or single site.
Expand Down
58 changes: 42 additions & 16 deletions web/statics/mu-plugins/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,6 @@
return WP_THEME_URL;
});

/**
* Update network admin URL.
*/
add_filter('network_site_url', function ($url, $path, $scheme) {
// Check network admin path
if ('wp-admin/network/' !== $path || 'admin' !== $scheme) {
return $url;
}

// Fix path by adding the WORDPRESSDIR constant
$current_network = get_network();
$url = set_url_scheme('https://'.$current_network->domain.'/'.WORDPRESSDIR.$current_network->path, $scheme);

return $url.ltrim($path, '/');
}, 10, 3);

/**
* Update automatically the `own.php` configuration file.
*/
Expand Down Expand Up @@ -189,3 +173,45 @@
// Puts contents into target configuration file
file_put_contents($target, $contents);
});
/**
* Update network admin URL.
*/
add_filter('network_site_url', function ($url, $path, $scheme) {
// Check network admin path
if ('wp-admin/network/' !== $path || 'admin' !== $scheme) {
return $url;
}
// Fix path by adding the WORDPRESSDIR constant
$current_network = get_network();
$url = set_url_scheme('https://'.$current_network->domain.'/'.WORDPRESSDIR.$current_network->path, $scheme);
return $url.ltrim($path, '/');
}, 10, 3);
/**
* Filters reserved site names on a sub-directory Multisite installation.
*/
add_filter('subdirectory_reserved_names', function ($names) {
return array_merge($names, [WORDPRESSDIR]);
});
/**
* Fires once a site has been created.
* Useful to update the `siteurl` option.
*/
add_action('wpmu_new_blog', function ($blog_id, $user_id, $domain, $path, $site_id, $meta) {
// Switch the newly created blog
switch_to_blog($blog_id);
// Get `siteurl` network option and add WORDPRESSDIR constant
$siteurl = get_option('siteurl');
$siteurl = rtrim($siteurl, '/').'/'.WORDPRESSDIR;
// Update option
update_option('siteurl', $siteurl);

// Restore to the current blog
restore_current_blog();
}, 10, 6);

0 comments on commit 3ff13c9

Please sign in to comment.