| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | declare (strict_types=1); |
| 12 | 12 | namespace WindPress\WindPress\Integration\GreenShift; |
| 13 | 13 | |
| 14 | 14 | use WindPress\WindPress\Integration\IntegrationInterface; |
| 15 | +use WindPress\WindPress\Utils\Common; | |
| 15 | 16 | use WindPress\WindPress\Utils\Config; |
| 16 | 17 | /** |
| 17 | 18 | * Tested with GreenShift version 9.4 |
| 18 | 19 | * @author Joshua Gugun Siagian <suabahasa@gmail.com> |
| @@ -20,23 +21,25 @@ | ||
| 20 | 21 | class Main implements IntegrationInterface |
| 21 | 22 | { |
| 22 | 23 | public function __construct() |
| 23 | 24 | { |
| 24 | - \add_filter('f!windpress/core/cache:compile.providers', fn(array $providers): array => $this->register_provider($providers)); | |
| 25 | - if ($this->is_enabled()) { | |
| 26 | - (new \WindPress\WindPress\Integration\GreenShift\Compile())(); | |
| 27 | - } | |
| 25 | + add_filter('f!windpress/core/cache:compile.providers', fn(array $providers): array => $this->register_provider($providers)); | |
| 28 | 26 | } |
| 29 | - public function get_name() : string | |
| 27 | + public function get_name(): string | |
| 30 | 28 | { |
| 31 | 29 | return 'greenshift'; |
| 32 | 30 | } |
| 33 | - public function is_enabled() : bool | |
| 31 | + public function is_enabled(): bool | |
| 34 | 32 | { |
| 35 | - return (bool) \apply_filters('f!windpress/integration/greenshift:enabled', Config::get(\sprintf('integration.%s.enabled', $this->get_name()), \true)); | |
| 33 | + return (bool) apply_filters('f!windpress/integration/greenshift:enabled', Config::get(sprintf('integration.%s.enabled', $this->get_name()), \true)); | |
| 36 | 34 | } |
| 37 | - public function register_provider(array $providers) : array | |
| 35 | + public function register_provider(array $providers): array | |
| 38 | 36 | { |
| 39 | - $providers[] = ['id' => $this->get_name(), 'name' => \__('GreenShift', 'windpress'), 'description' => \__('The GreenShift integration. It requires the Gutenberg/Block Editor integration enabled.', 'windpress'), 'callback' => fn() => [], 'enabled' => $this->is_enabled(), 'meta' => ['experimental' => \true]]; | |
| 37 | + $providers[] = ['id' => $this->get_name(), 'name' => __('GreenShift', 'windpress'), 'description' => __('The GreenShift integration. It requires the Gutenberg/Block Editor integration enabled.', 'windpress'), 'source_index' => 1, '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]]; | |
| 40 | 43 | return $providers; |
| 41 | 44 | } |
| 42 | 45 | } |