Inject WPFunctions to FieldNameObfuscator using DI
[MAILPOET-2665]
This commit is contained in:
committed by
Jack Kitterhing
parent
7d596e3407
commit
d0acad5c3b
@ -9,9 +9,16 @@ class FieldNameObfuscator {
|
||||
const OBFUSCATED_FIELD_PREFIX = 'form_field_';
|
||||
const HASH_LENGTH = 12;
|
||||
|
||||
/** @var WPFunctions */
|
||||
private $wp;
|
||||
|
||||
public function __construct(WPFunctions $wp) {
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
public function obfuscate($name) {
|
||||
$authKey = defined('AUTH_KEY') ? AUTH_KEY : '';
|
||||
$hash = substr(md5($authKey . WPFunctions::get()->homeUrl() . $name), 0, self::HASH_LENGTH);
|
||||
$hash = substr(md5($authKey . $this->wp->homeUrl() . $name), 0, self::HASH_LENGTH);
|
||||
return self::OBFUSCATED_FIELD_PREFIX . base64_encode($hash . '_' . $name);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user