Skip to content

Commit

Permalink
[+] Fixed latest smudges
Browse files Browse the repository at this point in the history
  • Loading branch information
progress44 committed Oct 25, 2019
1 parent c81f2a3 commit 53a076d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions classes/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public function loadOptions()
continue;
}

$config['value'] = $this->getValueForOption($config);
if ($config['required'] && empty($config['value'])) {
$this->config_map[$key]['value'] = $this->getValueForOption($config);
if ($this->config_map[$key]['required'] && empty($this->config_map[$key]['value'])) {
$continue = false;
}
}
Expand Down
25 changes: 13 additions & 12 deletions classes/sink.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function __construct()
}

$options = $this->options->loadOptions();

if (!$options) {
$this->ui->renderNotice('notice-error', 'Plugin not loaded, missing configuration');
return;
Expand All @@ -87,16 +88,16 @@ private function getS3Client()
{
$config = [
'version' => 'latest',
'region' => $this->config_map[0],
'region' => $this->config_map[0]['value'],
'credentials' => [
'key' => $this->config_map[2],
'secret' => $this->config_map[3],
'key' => $this->config_map[2]['value'],
'secret' => $this->config_map[3]['value'],
]
];

if (! empty($this->config_map[7])) {
if (! empty($this->config_map[7]['value'])) {
$config['http'] = [
'proxy' => $this->config_map[7].':'.$this->config_map[8],
'proxy' => $this->config_map[7]['value'].':'.$this->config_map[8]['value'],
];
}

Expand Down Expand Up @@ -133,18 +134,19 @@ public function createDefaultDir($dir, $key)
try {
if (!file_exists($dir.$key)) {
mkdir($dir.$key);
die;
}

// Moved because it should always create the directory first.
if (! empty($this->config_map[6])) {
return $this->config_map[6];
if (! empty($this->config_map[6]['value'])) {
return $this->config_map[6]['value'];
}

if (true == $this->config_map[5]) {
if (true == $this->config_map[5]['value']) {
return WP_SITEURL;
}

$result = $client->getObjectUrl($this->config_map[1], $key);
$result = $client->getObjectUrl($this->config_map[1]['value'], $key);
} catch (\Exception $e) {
if (is_admin()) {
$this->ui->renderNotice('notice-error', 'There was an error while configuring S3');
Expand All @@ -164,9 +166,8 @@ public function setUploadDir($uploads)
{
// Instantiate an Amazon S3 client.
$client = $this->registerS3StreamWrapper();

$dir = "s3://".$this->config_map[1]."/";
$key = $this->config_map['4'] ? $this->config_map['4'] : $this->default_uploads_folder;
$dir = "s3://".$this->config_map[1]['value']."/";
$key = $this->config_map['4']['value'] ?: $this->default_uploads_folder;
$result = $this->createDefaultDir($dir, $key);

$uploads = array_merge(
Expand Down

0 comments on commit 53a076d

Please sign in to comment.