| @@ -10,12 +10,10 @@ | ||
| 10 | 10 | */ |
| 11 | 11 | declare (strict_types=1); |
| 12 | 12 | namespace WindPress\WindPress\Api\Admin; |
| 13 | 13 | |
| 14 | -use WIND_PRESS; | |
| 15 | 14 | use WindPress\WindPress\Api\AbstractApi; |
| 16 | 15 | use WindPress\WindPress\Api\ApiInterface; |
| 17 | -use WindPress\WindPress\Utils\Common; | |
| 18 | 16 | use WP_REST_Request; |
| 19 | 17 | use WP_REST_Response; |
| 20 | 18 | use WP_REST_Server; |
| 21 | 19 | class Tailwind extends AbstractApi implements ApiInterface |
| @@ -22,38 +20,19 @@ | ||
| 22 | 20 | { |
| 23 | 21 | public function __construct() |
| 24 | 22 | { |
| 25 | 23 | } |
| 26 | - public function get_prefix() : string | |
| 24 | + public function get_prefix(): string | |
| 27 | 25 | { |
| 28 | 26 | return 'admin/tailwind'; |
| 29 | 27 | } |
| 30 | - public function register_custom_endpoints() : void | |
| 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( | |
| 34 | - // self::API_NAMESPACE, | |
| 35 | - // $this->get_prefix() . '/store', | |
| 36 | - // [ | |
| 37 | - // 'methods' => WP_REST_Server::CREATABLE, | |
| 38 | - // 'callback' => fn (\WP_REST_Request $wprestRequest): \WP_REST_Response => $this->store($wprestRequest), | |
| 39 | - // 'permission_callback' => fn (\WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest), | |
| 40 | - // ] | |
| 41 | - // ); | |
| 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)]); | |
| 42 | 31 | } |
| 43 | - public function index(WP_REST_Request $wprestRequest) : WP_REST_Response | |
| 32 | + public function index(WP_REST_Request $wprestRequest): WP_REST_Response | |
| 44 | 33 | { |
| 45 | 34 | $tailwind_data = ['wizard' => null]; |
| 46 | - $tailwind_data = \apply_filters('f!windpress/api/admin/tailwind:index', \json_decode(\wp_json_encode($tailwind_data))); | |
| 35 | + $tailwind_data = apply_filters('f!windpress/api/admin/tailwind:index', json_decode(wp_json_encode($tailwind_data))); | |
| 47 | 36 | return new WP_REST_Response(['tailwind' => $tailwind_data]); |
| 48 | 37 | } |
| 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([ | |
| 56 | - // 'message' => 'data stored successfully', | |
| 57 | - // ]); | |
| 58 | - // } | |
| 59 | 38 | } |