PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.90
WindPress – Tailwind CSS integration for WordPress v3.2.90
3.2.90 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 All 144 releases
← All changes | src/Api/Admin/Tailwind.php +5 -24 3.0.23.2.90 View file →
@@ -10,15 +10,13 @@
10 10 */
11 11 declare (strict_types=1);
12 12 namespace WindPress\WindPress\Api\Admin;
13 13
14 -use WIND_PRESS;
14 +use WindPress\WindPress\Api\AbstractApi;
15 +use WindPress\WindPress\Api\ApiInterface;
15 16 use WP_REST_Request;
16 17 use WP_REST_Response;
17 18 use WP_REST_Server;
18 -use WindPress\WindPress\Api\AbstractApi;
19 -use WindPress\WindPress\Api\ApiInterface;
20 -use WindPress\WindPress\Utils\Common;
21 19 class Tailwind extends AbstractApi implements ApiInterface
22 20 {
23 21 public function __construct()
24 22 {
@@ -28,30 +26,13 @@
28 26 return 'admin/tailwind';
29 27 }
30 28 public function register_custom_endpoints(): void
31 29 {
32 - register_rest_route(self::API_NAMESPACE, $this->get_prefix() . '/index', ['methods' => WP_REST_Server::READABLE, 'callback' => fn(\WP_REST_Request $wprestRequest): \WP_REST_Response => $this->index($wprestRequest), 'permission_callback' => fn(\WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest)]);
33 - register_rest_route(self::API_NAMESPACE, $this->get_prefix() . '/store', ['methods' => WP_REST_Server::CREATABLE, 'callback' => fn(\WP_REST_Request $wprestRequest): \WP_REST_Response => $this->store($wprestRequest), 'permission_callback' => fn(\WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest)]);
30 + register_rest_route(self::API_NAMESPACE, $this->get_prefix() . '/index', ['methods' => WP_REST_Server::READABLE, 'callback' => fn(WP_REST_Request $wprestRequest): WP_REST_Response => $this->index($wprestRequest), 'permission_callback' => fn(WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest)]);
34 31 }
35 32 public function index(WP_REST_Request $wprestRequest): WP_REST_Response
36 33 {
37 - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local file
38 - $stub_main_css = file_get_contents(dirname(WIND_PRESS::FILE) . '/stubs/main.css');
39 - $main_css = $stub_main_css;
40 - $main_css_path = wp_upload_dir()['basedir'] . WIND_PRESS::DATA_DIR . 'main.css';
41 - if (file_exists($main_css_path)) {
42 - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local file
43 - $main_css = file_get_contents($main_css_path);
44 - }
45 - $tailwind_data = ['main_css' => $main_css, '_main_css' => $stub_main_css, 'wizard' => null];
34 + $tailwind_data = ['wizard' => null];
46 35 $tailwind_data = apply_filters('f!windpress/api/admin/tailwind:index', json_decode(wp_json_encode($tailwind_data)));
47 - return new WP_REST_Response(['tailwind' => $tailwind_data, '_custom' => ['main_css' => ['prepend' => apply_filters('f!windpress/core/runtime:main_css.prepend', ''), 'append' => apply_filters('f!windpress/core/runtime:main_css.append', '')]]]);
48 - }
49 - public function store(WP_REST_Request $wprestRequest): WP_REST_Response
50 - {
51 - $payload = $wprestRequest->get_json_params();
52 - $main_css = $payload['tailwind']['main_css'];
53 - $main_css_path = wp_upload_dir()['basedir'] . WIND_PRESS::DATA_DIR . 'main.css';
54 - Common::save_file($main_css, $main_css_path);
55 - return new WP_REST_Response(['message' => 'data stored successfully']);
36 + return new WP_REST_Response(['tailwind' => $tailwind_data]);
56 37 }
57 38 }