# acymailing/10.2.2/back/Helpers/global/ajax.php

AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress, version 10.2.2. 47 lines.

- Page: https://pluginprobe.com/plugins/acymailing/10.2.2/code/back/Helpers/global/ajax.php
- Raw: https://pluginprobe.com/plugins/acymailing/10.2.2/raw/back/Helpers/global/ajax.php
- Modified: 2025-03-03T13:35:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/acymailing/10.2.2/code/back/Helpers/global/ajax.php#L10-L20`.

```php
<?php

function acym_getAllHeaders(): array
{
    if (function_exists('getallheaders')) {
        return getallheaders();
    }

    $headers = [];

    foreach ($_SERVER as $name => $value) {
        if (substr($name, 0, 5) === 'HTTP_') {
            $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
        } else {
            $headers[$name] = $value;
        }
    }

    return $headers;
}

function acym_getHeader(string $headerName): string
{
    $allHeaders = acym_getAllHeaders();

    if (!empty($allHeaders[$headerName])) {
        return $allHeaders[$headerName];
    }

    return '';
}

function acym_isAjax(): bool
{
    $allHeaders = acym_getAllHeaders();

    if (!empty($allHeaders['Accept'])) {
        $headerAccept = $allHeaders['Accept'];
    } elseif (!empty($allHeaders['accept'])) {
        $headerAccept = $allHeaders['accept'];
    } else {
        $headerAccept = '';
    }

    return strpos($headerAccept, 'application/json') !== false;
}

```
