PluginProbe
WindPress – Tailwind CSS integration for WordPress / trunk
WindPress – Tailwind CSS integration for WordPress vtrunk
3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 All 142 releases
windpress / src / Integration / Elementor / Main.php

Main.php in WindPress – Tailwind CSS integration for WordPress trunk, at src/Integration/Elementor/Main.php

60 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Elementor;
13
14 use WindPress\WindPress\Integration\IntegrationInterface;
15 use WindPress\WindPress\Utils\Common;
16 use WindPress\WindPress\Utils\Config;
17 /**
18 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
19 */
20 class Main implements IntegrationInterface
21 {
22 public function __construct()
23 {
24 add_filter('f!windpress/core/cache:compile.providers', fn(array $providers): array => $this->register_provider($providers));
25 if ($this->is_enabled()) {
26 add_filter('f!windpress/core/runtime:append_header.exclude_admin', fn(bool $is_exclude_admin): bool => $this->is_exclude_admin($is_exclude_admin));
27 }
28 }
29 public function get_name(): string
30 {
31 return 'elementor';
32 }
33 public function is_enabled(): bool
34 {
35 return (bool) apply_filters('f!windpress/integration/elementor:enabled', Config::get(sprintf('integration.%s.enabled', $this->get_name()), \true));
36 }
37 public function register_provider(array $providers): array
38 {
39 $providers[] = ['id' => $this->get_name(), 'name' => __('Elementor', 'windpress'), 'description' => __('Elementor integration', 'windpress'), '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 }];
45 return $providers;
46 }
47 public function is_exclude_admin(bool $is_exclude_admin): bool
48 {
49 if ($is_exclude_admin || !$this->is_preview()) {
50 return $is_exclude_admin;
51 }
52 return $this->is_preview();
53 }
54 public function is_preview(): bool
55 {
56 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This is not a form submission
57 return isset($_GET['elementor-preview']) && $_GET['elementor-preview'];
58 }
59 }
60