| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | declare (strict_types=1); |
| 12 | 12 | namespace WindPress\WindPress\Integration\Gutenberg; |
| 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 | * @author Joshua Gugun Siagian <suabahasa@gmail.com> |
| 18 | 19 | */ |
| @@ -19,23 +20,31 @@ | ||
| 19 | 20 | class Main implements IntegrationInterface |
| 20 | 21 | { |
| 21 | 22 | public function __construct() |
| 22 | 23 | { |
| 23 | - \add_filter('f!windpress/core/cache:compile.providers', fn(array $providers): array => $this->register_provider($providers)); | |
| 24 | + add_filter('f!windpress/core/cache:compile.providers', fn(array $providers): array => $this->register_provider($providers)); | |
| 24 | 25 | if ($this->is_enabled()) { |
| 25 | - new \WindPress\WindPress\Integration\Gutenberg\Editor(); | |
| 26 | + if (Config::get(sprintf('integration.%s.editor.enabled', $this->get_name()), \true)) { | |
| 27 | + new \WindPress\WindPress\Integration\Gutenberg\Editor(); | |
| 28 | + } | |
| 29 | + \WindPress\WindPress\Integration\Gutenberg\CommonBlock::get_instance(); | |
| 26 | 30 | } |
| 27 | 31 | } |
| 28 | - public function get_name() : string | |
| 32 | + public function get_name(): string | |
| 29 | 33 | { |
| 30 | 34 | return 'gutenberg'; |
| 31 | 35 | } |
| 32 | - public function is_enabled() : bool | |
| 36 | + public function is_enabled(): bool | |
| 33 | 37 | { |
| 34 | - return (bool) \apply_filters('f!windpress/integration/gutenberg:enabled', Config::get(\sprintf('integration.%s.enabled', $this->get_name()), \true)); | |
| 38 | + return (bool) apply_filters('f!windpress/integration/gutenberg:enabled', Config::get(sprintf('integration.%s.enabled', $this->get_name()), \true)); | |
| 35 | 39 | } |
| 36 | - public function register_provider(array $providers) : array | |
| 40 | + public function register_provider(array $providers): array | |
| 37 | 41 | { |
| 38 | - $providers[] = ['id' => $this->get_name(), 'name' => \__('Gutenberg', 'windpress'), 'description' => \__('Gutenberg/Block Editor integration', 'windpress'), 'callback' => \WindPress\WindPress\Integration\Gutenberg\Compile::class, 'enabled' => $this->is_enabled()]; | |
| 42 | + $providers[] = ['id' => $this->get_name(), 'name' => __('Gutenberg', 'windpress'), 'description' => __('Gutenberg/Block Editor integration', 'windpress'), 'source_index' => 1, 'callback' => Config::get(sprintf('integration.%s.compile.enabled', $this->get_name()), \true) ? \WindPress\WindPress\Integration\Gutenberg\Compile::class : static fn() => [], 'enabled' => $this->is_enabled(), 'type' => 'custom', 'homepage' => 'https://wordpress.org/gutenberg/?ref=jooosi', 'is_installed_active' => static function () { | |
| 43 | + $is = -1; | |
| 44 | + $is += function_exists('register_block_type') ? 1 : 0; | |
| 45 | + $is += function_exists('register_block_type') ? 1 : 0; | |
| 46 | + return $is; | |
| 47 | + }]; | |
| 39 | 48 | return $providers; |
| 40 | 49 | } |
| 41 | 50 | } |