: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class wfWebsiteEphemeralPayloadRetrievalException extends RuntimeException {
class wfWebsiteEphemeralPayloadExpiredException extends wfWebsiteEphemeralPayloadRetrievalException {
public function __construct() {
parent::__construct('Ephemeral payload expired', self::STATUS);
class wfWebsiteEphemeralPayloadRateLimitedException extends wfWebsiteEphemeralPayloadRetrievalException {
public function __construct() {
parent::__construct('Request limit reached', self::STATUS);
* Utilities related to the Wordfence website (wordfence.com)
private static $INSTANCE = null;
private function __construct($url) {
$this->url = trailingslashit($url);
public function getUrl($relative) {
return $this->url . $relative;
public function retrievePayload($token, &$expired) {
$url = $this->getUrl("api/ephemeral-payload/$token");
$response = wp_remote_get($url);
$status = wp_remote_retrieve_response_code($response);
if (!is_wp_error($response) && $status === 200) {
return wp_remote_retrieve_body($response);
case wfWebsiteEphemeralPayloadExpiredException::STATUS:
throw new wfWebsiteEphemeralPayloadExpiredException();
case wfWebsiteEphemeralPayloadRateLimitedException::STATUS:
throw new wfWebsiteEphemeralPayloadRateLimitedException();
throw new wfWebsiteEphemeralPayloadRetrievalException('Failed to retrieve ephemeral payload', (int) $status);
public static function getInstance() {
if (self::$INSTANCE === null)
self::$INSTANCE = new self(WORDFENCE_WWW_BASE_URL);
public static function url($relative) {
return self::getInstance()->getUrl($relative);