public function validate(NonceContextInterface $context = null)
    {
        $context or $context = new RequestGlobalsContext();

        $value = $context->offsetExists($this->action) ? $context[$this->action] : '';
        if (!$value || !is_string($value)) {
            return false;
        }

        $lifeFilter = $this->lifeFilter();

        add_filter('nonce_life', $lifeFilter);
        $valid = wp_verify_nonce($value, $this->hashedAction());
        remove_filter('nonce_life', $lifeFilter);

        return (bool)$valid;
    }
public function validate(NonceContextInterface $context = null)
    {
        $context or $context = new RequestGlobalsContext();

        $value = $context->offsetExists($this->action) ? $context[$this->action] : '';
        if (!$value || !is_string($value)) {
            return false;
        }

        $lifeFilter = $this->lifeFilter();

        add_filter('nonce_life', $lifeFilter);
        $valid = wp_verify_nonce($value, $this->hashedAction());
        remove_filter('nonce_life', $lifeFilter);

        return (bool)$valid;
    }
public function validate ( NonceContextInterface $ context = null ) { $ context or $ context = new RequestGlobalsContext ( ) ; $ value = $ context -> offsetExists ( $ this -> action ) ? $ context [ $ this -> action ] : '' ; if ( ! $ value || ! is_string ( $ value ) ) { return false ; } $ lifeFilter = $ this -> lifeFilter ( ) ; add_filter ( 'nonce_life' , $ lifeFilter ) ; $ valid = wp_verify_nonce ( $ value , $ this -> hashedAction ( ) ) ; remove_filter ( 'nonce_life' , $ lifeFilter ) ; return ( bool ) $ valid ; }
Validates the nonce against given context.

When not provided, context defaults to `RequestGlobalsContext`, so that value is searched
in super globals.

We need to filter the nonce life and remove the filter afterwards, because WP does not
allow to filter nonce by action (yet? @link https://core.trac.wordpress.org/ticket/35188)

@param NonceContextInterface $context
@return bool
Validates the nonce against given context .