Wordpress Nonce Wrapper
This wrapper provides Wordpress' nonce functionality in an object-oriented environment., (*1)
Installation
To install the package, run composer require nimos/wp-nonce-wrapper
.
Alternatively, you can download the zip file from Github, and run composer update
to install the dependencies., (*2)
Usage
Create a Nonce:, (*3)
$nonce = WpNonceWrapper::create_nonce();
Generate a nonce URL for 'http://example.com':, (*4)
$url = WpNonceWrapper::nonce_url( 'http://example.com' );
Generate hidden input to use a nonce in a form:, (*5)
WpNonceWrapper::nonce_field();
Verify a Nonce:, (*6)
$valid = WpNonceWrapper::verify_nonce( $nonce );
Display an are you sure dialogue, to manually confirm an action:, (*7)
WpNonceWrapper::nonce_ays( $someAction );
Testing
To run the tests, run vendor\bin\phpunit tests\WrapperTest.php
You will likely have to update WP_DIR in the test file to point to your Wordpress installation., (*8)