PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.10.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.10.2
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Helpers / global / ajax.php

ajax.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.10.2, at back/Helpers/global/ajax.php

47 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function acym_getAllHeaders(): array
4 {
5 if (function_exists('getallheaders')) {
6 return getallheaders();
7 }
8
9 $headers = [];
10
11 foreach ($_SERVER as $name => $value) {
12 if (substr($name, 0, 5) === 'HTTP_') {
13 $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
14 } else {
15 $headers[$name] = $value;
16 }
17 }
18
19 return $headers;
20 }
21
22 function acym_getHeader(string $headerName): string
23 {
24 $allHeaders = acym_getAllHeaders();
25
26 if (!empty($allHeaders[$headerName])) {
27 return $allHeaders[$headerName];
28 }
29
30 return '';
31 }
32
33 function acym_isAjax(): bool
34 {
35 $allHeaders = acym_getAllHeaders();
36
37 if (!empty($allHeaders['Accept'])) {
38 $headerAccept = $allHeaders['Accept'];
39 } elseif (!empty($allHeaders['accept'])) {
40 $headerAccept = $allHeaders['accept'];
41 } else {
42 $headerAccept = '';
43 }
44
45 return strpos($headerAccept, 'application/json') !== false;
46 }
47