PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.0.6
WindPress – Tailwind CSS integration for WordPress v3.0.6
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 / Gutenberg / Main.php

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

69 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\Gutenberg;
13
14 use WIND_PRESS;
15 use WindPress\WindPress\Core\Runtime;
16 use WindPress\WindPress\Integration\IntegrationInterface;
17 use WindPress\WindPress\Utils\AssetVite;
18 use WindPress\WindPress\Utils\Config;
19 /**
20 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
21 */
22 class Main implements IntegrationInterface
23 {
24 public function __construct()
25 {
26 // TODO: implement the integration
27 return;
28 \add_filter('f!windpress/core/cache:compile.providers', fn(array $providers): array => $this->register_provider($providers));
29 if ($this->is_enabled()) {
30 \add_action('enqueue_block_editor_assets', fn() => $this->enqueue_block_editor_assets());
31 }
32 }
33 public function get_name() : string
34 {
35 return 'gutenberg';
36 }
37 public function is_enabled() : bool
38 {
39 return (bool) \apply_filters('f!windpress/integration/gutenberg: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' => 'Gutenberg', 'description' => 'Gutenberg integration', 'callback' => \WindPress\WindPress\Integration\Gutenberg\Compile::class, 'enabled' => $this->is_enabled()];
44 return $providers;
45 }
46 public function enqueue_block_editor_assets()
47 {
48 $screen = \get_current_screen();
49 if (\is_admin() && $screen->is_block_editor()) {
50 \add_action('admin_head', fn() => $this->admin_head(), 1000001);
51 }
52 }
53 public function admin_head()
54 {
55 // Runtime::get_instance()->enqueue_importmap();
56 Runtime::get_instance()->enqueue_play_cdn();
57 if (\strpos($_SERVER['REQUEST_URI'], 'site-editor.php') !== \false) {
58 // wp_enqueue_script(WIND_PRESS::WP_OPTION . '-gutenberg-fse', plugin_dir_url(WIND_PRESS::FILE) . 'build/public/gutenberg/fse.js', [], WIND_PRESS::VERSION, true);
59 } else {
60 // wp_enqueue_script(WIND_PRESS::WP_OPTION . '-gutenberg-observer', plugin_dir_url(WIND_PRESS::FILE) . 'build/public/gutenberg/observer.js', [], WIND_PRESS::VERSION, true);
61 // AssetVite::get_instance()->enqueue_asset('assets/integration/gutenberg/post-editor.js', [
62 // 'handle' => WIND_PRESS::WP_OPTION . ':integration-gutenberg-post-editor',
63 // 'in-footer' => true,
64 // ]);
65 AssetVite::get_instance()->enqueue_asset('assets/integration/gutenberg/block-editor.jsx', ['handle' => WIND_PRESS::WP_OPTION . ':integration-gutenberg-block-editor', 'in-footer' => \true, 'dependencies' => ['wp-blocks', 'wp-element', 'wp-editor', 'wp-components', 'wp-i18n', 'react', 'react-dom']]);
66 }
67 }
68 }
69