Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ben182 committed Jan 4, 2020
2 parents c7a9b00 + 8d950ef commit 52de612
Show file tree
Hide file tree
Showing 12 changed files with 314 additions and 228 deletions.
2 changes: 1 addition & 1 deletion .php_cs.cache

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions _ide_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 6.6.2 on 2019-12-10 10:33:04.
* Generated for Laravel 6.9.0 on 2020-01-04 09:27:02.
*
* This file should not be included in your code, only analyzed by your IDE!
*
Expand Down Expand Up @@ -10096,8 +10096,8 @@ public static function all($keys = null)
* Retrieve an input item from the request.
*
* @param string|null $key
* @param string|array|null $default
* @return string|array|null
* @param mixed $default
* @return mixed
* @static
*/
public static function input($key = null, $default = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public function handle()
$this->addConclusion("There is already an html folder so I moved it to html_backup");
}

$this->shell->exec("sudo ln -s -f {$this->bindings->installationDir} {$this->bindings->domain->getHtmlFolder()}");
$this->shell->exec("ln -s -f {$this->bindings->installationDir} {$this->bindings->domain->getHtmlFolder()}");

break;
case 'Sub':

$this->bindings->domain->createHtmlFolder();

$this->shell->exec("sudo ln -s -f {$this->bindings->installationDir} {$this->bindings->domain->getHtmlFolder()}/{$this->options->subDir}");
$this->shell->exec("ln -s -f {$this->bindings->installationDir} {$this->bindings->domain->getHtmlFolder()}/{$this->options->subDir}");

break;
}
Expand Down
24 changes: 24 additions & 0 deletions app/Console/Commands/WordpressInstall/Tasks/PageBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Console\Commands\WordpressInstall\Tasks;

use App\Console\Task;

class PageBuilder extends Task
{
public $name = 'Installing Page Builder';

public function localRequirements()
{
return $this->options->pageBuilder !== 'None';
}

public function handle()
{
switch ($this->options->pageBuilder) {
case 'Elementor':
$this->shell->exec("cd {$this->bindings->installationDir} && wp plugin install elementor --activate");
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ public function handle()
}

if ($this->options->pioneersConfig) {
$this->shell->exec("cd {$this->bindings->installationDir} && wp option update whl_page mp-admin");
$this->shell->exec("cd {$this->bindings->installationDir} && wp option update whl_page {$this->bindings->adminUrl}");
} else {
$this->shell->exec("cd {$this->bindings->installationDir} && wp plugin deactivate wps-hide-login");
}

$this->addConclusion("Configured Wordpress");
$this->addConclusion("Email: $email");
$this->addConclusion("Password: $password");
$this->addConclusion("Login URL is {$this->bindings->domain->getFullUrl()}" . ($this->options->subDir ? '/' . $this->options->subDir : '') . '/' . $this->bindings->adminUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public function handle()
$bPioneersConfig = $this->confirm('Apply Pioneers specific config?', true);
$bLocal = $this->confirm('Is this a local or stage site?', true);

// PAGE BUILDER
$pageBuilder = $this->choice('Install Page Builder?', [
'Elementor',
'None',
], 'Elementor');

WordpressInstallTaskManager::work([
'domain' => $sDomain,
'rootOrSub' => $sRootOrSub,
Expand All @@ -64,6 +70,7 @@ public function handle()
'installPlugins' => $bInstallRecommendedPlugins,
'pioneersConfig' => $bPioneersConfig,
'local' => $bLocal,
'pageBuilder' => $pageBuilder,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Console\TaskManager;
use Illuminate\Validation\Rule;
use App\Console\Commands\WordpressInstall\Tasks\Database;
use App\Console\Commands\WordpressInstall\Tasks\PageBuilder;
use App\Console\Commands\WordpressInstall\Tasks\WordpressConf;
use App\Console\Commands\WordpressInstall\Tasks\WordpressInit;
use App\Console\Commands\WordpressInstall\Tasks\LinkApplication;
Expand All @@ -20,6 +21,7 @@ class WordpressInstallTaskManager extends TaskManager
WordpressInit::class,
Database::class,
WordpressConf::class,
PageBuilder::class,
LinkApplication::class,
];

Expand All @@ -35,9 +37,13 @@ public function addVariableBinding() : array
$installDir = $oDomain->getBaseFolder() . "/{$nameSlugged}";
}

$initials = app('stool-initials')->generate($this->options->name);
$initials = strtolower($initials);

return [
'domain' => $oDomain,
'installationDir' => $installDir,
'adminUrl' => $initials . '-admin',
];
}

Expand All @@ -60,6 +66,13 @@ public function validate()
'installPlugins' => 'required|boolean',
'pioneersConfig' => 'required|boolean',
'local' => 'required|boolean',
'pageBuilder' => [
Rule::in([
'Divi',
'Elementor',
'None',
]),
],
];
}
}
40 changes: 40 additions & 0 deletions app/Helper/Initials.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Helper;

class Initials
{
/**
* Generate initials from a name.
*
* @param string $name
*
* @return string
*/
public function generate(string $name) : string
{
$words = explode(' ', $name);
if (count($words) >= 2) {
return strtoupper(substr($words[0], 0, 1) . substr(end($words), 0, 1));
}

return $this->makeInitialsFromSingleWord($name);
}

/**
* Make initials from a word with no spaces.
*
* @param string $name
*
* @return string
*/
protected function makeInitialsFromSingleWord(string $name) : string
{
preg_match_all('#([A-Z]+)#', $name, $capitals);
if (count($capitals[1]) >= 2) {
return substr(implode('', $capitals[1]), 0, 2);
}

return strtoupper(substr($name, 0, 2));
}
}
2 changes: 2 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Helper\Config;
use App\Helper\Github;
use App\Helper\Hardware;
use App\Helper\Initials;
use App\Helper\Password;
use App\Helper\Increment;
use App\Helper\FloatingIp;
Expand Down Expand Up @@ -59,6 +60,7 @@ public function boot()
$this->app->singleton('stool-github', Github::class);
$this->app->singleton('stool-apache', Apache::class);
$this->app->singleton('stool-floating-ip', FloatingIp::class);
$this->app->singleton('stool-initials', Initials::class);

Command::macro('abort', function ($sMessage) {
$this->error($sMessage);
Expand Down
Loading

0 comments on commit 52de612

Please sign in to comment.