Skip to content
Merged
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
4 changes: 4 additions & 0 deletions config/yard-config-expander.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
'ACF_PRO_LICENSE_KEY' => $_SERVER['ACF_PRO_LICENSE_KEY'] ?? null,
'FACETWP_LICENSE_KEY' => $_SERVER['FACETWP_LICENSE_KEY'] ?? null,
'GF_LICENSE_KEY' => $_SERVER['GF_LICENSE_KEY'] ?? null,
'GRAVITYSMTP_GENERIC_HOST' => $_SERVER['GRAVITYSMTP_GENERIC_HOST'] ?? null,
'GRAVITYSMTP_GENERIC_PORT' => $_SERVER['GRAVITYSMTP_GENERIC_PORT'] ?? null,
'GRAVITYSMTP_GENERIC_ENCRYPTION_TYPE' => $_SERVER['GRAVITYSMTP_GENERIC_ENCRYPTION_TYPE'] ?? null,
'GRAVITYSMTP_GENERIC_AUTH' => $_SERVER['GRAVITYSMTP_GENERIC_AUTH'] ?? null,
'SEARCHWP_LICENSE_KEY' => $_SERVER['SEARCHWP_LICENSE_KEY'] ?? null,
'SEOPRESS_LICENSE_KEY' => $_SERVER['SEOPRESS_LICENSE_KEY'] ?? null,
'WPMDB_LICENSE_KEY' => $_SERVER['WPMDB_LICENSE_KEY'] ?? null,
Expand Down
4 changes: 2 additions & 2 deletions src/Licenses/Contracts/AbstractLicense.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function __construct(array $licenses)

abstract public function register(): void;

protected function getLicense(): string
protected function getLicense(?string $configKey = null): string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Support for multiple constants per class was still missing.

{
return $this->licenses[static::LICENSE_CONFIG_KEY] ?? '';
return $this->licenses[$configKey ?? static::LICENSE_CONFIG_KEY] ?? '';
}
}
2 changes: 2 additions & 0 deletions src/Licenses/LicensesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Yard\ConfigExpander\Licenses\Plugins\AdvancedCustomFieldsLicense;
use Yard\ConfigExpander\Licenses\Plugins\FacetWPLicense;
use Yard\ConfigExpander\Licenses\Plugins\GravityFormsLicense;
use Yard\ConfigExpander\Licenses\Plugins\GravitySMTPLicense;
use Yard\ConfigExpander\Licenses\Plugins\SearchWPLicense;
use Yard\ConfigExpander\Licenses\Plugins\SeoPressLicense;
use Yard\ConfigExpander\Licenses\Plugins\WpMigrateLicense;
Expand All @@ -30,6 +31,7 @@ protected function setLicenses(): void
LicenseManager::make($licenses)->registerPlugins([
AdvancedCustomFieldsLicense::class,
GravityFormsLicense::class,
GravitySMTPLicense::class,
FacetWPLicense::class,
SearchWPLicense::class,
SeoPressLicense::class,
Expand Down
35 changes: 35 additions & 0 deletions src/Licenses/Plugins/GravitySMTPLicense.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Yard\ConfigExpander\Licenses\Plugins;

use Yard\ConfigExpander\Licenses\Contracts\AbstractLicense;

class GravitySMTPLicense extends AbstractLicense
{
protected const GRAVITYSMTP_GENERIC_HOST = 'GRAVITYSMTP_GENERIC_HOST';
protected const GRAVITYSMTP_GENERIC_PORT = 'GRAVITYSMTP_GENERIC_PORT';
protected const GRAVITYSMTP_GENERIC_ENCRYPTION_TYPE = 'GRAVITYSMTP_GENERIC_ENCRYPTION_TYPE';
protected const GRAVITYSMTP_GENERIC_AUTH = 'GRAVITYSMTP_GENERIC_AUTH';

public function register(): void
{
$smtpConstants = [
self::GRAVITYSMTP_GENERIC_HOST,
self::GRAVITYSMTP_GENERIC_PORT,
self::GRAVITYSMTP_GENERIC_ENCRYPTION_TYPE,
self::GRAVITYSMTP_GENERIC_AUTH,
];

foreach ($smtpConstants as $constant) {
$value = $this->getLicense($constant);

if (defined($constant) || ('' === $value)) {
continue;
}

define($constant, $value);
}
}
}
Loading