nimos / wp-nonce-wrapper
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nimos/wp-nonce-wrapper
Requires (Dev)
- phpunit/phpunit: 6.0
This package is not auto-updated.
Last update: 2025-10-18 00:33:45 UTC
README
This wrapper provides Wordpress' nonce functionality in an object-oriented environment.
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.
Usage
Create a Nonce:
$nonce = WpNonceWrapper::create_nonce();
Generate a nonce URL for 'http://example.com':
$url = WpNonceWrapper::nonce_url( 'http://example.com' );
Generate hidden input to use a nonce in a form:
WpNonceWrapper::nonce_field();
Verify a Nonce:
$valid = WpNonceWrapper::verify_nonce( $nonce );
Display an are you sure dialogue, to manually confirm an action:
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.