Refresh nonce via heartbeats [MAILPOET-2839]

This commit is contained in:
wxa
2020-05-22 00:11:05 +03:00
committed by Veljko V
parent 2b4afbcda9
commit 70e3d1e459
2 changed files with 19 additions and 0 deletions

View File

@ -84,6 +84,12 @@ class API {
'wp_ajax_nopriv_mailpoet',
[$this, 'setupAjax']
);
// nonce refreshing via heartbeats
WPFunctions::get()->addAction(
'wp_refresh_nonces',
[$this, 'addTokenToHeartbeatResponse']
);
}
public function setupAjax() {
@ -234,6 +240,11 @@ class API {
);
}
public function addTokenToHeartbeatResponse($response) {
$response['mailpoet_token'] = Security::generateToken();
return $response;
}
public function addEndpointNamespace($namespace, $version) {
if (!empty($this->endpointNamespaces[$version][$namespace])) return;
$this->endpointNamespaces[$version][] = $namespace;