Skip to content
Open
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
33 changes: 33 additions & 0 deletions src/Installer/WordPressInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
*/
Expand Down
20 changes: 20 additions & 0 deletions src/Props.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
6 changes: 6 additions & 0 deletions src/ValetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down