| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | declare (strict_types=1); |
| 12 | 12 | namespace WindPress\WindPress\Integration\Elementor; |
| 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,27 +20,32 @@ | ||
| 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 | - \add_filter('f!windpress/core/runtime:append_header.exclude_admin', fn(bool $is_exclude_admin): bool => $this->is_exclude_admin($is_exclude_admin)); | |
| 26 | + add_filter('f!windpress/core/runtime:append_header.exclude_admin', fn(bool $is_exclude_admin): bool => $this->is_exclude_admin($is_exclude_admin)); | |
| 26 | 27 | } |
| 27 | 28 | } |
| 28 | - public function get_name() : string | |
| 29 | + public function get_name(): string | |
| 29 | 30 | { |
| 30 | 31 | return 'elementor'; |
| 31 | 32 | } |
| 32 | - public function is_enabled() : bool | |
| 33 | + public function is_enabled(): bool | |
| 33 | 34 | { |
| 34 | - return (bool) \apply_filters('f!windpress/integration/elementor:enabled', Config::get(\sprintf('integration.%s.enabled', $this->get_name()), \true)); | |
| 35 | + return (bool) apply_filters('f!windpress/integration/elementor:enabled', Config::get(sprintf('integration.%s.enabled', $this->get_name()), \true)); | |
| 35 | 36 | } |
| 36 | - public function register_provider(array $providers) : array | |
| 37 | + public function register_provider(array $providers): array | |
| 37 | 38 | { |
| 38 | - $providers[] = ['id' => $this->get_name(), 'name' => 'Elementor', 'description' => 'Elementor integration', 'callback' => \WindPress\WindPress\Integration\Elementor\Compile::class, 'enabled' => $this->is_enabled()]; | |
| 39 | + $providers[] = ['id' => $this->get_name(), 'name' => __('Elementor', 'windpress'), 'description' => __('Elementor integration', 'windpress'), 'source_index' => 1, 'callback' => Config::get(sprintf('integration.%s.compile.enabled', $this->get_name()), \true) ? \WindPress\WindPress\Integration\Elementor\Compile::class : static fn() => [], 'enabled' => $this->is_enabled(), 'type' => 'plugin', 'homepage' => 'https://be.elementor.com/visit/?bta=209150&brand=elementor', 'is_installed_active' => static function () { | |
| 40 | + $is = -1; | |
| 41 | + $is += Common::is_plugin_installed('Elementor') ? 1 : 0; | |
| 42 | + $is += Common::is_plugin_active_by_name('Elementor') ? 1 : 0; | |
| 43 | + return $is; | |
| 44 | + }]; | |
| 39 | 45 | return $providers; |
| 40 | 46 | } |
| 41 | - public function is_exclude_admin(bool $is_exclude_admin) : bool | |
| 47 | + public function is_exclude_admin(bool $is_exclude_admin): bool | |
| 42 | 48 | { |
| 43 | 49 | if ($is_exclude_admin || !$this->is_preview()) { |
| 44 | 50 | return $is_exclude_admin; |
| 45 | 51 | } |
| @@ -44,9 +50,9 @@ | ||
| 44 | 50 | return $is_exclude_admin; |
| 45 | 51 | } |
| 46 | 52 | return $this->is_preview(); |
| 47 | 53 | } |
| 48 | - public function is_preview() : bool | |
| 54 | + public function is_preview(): bool | |
| 49 | 55 | { |
| 50 | 56 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This is not a form submission |
| 51 | 57 | return isset($_GET['elementor-preview']) && $_GET['elementor-preview']; |
| 52 | 58 | } |