Skip to content

Commit

Permalink
Add acf-pro install commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Dargham committed Jun 16, 2023
1 parent 7f4d92b commit 961e2e5
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/WordPressTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected function wpInit()
$this->wpLanguageInstall(null, ['activate' => true]);
$this->wpUpdateTimezone();
$this->wpClean();
$this->wpMaybeInstallAcfPro();
$this->wpActivatePlugins();

$this->io()->success('WordPress is ready.');
Expand Down Expand Up @@ -375,4 +376,52 @@ protected function loadWpConfig()
require_once $config_application;
require_once $config_local;
}

protected function wpMaybeInstallAcfPro()
{
if ($this->io()->confirm('Do you want to install ACF PRO (paid license key required) ?', false)) {
$this->wpInstallAcfPro();
}
}

public function wpInstallAcfPro($options = ['username' => '', 'password' => ''])
{
$this->io()->info(
"Installation of ACF PRO is made using connect.advancedcustomfields.com private Composer repository and require HTTP basic authentication.\n
The username is the ACF PRO license key, and the password is the site URL (including https:// or http://) that the license is registered for (not necessarily the site URL of this project).\n
See the official ACF PRO documentation for more information on https://www.advancedcustomfields.com/resources/installing-acf-pro-with-composer/"
);

if (!empty($options['username'])) {
$username = $options['username'];
} else {
$username = $this->io()->ask('connect.advancedcustomfields.com username (license key)');
}

if (!empty($options['password'])) {
$password = $options['password'];
} else {
$password = $this->io()->ask('connect.advancedcustomfields.com password (license site URL)');
}

$this->taskComposer('remove')
->arg('wpackagist-plugin/advanced-custom-fields')
->run();

$this->taskComposer('config')
->arg('http-basic.connect.advancedcustomfields.com')
->arg($username)
->arg($password)
->run();

$this->taskComposer('config')
->arg('repositories.advancedcustomfields')
->arg('composer')
->arg('https://connect.advancedcustomfields.com')
->run();

$this->taskComposer('require')
->arg('wpengine/advanced-custom-fields-pro')
->run();
}
}

0 comments on commit 961e2e5

Please sign in to comment.