PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.84
WindPress – Tailwind CSS integration for WordPress v3.2.84
3.2.89 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 All 143 releases
windpress / src / Integration / LiveCanvas / Main.php

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

68 lines 3.0 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\LiveCanvas;
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:is_prevent_load', fn(bool $is_prevent_load): bool => $this->is_prevent_load($is_prevent_load));
27 add_filter('f!windpress/core/runtime:append_header.exclude_admin', fn(bool $is_exclude_admin): bool => $this->is_exclude_admin($is_exclude_admin));
28 if (Config::get(sprintf('integration.%s.editor.enabled', $this->get_name()), \true)) {
29 new \WindPress\WindPress\Integration\LiveCanvas\Editor();
30 }
31 }
32 }
33 public function get_name(): string
34 {
35 return 'livecanvas';
36 }
37 public function is_enabled(): bool
38 {
39 return (bool) apply_filters('f!windpress/integration/livecanvas:enabled', Config::get(sprintf('integration.%s.enabled', $this->get_name()), \true));
40 }
41 public function register_provider(array $providers): array
42 {
43 $providers[] = ['id' => $this->get_name(), 'name' => __('LiveCanvas', 'windpress'), 'description' => __('LiveCanvas integration', 'windpress'), 'callback' => Config::get(sprintf('integration.%s.compile.enabled', $this->get_name()), \true) ? \WindPress\WindPress\Integration\LiveCanvas\Compile::class : static fn() => [], 'enabled' => $this->is_enabled(), 'type' => 'plugin', 'homepage' => 'https://livecanvas.com/?ref=4008', 'is_installed_active' => static function () {
44 $is = -1;
45 $is += Common::is_plugin_installed('LiveCanvas') ? 1 : 0;
46 $is += Common::is_plugin_active_by_name('LiveCanvas') ? 1 : 0;
47 return $is;
48 }, 'meta' => ['experimental' => \true]];
49 return $providers;
50 }
51 public function is_prevent_load(bool $is_prevent_load): bool
52 {
53 if ($is_prevent_load) {
54 return $is_prevent_load;
55 }
56 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This is not a form submission
57 return isset($_GET['lc_action_launch_editing']) && $_GET['lc_action_launch_editing'] === '1';
58 }
59 public function is_exclude_admin(bool $is_exclude_admin): bool
60 {
61 if ($is_exclude_admin) {
62 return $is_exclude_admin;
63 }
64 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- This is not a form submission
65 return isset($_GET['lc_page_editing_mode']) && $_GET['lc_page_editing_mode'] === '1';
66 }
67 }
68