admin管理员组

文章数量:1313347

I am setting up a Wordpress Network Multisite solution - and expect to serve distinct domains e.g.

  • www.builder
  • www.tailor
  • www.chef

These will be set within the /wp-admin/network/site-info.php?id=2 page - in the "Site Address(URL)" field.

I have three environments - each on a different physical device;

  • local.* (local development)
  • uat.* (customer staging / sign off)
  • www.* (production)

I will be using GIT to push custom code, WP & plugin updates from local > dev > www

The entire database will be cloned from www > dev | local - in order to recreate issues when required.

What approach should I use to programmatically define the subdomains such that I do not need to update database tables every time I restore a backup from www to local?

I did this on standard WP using the machine the code was running on to determine the url:


//Decide which subdomain to serve
$subdomain = "local.";
$var_hostname = gethostname();
$reqDom = $_SERVER['HTTP_HOST'];
if (strrpos($var_hostname, "dev") > -1) {
    $subdomain = "uat.";   
} else if (strrpos($var_hostname, "web") > -1) {
    // web host found... must be LIVE
    $subdomain = "www";
}
define('WP_HOME', 'https://' . $subdomain . 'chef');
define('WP_SITEURL', 'https://' . $subdomain . 'chef');

I've tried the following filter but with no success:

// Derive which URL's to use - along with multisite
function my_filter_option_siteurl($siteurl) {
    // filter $siteurl here   
    return getSanitisedEnvURL($siteurl);
}

本文标签: Wordpress Folder Multisitedevstagingwww versions