@@ -17,495 +17,495 @@ |
||
17 | 17 | class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * $_COOKIE parameters |
|
22 | - * |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected $cookies; |
|
26 | - |
|
27 | - /** |
|
28 | - * $_FILES parameters |
|
29 | - * |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $files; |
|
33 | - |
|
34 | - /** |
|
35 | - * true if current user appears to be some kind of bot |
|
36 | - * |
|
37 | - * @var bool |
|
38 | - */ |
|
39 | - protected $is_bot; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var RequestParams |
|
43 | - */ |
|
44 | - protected $request_params; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var RequestTypeContextCheckerInterface |
|
48 | - */ |
|
49 | - protected $request_type; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var ServerParams |
|
53 | - */ |
|
54 | - protected $server_params; |
|
55 | - |
|
56 | - |
|
57 | - public function __construct( |
|
58 | - RequestParams $request_params, |
|
59 | - ServerParams $server_params, |
|
60 | - array $cookies = [], |
|
61 | - array $files = [] |
|
62 | - ) { |
|
63 | - $this->cookies = ! empty($cookies) |
|
64 | - ? $cookies |
|
65 | - : filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING); |
|
66 | - $this->files = ! empty($files) ? $files : $_FILES; |
|
67 | - $this->request_params = $request_params; |
|
68 | - $this->server_params = $server_params; |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @param RequestTypeContextCheckerInterface $type |
|
74 | - */ |
|
75 | - public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type) |
|
76 | - { |
|
77 | - $this->request_type = $type; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @return array |
|
83 | - */ |
|
84 | - public function getParams() |
|
85 | - { |
|
86 | - return $this->request_params->getParams(); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - public function postParams() |
|
94 | - { |
|
95 | - return $this->request_params->postParams(); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function cookieParams() |
|
103 | - { |
|
104 | - return $this->cookies; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return array |
|
110 | - */ |
|
111 | - public function serverParams() |
|
112 | - { |
|
113 | - return $this->server_params->getAllServerParams(); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @param string $key |
|
119 | - * @param mixed|null $default |
|
120 | - * @return array|int|float|string |
|
121 | - */ |
|
122 | - public function getServerParam($key, $default = null) |
|
123 | - { |
|
124 | - return $this->server_params->getServerParam($key, $default); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @param string $key |
|
130 | - * @param array|int|float|string $value |
|
131 | - * @return void |
|
132 | - */ |
|
133 | - public function setServerParam($key, $value) |
|
134 | - { |
|
135 | - $this->server_params->setServerParam($key, $value); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @param string $key |
|
141 | - * @return bool |
|
142 | - */ |
|
143 | - public function serverParamIsSet($key) |
|
144 | - { |
|
145 | - return $this->server_params->serverParamIsSet($key); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * @return array |
|
151 | - */ |
|
152 | - public function filesParams() |
|
153 | - { |
|
154 | - return $this->files; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * returns sanitized contents of $_REQUEST |
|
160 | - * |
|
161 | - * @return array |
|
162 | - */ |
|
163 | - public function requestParams() |
|
164 | - { |
|
165 | - return $this->request_params->requestParams(); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @param string $key |
|
171 | - * @param mixed|null $value |
|
172 | - * @param bool $override_ee |
|
173 | - * @return void |
|
174 | - */ |
|
175 | - public function setRequestParam($key, $value, $override_ee = false) |
|
176 | - { |
|
177 | - $this->request_params->setRequestParam($key, $value, $override_ee); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * merges the incoming array of parameters into the existing request parameters |
|
183 | - * |
|
184 | - * @param array $request_params |
|
185 | - * @return void |
|
186 | - * @since 4.10.24.p |
|
187 | - */ |
|
188 | - public function mergeRequestParams(array $request_params) |
|
189 | - { |
|
190 | - $this->request_params->mergeRequestParams($request_params); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * returns sanitized value for a request param if the given key exists |
|
196 | - * |
|
197 | - * @param string $key |
|
198 | - * @param mixed|null $default |
|
199 | - * @param string $type the expected data type for the parameter's value, ie: string, int, bool, etc |
|
200 | - * @param bool $is_array if true, then parameter value will be treated as an array of $type |
|
201 | - * @param string $delimiter for CSV type strings that should be returned as an array |
|
202 | - * @return array|bool|float|int|string |
|
203 | - */ |
|
204 | - public function getRequestParam($key, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '') |
|
205 | - { |
|
206 | - return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter); |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * check if param exists |
|
212 | - * |
|
213 | - * @param string $key |
|
214 | - * @return bool |
|
215 | - */ |
|
216 | - public function requestParamIsSet($key) |
|
217 | - { |
|
218 | - return $this->request_params->requestParamIsSet($key); |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
224 | - * and return the sanitized value for the first match found |
|
225 | - * wildcards can be either of the following: |
|
226 | - * ? to represent a single character of any type |
|
227 | - * * to represent one or more characters of any type |
|
228 | - * |
|
229 | - * @param string $pattern |
|
230 | - * @param mixed|null $default |
|
231 | - * @param string $type the expected data type for the parameter's value, ie: string, int, bool, etc |
|
232 | - * @param bool $is_array if true, then parameter value will be treated as an array of $type |
|
233 | - * @param string $delimiter for CSV type strings that should be returned as an array |
|
234 | - * @return array|bool|float|int|string |
|
235 | - */ |
|
236 | - public function getMatch($pattern, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '') |
|
237 | - { |
|
238 | - return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter); |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
244 | - * wildcards can be either of the following: |
|
245 | - * ? to represent a single character of any type |
|
246 | - * * to represent one or more characters of any type |
|
247 | - * returns true if a match is found or false if not |
|
248 | - * |
|
249 | - * @param string $pattern |
|
250 | - * @return bool |
|
251 | - */ |
|
252 | - public function matches($pattern) |
|
253 | - { |
|
254 | - return $this->request_params->matches($pattern); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * remove param |
|
260 | - * |
|
261 | - * @param $key |
|
262 | - * @param bool $unset_from_global_too |
|
263 | - */ |
|
264 | - public function unSetRequestParam($key, $unset_from_global_too = false) |
|
265 | - { |
|
266 | - $this->request_params->unSetRequestParam($key, $unset_from_global_too); |
|
267 | - } |
|
268 | - |
|
269 | - |
|
270 | - /** |
|
271 | - * remove params |
|
272 | - * |
|
273 | - * @param array $keys |
|
274 | - * @param bool $unset_from_global_too |
|
275 | - */ |
|
276 | - public function unSetRequestParams(array $keys, $unset_from_global_too = false) |
|
277 | - { |
|
278 | - $this->request_params->unSetRequestParams($keys, $unset_from_global_too); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * @return string |
|
284 | - */ |
|
285 | - public function ipAddress() |
|
286 | - { |
|
287 | - return $this->server_params->ipAddress(); |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison. |
|
293 | - * |
|
294 | - * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to |
|
295 | - * "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return |
|
296 | - * "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/". |
|
297 | - * @return string |
|
298 | - */ |
|
299 | - public function requestUri($relativeToWpRoot = false) |
|
300 | - { |
|
301 | - return $this->server_params->requestUri($relativeToWpRoot); |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - public function userAgent() |
|
309 | - { |
|
310 | - return $this->server_params->userAgent(); |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * @param string $user_agent |
|
316 | - */ |
|
317 | - public function setUserAgent($user_agent = '') |
|
318 | - { |
|
319 | - $this->server_params->setUserAgent($user_agent); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * @return bool |
|
325 | - */ |
|
326 | - public function isBot() |
|
327 | - { |
|
328 | - return $this->is_bot; |
|
329 | - } |
|
330 | - |
|
331 | - |
|
332 | - /** |
|
333 | - * @param bool $is_bot |
|
334 | - */ |
|
335 | - public function setIsBot($is_bot) |
|
336 | - { |
|
337 | - $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN); |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * @return bool |
|
343 | - */ |
|
344 | - public function isActivation() |
|
345 | - { |
|
346 | - return $this->request_type->isActivation(); |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * @param $is_activation |
|
352 | - * @return bool |
|
353 | - */ |
|
354 | - public function setIsActivation($is_activation) |
|
355 | - { |
|
356 | - return $this->request_type->setIsActivation($is_activation); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * @return bool |
|
362 | - */ |
|
363 | - public function isAdmin() |
|
364 | - { |
|
365 | - return $this->request_type->isAdmin(); |
|
366 | - } |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * @return bool |
|
371 | - */ |
|
372 | - public function isAdminAjax() |
|
373 | - { |
|
374 | - return $this->request_type->isAdminAjax(); |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * @return bool |
|
380 | - */ |
|
381 | - public function isAjax() |
|
382 | - { |
|
383 | - return $this->request_type->isAjax(); |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * @return bool |
|
389 | - */ |
|
390 | - public function isEeAjax() |
|
391 | - { |
|
392 | - return $this->request_type->isEeAjax(); |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * @return bool |
|
398 | - */ |
|
399 | - public function isOtherAjax() |
|
400 | - { |
|
401 | - return $this->request_type->isOtherAjax(); |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * @return bool |
|
407 | - */ |
|
408 | - public function isApi() |
|
409 | - { |
|
410 | - return $this->request_type->isApi(); |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * @return bool |
|
416 | - */ |
|
417 | - public function isCli() |
|
418 | - { |
|
419 | - return $this->request_type->isCli(); |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - /** |
|
424 | - * @return bool |
|
425 | - */ |
|
426 | - public function isCron() |
|
427 | - { |
|
428 | - return $this->request_type->isCron(); |
|
429 | - } |
|
430 | - |
|
431 | - |
|
432 | - /** |
|
433 | - * @return bool |
|
434 | - */ |
|
435 | - public function isFeed() |
|
436 | - { |
|
437 | - return $this->request_type->isFeed(); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * @return bool |
|
443 | - */ |
|
444 | - public function isFrontend() |
|
445 | - { |
|
446 | - return $this->request_type->isFrontend(); |
|
447 | - } |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * @return bool |
|
452 | - */ |
|
453 | - public function isFrontAjax() |
|
454 | - { |
|
455 | - return $this->request_type->isFrontAjax(); |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * @return bool |
|
461 | - */ |
|
462 | - public function isIframe() |
|
463 | - { |
|
464 | - return $this->request_type->isIframe(); |
|
465 | - } |
|
466 | - |
|
467 | - |
|
468 | - /** |
|
469 | - * @return bool |
|
470 | - */ |
|
471 | - public function isWordPressApi() |
|
472 | - { |
|
473 | - return $this->request_type->isWordPressApi(); |
|
474 | - } |
|
475 | - |
|
476 | - |
|
477 | - /** |
|
478 | - * @return bool |
|
479 | - */ |
|
480 | - public function isWordPressHeartbeat() |
|
481 | - { |
|
482 | - return $this->request_type->isWordPressHeartbeat(); |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - /** |
|
487 | - * @return bool |
|
488 | - */ |
|
489 | - public function isWordPressScrape() |
|
490 | - { |
|
491 | - return $this->request_type->isWordPressScrape(); |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - /** |
|
496 | - * @return string |
|
497 | - */ |
|
498 | - public function slug() |
|
499 | - { |
|
500 | - return $this->request_type->slug(); |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * @return RequestTypeContextCheckerInterface |
|
506 | - */ |
|
507 | - public function getRequestType() |
|
508 | - { |
|
509 | - return $this->request_type; |
|
510 | - } |
|
20 | + /** |
|
21 | + * $_COOKIE parameters |
|
22 | + * |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected $cookies; |
|
26 | + |
|
27 | + /** |
|
28 | + * $_FILES parameters |
|
29 | + * |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $files; |
|
33 | + |
|
34 | + /** |
|
35 | + * true if current user appears to be some kind of bot |
|
36 | + * |
|
37 | + * @var bool |
|
38 | + */ |
|
39 | + protected $is_bot; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var RequestParams |
|
43 | + */ |
|
44 | + protected $request_params; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var RequestTypeContextCheckerInterface |
|
48 | + */ |
|
49 | + protected $request_type; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var ServerParams |
|
53 | + */ |
|
54 | + protected $server_params; |
|
55 | + |
|
56 | + |
|
57 | + public function __construct( |
|
58 | + RequestParams $request_params, |
|
59 | + ServerParams $server_params, |
|
60 | + array $cookies = [], |
|
61 | + array $files = [] |
|
62 | + ) { |
|
63 | + $this->cookies = ! empty($cookies) |
|
64 | + ? $cookies |
|
65 | + : filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING); |
|
66 | + $this->files = ! empty($files) ? $files : $_FILES; |
|
67 | + $this->request_params = $request_params; |
|
68 | + $this->server_params = $server_params; |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @param RequestTypeContextCheckerInterface $type |
|
74 | + */ |
|
75 | + public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type) |
|
76 | + { |
|
77 | + $this->request_type = $type; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @return array |
|
83 | + */ |
|
84 | + public function getParams() |
|
85 | + { |
|
86 | + return $this->request_params->getParams(); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + public function postParams() |
|
94 | + { |
|
95 | + return $this->request_params->postParams(); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function cookieParams() |
|
103 | + { |
|
104 | + return $this->cookies; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return array |
|
110 | + */ |
|
111 | + public function serverParams() |
|
112 | + { |
|
113 | + return $this->server_params->getAllServerParams(); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @param string $key |
|
119 | + * @param mixed|null $default |
|
120 | + * @return array|int|float|string |
|
121 | + */ |
|
122 | + public function getServerParam($key, $default = null) |
|
123 | + { |
|
124 | + return $this->server_params->getServerParam($key, $default); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @param string $key |
|
130 | + * @param array|int|float|string $value |
|
131 | + * @return void |
|
132 | + */ |
|
133 | + public function setServerParam($key, $value) |
|
134 | + { |
|
135 | + $this->server_params->setServerParam($key, $value); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @param string $key |
|
141 | + * @return bool |
|
142 | + */ |
|
143 | + public function serverParamIsSet($key) |
|
144 | + { |
|
145 | + return $this->server_params->serverParamIsSet($key); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * @return array |
|
151 | + */ |
|
152 | + public function filesParams() |
|
153 | + { |
|
154 | + return $this->files; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * returns sanitized contents of $_REQUEST |
|
160 | + * |
|
161 | + * @return array |
|
162 | + */ |
|
163 | + public function requestParams() |
|
164 | + { |
|
165 | + return $this->request_params->requestParams(); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @param string $key |
|
171 | + * @param mixed|null $value |
|
172 | + * @param bool $override_ee |
|
173 | + * @return void |
|
174 | + */ |
|
175 | + public function setRequestParam($key, $value, $override_ee = false) |
|
176 | + { |
|
177 | + $this->request_params->setRequestParam($key, $value, $override_ee); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * merges the incoming array of parameters into the existing request parameters |
|
183 | + * |
|
184 | + * @param array $request_params |
|
185 | + * @return void |
|
186 | + * @since 4.10.24.p |
|
187 | + */ |
|
188 | + public function mergeRequestParams(array $request_params) |
|
189 | + { |
|
190 | + $this->request_params->mergeRequestParams($request_params); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * returns sanitized value for a request param if the given key exists |
|
196 | + * |
|
197 | + * @param string $key |
|
198 | + * @param mixed|null $default |
|
199 | + * @param string $type the expected data type for the parameter's value, ie: string, int, bool, etc |
|
200 | + * @param bool $is_array if true, then parameter value will be treated as an array of $type |
|
201 | + * @param string $delimiter for CSV type strings that should be returned as an array |
|
202 | + * @return array|bool|float|int|string |
|
203 | + */ |
|
204 | + public function getRequestParam($key, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '') |
|
205 | + { |
|
206 | + return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter); |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * check if param exists |
|
212 | + * |
|
213 | + * @param string $key |
|
214 | + * @return bool |
|
215 | + */ |
|
216 | + public function requestParamIsSet($key) |
|
217 | + { |
|
218 | + return $this->request_params->requestParamIsSet($key); |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
224 | + * and return the sanitized value for the first match found |
|
225 | + * wildcards can be either of the following: |
|
226 | + * ? to represent a single character of any type |
|
227 | + * * to represent one or more characters of any type |
|
228 | + * |
|
229 | + * @param string $pattern |
|
230 | + * @param mixed|null $default |
|
231 | + * @param string $type the expected data type for the parameter's value, ie: string, int, bool, etc |
|
232 | + * @param bool $is_array if true, then parameter value will be treated as an array of $type |
|
233 | + * @param string $delimiter for CSV type strings that should be returned as an array |
|
234 | + * @return array|bool|float|int|string |
|
235 | + */ |
|
236 | + public function getMatch($pattern, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '') |
|
237 | + { |
|
238 | + return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter); |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
244 | + * wildcards can be either of the following: |
|
245 | + * ? to represent a single character of any type |
|
246 | + * * to represent one or more characters of any type |
|
247 | + * returns true if a match is found or false if not |
|
248 | + * |
|
249 | + * @param string $pattern |
|
250 | + * @return bool |
|
251 | + */ |
|
252 | + public function matches($pattern) |
|
253 | + { |
|
254 | + return $this->request_params->matches($pattern); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * remove param |
|
260 | + * |
|
261 | + * @param $key |
|
262 | + * @param bool $unset_from_global_too |
|
263 | + */ |
|
264 | + public function unSetRequestParam($key, $unset_from_global_too = false) |
|
265 | + { |
|
266 | + $this->request_params->unSetRequestParam($key, $unset_from_global_too); |
|
267 | + } |
|
268 | + |
|
269 | + |
|
270 | + /** |
|
271 | + * remove params |
|
272 | + * |
|
273 | + * @param array $keys |
|
274 | + * @param bool $unset_from_global_too |
|
275 | + */ |
|
276 | + public function unSetRequestParams(array $keys, $unset_from_global_too = false) |
|
277 | + { |
|
278 | + $this->request_params->unSetRequestParams($keys, $unset_from_global_too); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * @return string |
|
284 | + */ |
|
285 | + public function ipAddress() |
|
286 | + { |
|
287 | + return $this->server_params->ipAddress(); |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison. |
|
293 | + * |
|
294 | + * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to |
|
295 | + * "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return |
|
296 | + * "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/". |
|
297 | + * @return string |
|
298 | + */ |
|
299 | + public function requestUri($relativeToWpRoot = false) |
|
300 | + { |
|
301 | + return $this->server_params->requestUri($relativeToWpRoot); |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + public function userAgent() |
|
309 | + { |
|
310 | + return $this->server_params->userAgent(); |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * @param string $user_agent |
|
316 | + */ |
|
317 | + public function setUserAgent($user_agent = '') |
|
318 | + { |
|
319 | + $this->server_params->setUserAgent($user_agent); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * @return bool |
|
325 | + */ |
|
326 | + public function isBot() |
|
327 | + { |
|
328 | + return $this->is_bot; |
|
329 | + } |
|
330 | + |
|
331 | + |
|
332 | + /** |
|
333 | + * @param bool $is_bot |
|
334 | + */ |
|
335 | + public function setIsBot($is_bot) |
|
336 | + { |
|
337 | + $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN); |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * @return bool |
|
343 | + */ |
|
344 | + public function isActivation() |
|
345 | + { |
|
346 | + return $this->request_type->isActivation(); |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * @param $is_activation |
|
352 | + * @return bool |
|
353 | + */ |
|
354 | + public function setIsActivation($is_activation) |
|
355 | + { |
|
356 | + return $this->request_type->setIsActivation($is_activation); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * @return bool |
|
362 | + */ |
|
363 | + public function isAdmin() |
|
364 | + { |
|
365 | + return $this->request_type->isAdmin(); |
|
366 | + } |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * @return bool |
|
371 | + */ |
|
372 | + public function isAdminAjax() |
|
373 | + { |
|
374 | + return $this->request_type->isAdminAjax(); |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * @return bool |
|
380 | + */ |
|
381 | + public function isAjax() |
|
382 | + { |
|
383 | + return $this->request_type->isAjax(); |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * @return bool |
|
389 | + */ |
|
390 | + public function isEeAjax() |
|
391 | + { |
|
392 | + return $this->request_type->isEeAjax(); |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * @return bool |
|
398 | + */ |
|
399 | + public function isOtherAjax() |
|
400 | + { |
|
401 | + return $this->request_type->isOtherAjax(); |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * @return bool |
|
407 | + */ |
|
408 | + public function isApi() |
|
409 | + { |
|
410 | + return $this->request_type->isApi(); |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * @return bool |
|
416 | + */ |
|
417 | + public function isCli() |
|
418 | + { |
|
419 | + return $this->request_type->isCli(); |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + /** |
|
424 | + * @return bool |
|
425 | + */ |
|
426 | + public function isCron() |
|
427 | + { |
|
428 | + return $this->request_type->isCron(); |
|
429 | + } |
|
430 | + |
|
431 | + |
|
432 | + /** |
|
433 | + * @return bool |
|
434 | + */ |
|
435 | + public function isFeed() |
|
436 | + { |
|
437 | + return $this->request_type->isFeed(); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * @return bool |
|
443 | + */ |
|
444 | + public function isFrontend() |
|
445 | + { |
|
446 | + return $this->request_type->isFrontend(); |
|
447 | + } |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * @return bool |
|
452 | + */ |
|
453 | + public function isFrontAjax() |
|
454 | + { |
|
455 | + return $this->request_type->isFrontAjax(); |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * @return bool |
|
461 | + */ |
|
462 | + public function isIframe() |
|
463 | + { |
|
464 | + return $this->request_type->isIframe(); |
|
465 | + } |
|
466 | + |
|
467 | + |
|
468 | + /** |
|
469 | + * @return bool |
|
470 | + */ |
|
471 | + public function isWordPressApi() |
|
472 | + { |
|
473 | + return $this->request_type->isWordPressApi(); |
|
474 | + } |
|
475 | + |
|
476 | + |
|
477 | + /** |
|
478 | + * @return bool |
|
479 | + */ |
|
480 | + public function isWordPressHeartbeat() |
|
481 | + { |
|
482 | + return $this->request_type->isWordPressHeartbeat(); |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + /** |
|
487 | + * @return bool |
|
488 | + */ |
|
489 | + public function isWordPressScrape() |
|
490 | + { |
|
491 | + return $this->request_type->isWordPressScrape(); |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + /** |
|
496 | + * @return string |
|
497 | + */ |
|
498 | + public function slug() |
|
499 | + { |
|
500 | + return $this->request_type->slug(); |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * @return RequestTypeContextCheckerInterface |
|
506 | + */ |
|
507 | + public function getRequestType() |
|
508 | + { |
|
509 | + return $this->request_type; |
|
510 | + } |
|
511 | 511 | } |