| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the WindPress package. |
| 5 |
* |
| 6 |
* (c) Joshua Gugun Siagian <suabahasa@gmail.com> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
declare (strict_types=1); |
| 12 |
namespace WindPress\WindPress\Integration\GreenShift; |
| 13 |
|
| 14 |
use WindPress\WindPress\Integration\IntegrationInterface; |
| 15 |
use WindPress\WindPress\Utils\Common; |
| 16 |
use WindPress\WindPress\Utils\Config; |
| 17 |
/** |
| 18 |
* Tested with GreenShift version 9.4 |
| 19 |
* @author Joshua Gugun Siagian <suabahasa@gmail.com> |
| 20 |
*/ |
| 21 |
class Main implements IntegrationInterface |
| 22 |
{ |
| 23 |
public function __construct() |
| 24 |
{ |
| 25 |
add_filter('f!windpress/core/cache:compile.providers', fn(array $providers): array => $this->register_provider($providers)); |
| 26 |
} |
| 27 |
public function get_name(): string |
| 28 |
{ |
| 29 |
return 'greenshift'; |
| 30 |
} |
| 31 |
public function is_enabled(): bool |
| 32 |
{ |
| 33 |
return (bool) apply_filters('f!windpress/integration/greenshift:enabled', Config::get(sprintf('integration.%s.enabled', $this->get_name()), \true)); |
| 34 |
} |
| 35 |
public function register_provider(array $providers): array |
| 36 |
{ |
| 37 |
$providers[] = ['id' => $this->get_name(), 'name' => __('GreenShift', 'windpress'), 'description' => __('The GreenShift integration. It requires the Gutenberg/Block Editor integration enabled.', 'windpress'), 'callback' => Config::get(sprintf('integration.%s.compile.enabled', $this->get_name()), \true) ? \WindPress\WindPress\Integration\GreenShift\Compile::class : static fn() => [], 'enabled' => $this->is_enabled(), 'type' => 'plugin', 'homepage' => 'https://shop.greenshiftwp.com/?from=3679', 'is_installed_active' => static function () { |
| 38 |
$is = -1; |
| 39 |
$is += Common::is_plugin_installed('GreenShift - Animation and Page Builder Blocks') ? 1 : 0; |
| 40 |
$is += Common::is_plugin_active_by_name('GreenShift - Animation and Page Builder Blocks') ? 1 : 0; |
| 41 |
return $is; |
| 42 |
}, 'meta' => ['experimental' => \true]]; |
| 43 |
return $providers; |
| 44 |
} |
| 45 |
} |
| 46 |
|