diff --git a/src/Installer/WordPressInstaller.php b/src/Installer/WordPressInstaller.php index aaea325..f1f1bdc 100644 --- a/src/Installer/WordPressInstaller.php +++ b/src/Installer/WordPressInstaller.php @@ -111,6 +111,18 @@ public function runInstall() { Command::debug('Installing WordPress'); + if ($this->props->isMultisite()) { + $this->runMultisiteInstall(); + } else { + $this->runSingleInstall(); + } + } + + /** + * Run single site WordPress install. + */ + protected function runSingleInstall() + { WP::core('install', [ 'url' => $this->props->fullUrl(), 'title' => $this->props->site_name, @@ -121,6 +133,27 @@ public function runInstall() ]); } + /** + * Run multisite network WordPress install. + */ + protected function runMultisiteInstall() + { + $args = [ + 'url' => $this->props->fullUrl(), + 'title' => $this->props->site_name, + 'admin_user' => $this->props->option('admin_user'), + 'admin_password' => $this->props->option('admin_password'), + 'admin_email' => $this->props->option('admin_email', "admin@{$this->props->domain}"), + 'skip-email' => true + ]; + + if ($this->props->isSubdomains()) { + $args['subdomains'] = true; + } + + WP::core('multisite-install', $args); + } + /** * Install the sqlite database drop-in. */ diff --git a/src/Props.php b/src/Props.php index d1c8cb9..e7d3082 100644 --- a/src/Props.php +++ b/src/Props.php @@ -129,6 +129,26 @@ public function isSecure() return ! ($this->option('unsecure') || $this->option('portable')); } + /** + * Whether or not the install will be a multisite network. + * + * @return bool + */ + public function isMultisite() + { + return (bool) $this->option('network') || $this->option('subdomains'); + } + + /** + * Whether or not the install will use subdomains for multisite. + * + * @return bool + */ + public function isSubdomains() + { + return (bool) $this->option('subdomains'); + } + /** * Get an option value by name. * diff --git a/src/ValetCommand.php b/src/ValetCommand.php index 1ab83c1..aa7148a 100644 --- a/src/ValetCommand.php +++ b/src/ValetCommand.php @@ -154,6 +154,12 @@ public static function boot() * [--portable] * : Provision the site to be portable. Implies --unsecure and --db=sqlite. * + * [--network] + * : Install WordPress as a multisite network. + * + * [--subdomains] + * : Use subdomains for multisite. Implies --network. + * * @subcommand new * * @when before_wp_load