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
← All changes | src/Api/Admin/Volume.php +16 -8 3.0.133.2.89 View file →
@@ -21,25 +21,33 @@
21 21 {
22 22 public function __construct()
23 23 {
24 24 }
25 - public function get_prefix() : string
25 + public function get_prefix(): string
26 26 {
27 27 return 'admin/volume';
28 28 }
29 - public function register_custom_endpoints() : void
29 + public function register_custom_endpoints(): void
30 30 {
31 - \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)]);
32 - \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)]);
31 + 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)]);
32 + 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)]);
33 + register_rest_route(self::API_NAMESPACE, $this->get_prefix() . '/handlers', ['methods' => WP_REST_Server::READABLE, 'callback' => fn(WP_REST_Request $wprestRequest): WP_REST_Response => $this->handlers($wprestRequest), 'permission_callback' => fn(WP_REST_Request $wprestRequest): bool => $this->permission_callback($wprestRequest)]);
33 34 }
34 - public function index(WP_REST_Request $wprestRequest) : WP_REST_Response
35 + public function index(WP_REST_Request $wprestRequest): WP_REST_Response
35 36 {
36 37 return new WP_REST_Response(['entries' => CoreVolume::get_entries()]);
37 38 }
38 - public function store(WP_REST_Request $wprestRequest) : WP_REST_Response
39 + public function store(WP_REST_Request $wprestRequest): WP_REST_Response
39 40 {
40 41 $payload = $wprestRequest->get_json_params();
41 42 $entries = $payload['volume']['entries'];
42 - CoreVolume::save_entries($entries);
43 - return new WP_REST_Response(['message' => 'data stored successfully']);
43 + $result = CoreVolume::save_entries($entries);
44 + if (!empty($result['errors']) || !empty($result['skipped'])) {
45 + return new WP_REST_Response(['success' => \false, 'message' => __('Some entries could not be saved.', 'windpress'), 'details' => $result], empty($result['errors']) ? 400 : 500);
46 + }
47 + return new WP_REST_Response(['success' => \true, 'message' => __('data stored successfully', 'windpress')]);
48 + }
49 + public function handlers(WP_REST_Request $wprestRequest): WP_REST_Response
50 + {
51 + return new WP_REST_Response(['handlers' => CoreVolume::get_available_handlers()]);
44 52 }
45 53 }