Something to simplify the handling with Nonces in WP in PHP OOP

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:composer-wordpress-package

1.0.2 2018-04-03 02:08 UTC

This package is not auto-updated.

Last update: 2024-05-01 18:19:45 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();