PHPackages                             vitalis/wpnonce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. vitalis/wpnonce

ActiveLibrary

vitalis/wpnonce
===============

An OOP implementation of WordPress Nonces

00PHPCI failing

Since Jan 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/agavitalis/wordpress-nonces-oop)[ Packagist](https://packagist.org/packages/vitalis/wpnonce)[ RSS](/packages/vitalis-wpnonce/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

OOP WordPress nonces
====================

[](#oop-wordpress-nonces)

This library is an object oriented implementation of WordPress nonces. It implements the following WordPress functions:

- wp\_create\_nonce()
- wp\_verify\_nonce()
- wp\_nonce\_ays()
- wp\_nonce\_field()
- wp\_nonce\_url()

For an explanation of what WordPress nonces are please see [WordPress codex](https://codex.wordpress.org/WordPress_Nonces).
**PLEASE NOTE: This is a development version that, for generating the nonces, uses fake algorithms and stubbed values instead of real algorithms and values.**

Installation
------------

[](#installation)

This library is distributed as a Composer package.
To install the development version:

```
composer.phar install

```

To install the production version (skipping the development packages):

```
composer.phar install --no-dev

```

Required PHP version
--------------------

[](#required-php-version)

This library is developed with PHP 7.1.x.

Coding standards
----------------

[](#coding-standards)

Code style: PSR-1 and PSR-2.
Autoloader: PSR-4 autoloader generated by Composer.

How to use this library
-----------------------

[](#how-to-use-this-library)

The preferred method for using this library is through the provided Factory. Here you can find some examples.

### Examples:

[](#examples)

#### wp\_create\_nonce() functionality

[](#wp_create_nonce-functionality)

Getting a nonce for the action 'my\_action':

```
use Agavitalis\WPNonce\Factories\WPNonceFactory;
$nonce_string = (new WPNonceFactory('my_action'))->getRaw()->get();
```

#### wp\_nonce\_field() functionality

[](#wp_nonce_field-functionality)

Getting hidden fields with nonce, for action 'my\_action', field name 'my\_nonce', with the referer and without echo:

```
use Agavitalis\WPNonce\Factories\WPNonceFactory;
$nonce_field_string = (new WPNonceFactory('my_action'))->getField('my_nonce', true, false)->get();
```

#### wp\_nonce\_url() functionality

[](#wp_nonce_url-functionality)

Getting a nonce added to the url  , for action 'my\_action', with name 'my\_nonce':

```
use Agavitalis\WPNonce\Factories\WPNonceFactory;
$nonce_url_string = (new WPNonceFactory('my_action'))->getUrl('http://example.com/insertdata', 'my_nonce')->get();
```

#### wp\_verify\_nonce() functionality

[](#wp_verify_nonce-functionality)

If you receive the string 'abcd123456', the action is 'my\_action' and you want to verify this nonce against your action you'll use:

```
use Agavitalis\WPNonce\Factories\WPNonceFactory;
$nonce_ok = (new WPNonceFactory('my_action'))->getRaw()->verify('abcd123456');
```

#### wp\_nonce\_ays() functionality

[](#wp_nonce_ays-functionality)

To display the "Are you sure" message to confirm the action being taken, for the action 'my\_action':

```
use Agavitalis\WPNonce\Factories\WPNonceFactory;
(new WPNonceFactory('my_action'))->getRaw()->ays();
```

Tests
-----

[](#tests)

This library comes with unit tests for PHPUnit version 6.1.x. The tests use the PSR-4 autoloader generated by Composer.
To set up the development environment follow the instructions of the 'Installation' section above.

License
-------

[](#license)

This library is licensed under the terms of the GPLv2+ license. See the provided [LICENSE.md](LICENSE.md) file.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ae1f5480e1a7863d4be0228f3bfa5389b1905286dbc71728eaed41faa78a1d3?d=identicon)[agavitalis](/maintainers/agavitalis)

---

Top Contributors

[![agavitalis](https://avatars.githubusercontent.com/u/19613305?v=4)](https://github.com/agavitalis "agavitalis (5 commits)")

### Embed Badge

![Health badge](/badges/vitalis-wpnonce/health.svg)

```
[![Health](https://phpackages.com/badges/vitalis-wpnonce/health.svg)](https://phpackages.com/packages/vitalis-wpnonce)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
