PluginProbe
The Innovative Form Builder – IvyForms / 0.8.1
The Innovative Form Builder – IvyForms v0.8.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Routes / Feedback / Feedback.php

Feedback.php in The Innovative Form Builder – IvyForms 0.8.1, at backend/src/Routes/Feedback/Feedback.php

64 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Routes\Feedback;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Vendor\DI\Container;
11 use IvyForms\Vendor\DI\DependencyException;
12 use IvyForms\Vendor\DI\NotFoundException;
13 use IvyForms\Controllers\Deactivation\SubmitDeactivationFeedbackController;
14 use WP_REST_Server;
15
16 /**
17 * Class Feedback
18 *
19 * @package IvyForms\Routes\Feedback
20 */
21 class Feedback
22 {
23 /**
24 * @throws DependencyException
25 * @throws NotFoundException
26 */
27 public static function registerRoutes(Container $container, string $routeNamespace): void
28 {
29 // Register deactivation feedback endpoint
30 register_rest_route(
31 $routeNamespace,
32 '/deactivation-feedback',
33 [
34 'methods' => WP_REST_Server::CREATABLE,
35 'callback' => $container->get(SubmitDeactivationFeedbackController::class),
36 'permission_callback' => function () {
37 // Require admin capabilities for deactivation feedback
38 return current_user_can('manage_options');
39 },
40 'args' => [
41 'api_version' => [
42 'required' => false,
43 'validate_callback' => function ($param) {
44 return is_string($param);
45 }
46 ],
47 'feedback_key' => [
48 'required' => true,
49 'validate_callback' => function ($param) {
50 return is_string($param) && !empty($param);
51 }
52 ],
53 'feedback' => [
54 'required' => false,
55 'validate_callback' => function ($param) {
56 return is_string($param);
57 }
58 ]
59 ]
60 ]
61 );
62 }
63 }
64