Csrf
class Csrf (View source)
Provide CSRF protection utilities through WordPress nonces.
Methods
__construct(string $key = '__wpemergeCsrfToken', integer $maximum_lifetime = 2)
Constructor.
string
getToken(int|string $action = -1)
Get the last generated token.
string
string
generateToken(int|string $action = -1)
Generate a new token.
boolean
isValidToken(string $token, int|string $action = -1)
Check if a token is valid.
string
url(string $url, int|string $action = -1)
Add the token to a URL.
void
field(int|string $action = -1)
Return the markup for a hidden input which holds the current token.
Details
at line 54
__construct(string $key = '__wpemergeCsrfToken', integer $maximum_lifetime = 2)
Constructor.
at line 65
string
getToken(int|string $action = -1)
Get the last generated token.
at line 79
string
getTokenFromRequest(RequestInterface $request)
Get the csrf token from a request.
at line 104
string
generateToken(int|string $action = -1)
Generate a new token.
at line 119
boolean
isValidToken(string $token, int|string $action = -1)
Check if a token is valid.
at line 133
string
url(string $url, int|string $action = -1)
Add the token to a URL.
at line 143
void
field(int|string $action = -1)
Return the markup for a hidden input which holds the current token.