PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/API/Route/Routes.php +19 -129 1.42.15.3 View file →
@@ -1,177 +1,67 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\API\Route;
4 4
5 +use BitCode\BitForm\API\Controller\EntryController;
5 6 use WP_REST_Controller;
6 7 use WP_REST_Server;
7 -use BitCode\BitForm\API\Controller\EntryController;
8 -use BitCode\BitForm\API\Controller\NoteController;
9 8
10 -
11 9 class Routes extends WP_REST_Controller
12 10 {
13 - function __construct()
11 + private $entryController;
12 +
13 + protected $namespace;
14 +
15 + protected $rest_base;
16 +
17 + public function __construct()
14 18 {
15 19 $this->namespace = 'bitform';
16 20 $this->rest_base = 'v1';
17 21 $this->entryController = new EntryController();
18 - $this->noteController = new NoteController();
19 22 }
20 23
21 24 public function register_routes()
22 25 {
23 - /* form routes */
26 + /* google sheet route */
24 27 register_rest_route(
25 28 $this->namespace,
26 - $this->rest_base . '/forms/',
29 + $this->rest_base . '/google/',
27 30 [
28 31 [
29 32 'methods' => WP_REST_Server::READABLE,
30 - 'callback' => [$this->entryController, 'get_forms'],
31 - 'permission_callback' => array($this, 'get_items_permissions_check'),
32 - ],
33 - 'schema' => [$this, 'get_item_schema']
34 - ]
35 - );
36 - register_rest_route(
37 - $this->namespace,
38 - $this->rest_base . '/fields/(?P<form_id>[\d]+)',
39 - [
40 - [
41 - 'methods' => WP_REST_Server::READABLE,
42 - 'callback' => [$this->entryController, 'get_fields'],
43 - 'permission_callback' => [$this, 'get_items_permissions_check']
33 + 'callback' => [$this->entryController, 'googleAuth'],
34 + 'permission_callback' => '__return_true'
44 35 ]
45 - ]
46 - );
47 - /* form routes*/
48 36
49 - /* entry routes*/
50 - register_rest_route(
51 - $this->namespace,
52 - $this->rest_base . '/entry/(?P<form_id>[\d]+)',
53 - [
54 - [
55 - 'methods' => WP_REST_Server::CREATABLE,
56 - 'callback' => [$this->entryController, 'entry_store'],
57 - 'permission_callback' => [$this, 'get_items_permissions_check']
58 - ]
59 37 ]
60 38 );
39 + // oneDrive rest route
61 40 register_rest_route(
62 41 $this->namespace,
63 - $this->rest_base . '/form/response/(?P<id>[\d]+)',
42 + $this->rest_base . '/oneDrive/',
64 43 [
65 44 [
66 45 'methods' => WP_REST_Server::READABLE,
67 - 'callback' => [$this->entryController, 'getEntryResponse'],
68 - 'permission_callback' => [$this, 'get_items_permissions_check']
46 + 'callback' => [$this->entryController, 'oneDriveAuth'],
47 + 'permission_callback' => '__return_true'
69 48 ]
70 - ]
71 - );
72 - register_rest_route(
73 - $this->namespace,
74 - $this->rest_base . '/entry/(?P<entry_id>[\d]+)',
75 - [
76 - [
77 - 'methods' => WP_REST_Server::READABLE,
78 - 'callback' => [$this->entryController, 'entry_view'],
79 - 'permission_callback' => [$this, 'get_items_permissions_check']
80 49
81 - ],
82 - [
83 - 'methods' => WP_REST_Server::DELETABLE,
84 - 'callback' => [$this->entryController, 'entry_delete'],
85 - 'permission_callback' => [$this, 'get_items_permissions_check']
86 - ]
87 50 ]
88 51 );
89 52
53 + // zoho
90 54 register_rest_route(
91 55 $this->namespace,
92 - $this->rest_base . '/entry_update/(?P<entry_id>[\d]+)/',
56 + $this->rest_base . '/zoho/',
93 57 [
94 58 [
95 - 'methods' => WP_REST_Server::EDITABLE,
96 - 'callback' => [$this->entryController, 'entry_update'],
97 - 'permission_callback' => [$this, 'get_items_permissions_check']
98 - ]
99 - ]
100 - );
101 - /* entry routes*/
102 -
103 - /* note routes*/
104 - register_rest_route(
105 - $this->namespace,
106 - $this->rest_base . '/notes/',
107 - [
108 - [
109 59 'methods' => WP_REST_Server::READABLE,
110 - 'callback' => [$this->noteController, 'get_notes'],
111 - 'permission_callback' => [$this, 'get_items_permissions_check']
112 - ]
113 - ]
114 - );
115 - register_rest_route(
116 - $this->namespace,
117 - $this->rest_base . '/create-note/',
118 - [
119 - [
120 - 'methods' => WP_REST_Server::CREATABLE,
121 - 'callback' => [$this->noteController, 'create_note'],
122 - 'permission_callback' => [$this, 'get_items_permissions_check']
123 - ]
124 - ]
125 - );
126 - register_rest_route(
127 - $this->namespace,
128 - $this->rest_base . '/note/(?P<id>[\d]+)',
129 - [
130 - [
131 - 'methods' => WP_REST_Server::READABLE,
132 - 'callback' => [$this->noteController, 'note_edit'],
133 - 'permission_callback' => [$this, 'get_items_permissions_check'],
134 - 'args' => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE),
135 - ],
136 - [
137 - 'methods' => WP_REST_Server::EDITABLE,
138 - 'callback' => [$this->noteController, 'note_update'],
139 - 'permission_callback' => [$this, 'get_items_permissions_check']
140 - ],
141 - [
142 - 'methods' => WP_REST_Server::DELETABLE,
143 - 'callback' => [$this->noteController, 'note_delete'],
144 - 'permission_callback' => [$this, 'get_items_permissions_check']
145 - ]
146 - ]
147 - );
148 - /* note routes*/
149 -
150 - /* google sheet route */
151 - register_rest_route(
152 - $this->namespace,
153 - $this->rest_base . '/google/',
154 - [
155 - [
156 - 'methods' => WP_REST_Server::READABLE,
157 - 'callback' => [$this->entryController, 'googleAuth'],
60 + 'callback' => [$this->entryController, 'authRedirect'],
158 61 'permission_callback' => '__return_true'
159 62 ]
160 63
161 64 ]
162 65 );
163 - }
164 - public function get_items_permissions_check($request)
165 - {
166 - $api_key = get_option('bitform_secret_api_key');
167 - $header = $request->get_header('Bitform-Api-Key');
168 - if (empty($header)) {
169 - $error = ['message' => 'Api Key is required to access this resource'];
170 - return wp_send_json_error($error, 401);
171 - } else if ($request->get_header('Bitform-Api-Key') != $api_key || $api_key == null) {
172 - $error = ['message' => 'Invalid API key'];
173 - return wp_send_json_error($error, 401);
174 - }
175 - return true;
176 66 }
177 67 }