-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCtPublicFunctionsLocalize.php
More file actions
44 lines (37 loc) · 1.79 KB
/
CtPublicFunctionsLocalize.php
File metadata and controls
44 lines (37 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Cleantalk\ApbctWP\Localize;
use Cleantalk\ApbctWP\Antispam\EmailEncoder;
use Cleantalk\ApbctWP\Escape;
use Cleantalk\ApbctWP\Variables\Server;
class CtPublicFunctionsLocalize
{
const NAME = 'ctPublicFunctions';
const HANDLE = 'ct_public_functions';
public static function getData()
{
global $apbct;
$data = array(
'_ajax_nonce' => $apbct->ajax_service->getPublicNonce(),
'_rest_nonce' => wp_create_nonce('wp_rest'),
'_ajax_url' => admin_url('admin-ajax.php', 'relative'),
'_rest_url' => Escape::escUrl(apbct_get_rest_url()),
'data__cookies_type' => $apbct->data['cookies_type'],
'data__ajax_type' => $apbct->data['ajax_type'],
'data__bot_detector_enabled' => $apbct->settings['data__bot_detector_enabled'],
'data__frontend_data_log_enabled' => $apbct->constants->do_not_collect_frontend_data_logs->isDefinedAndTypeOK() ? 0 : 1,
'cookiePrefix' => apbct__get_cookie_prefix(),
'wprocket_detected' => apbct_is_plugin_active('wp-rocket/wp-rocket.php'),
'host_url' => Server::get('HTTP_HOST'),
);
$data = array_merge($data, EmailEncoder::getLocalizationText());
return $data;
}
public static function getCode()
{
return '
<script data-no-defer="1" data-ezscrex="false" data-cfasync="false" data-pagespeed-no-defer data-cookieconsent="ignore">
var ' . self::NAME . ' = ' . json_encode(self::getData()) . '
</script>
';
}
}