darkflameninja / nuonce
Something to simplify the handling with Nonces in WP in PHP OOP
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:composer-wordpress-package
Requires
- php: >=5.6.0
Requires (Dev)
- 10up/wp_mock: ^0.1.1
This package is not auto-updated.
Last update: 2025-03-19 23:07:42 UTC
README
Nuonce tries to simplify the handling with Nonces in PHP OOP.
Install
composer require Darkflameninja/Nuonce
Or just add
"require Darkflameninja/Nuonce": "1.0"
to your composer.json
file and run a composer update.
Usage:
Define your action & nonce
$yourobj = new Nuonce($action, $nonce); // if your input == ''(in both cases),it's predefined as action = nonce_action & nonce = _wpnonce
Create an URL
$url = $yourobj->url($url, $name);
Create a nonce field
$yourobj->field($name);
You also can set the referer as first parameter
$referer = 'http://mysite.com/something'; $yourobj->field($referer);
Skip the referer by setting it false.
$yourobj->field($referer, false);
Create a nonce
$nonce = $yourobj->create();
Check an URL for a valid nonce
$retval = $yourobj->AdminReferer($queryArg);
Check an AJAX URL for a valid nonce
$queryArg = '_myNonce'; $retval = $yourobj->AjaxReferer($queryArg);
If the third parameter is set to false, the script won't die, if the nonce is invalid
$retval = $yourobj->AjaxReferer($queryArg, false);
Verify a nonce
$retval = $yourobj->verify();