PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.89
WindPress – Tailwind CSS integration for WordPress v3.2.89
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 / Api / Admin / ThemeJson.php

ThemeJson.php in WindPress – Tailwind CSS integration for WordPress 3.2.89, at src/Api/Admin/ThemeJson.php

41 lines 1.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\Api\Admin;
13
14 use WindPress\WindPress\Api\AbstractApi;
15 use WindPress\WindPress\Api\ApiInterface;
16 use WindPress\WindPress\Core\Cache as CoreCache;
17 use WP_REST_Request;
18 use WP_REST_Response;
19 use WP_REST_Server;
20 class ThemeJson extends AbstractApi implements ApiInterface
21 {
22 public function __construct()
23 {
24 }
25 public function get_prefix(): string
26 {
27 return 'admin/theme-json';
28 }
29 public function register_custom_endpoints(): void
30 {
31 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)]);
32 }
33 public function store(WP_REST_Request $wprestRequest): WP_REST_Response
34 {
35 $payload = $wprestRequest->get_json_params();
36 $themeJsonBlob = base64_decode($payload['data'] ?? '');
37 CoreCache::save_theme_json($themeJsonBlob);
38 return new WP_REST_Response(['message' => __('data stored successfully', 'windpress')]);
39 }
40 }
41