PHPackages                             alexlg89/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. alexlg89/wpnonce

ActiveComposer-wordpress-package

alexlg89/wpnonce
================

Wrapper Class for Wordpress wp\_nonce\* functions.

0.0.1(9y ago)0261MITPHPPHP &gt;=5.6.0

Since Mar 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Alexlg89/WPnonce)[ Packagist](https://packagist.org/packages/alexlg89/wpnonce)[ RSS](/packages/alexlg89-wpnonce/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

WpNonce
=======

[](#wpnonce)

WpNonce is a static wrapper class for Wordpress wp\_nonce\* functions.

Install
-------

[](#install)

```
composer require alexlg89/wpnonce

```

Or just add

```
"require alexlg89/wpnonce": "0.0.1"

```

to your `compsoer.json` file and run a compposer update.

Usage:
------

[](#usage)

### Create an URL with a nonce parameter

[](#create-an-url-with-a-nonce-parameter)

```
$url = 'http://mysite.com/custommers';
$action = 'add-customer';
$name = '_myNonce';
$nonceUrl = WpNonce::url($url, $action, $name);
```

Or just use the default name by skipping the last parameter.

```
$nonceUrl = WpNonce::url($url, $action);
```

### Create a nonce field with a specific action

[](#create-a-nonce-field-with-a-specific-action)

```
$action = 'add-customer';
WpNonce::field($action);
```

You also can set the referer as second parameter

```
$referer = 'http://mysite.com/dashboard';
WpNonce::field($action, $referer);
```

The third parameter alows you to just get the nonce field and skip the referer field, if set to false.

```
WpNonce::field($action, $referer, false);
```

You can let the field function return the html as string, if you set the fourth parameter to false.

```
$html = WpNonce::field($action, $referer, true, false);
```

### Create a nonce with a specific action

[](#create-a-nonce-with-a-specific-action)

```
$action = 'add-customer';
$nonce = WpNonce::create($action);
```

### Check an URL for a vaild nonce

[](#check-an-url-for-a-vaild-nonce)

```
$action = 'add-customer';
$name = '_myNonce';
$retval = WpNonce::checkAdminReferer($action, $name);
```

Or just use the default name by skipping the last parameter.

```
$retval = WpNonce::checkAdminReferer($action);
```

### Check an AJAX URL for a vaild nonce

[](#check-an-ajax-url-for-a-vaild-nonce)

```
$action = 'add-customer';
$queryArg = '_myNonce';
$retval = WpNonce::check_ajax_referer($action, $queryArg);
```

If the third parameter is set to false, the script won't die, if the nonce is invalid

```
$retval = WpNonce::check_ajax_referer($action, $queryArg, false);
```

### Verify a nonce with a specific action

[](#verify-a-nonce-with-a-specific-action)

```
$nonce = 'an2bf72h';
$action = 'add-customer';
$retval = WpNonce::verify($nonce, $action);
```

### Default nonce

[](#default-nonce)

```
const DEFAULT_NONCE = '_wpnonce';
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3326d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7962f522c9be5a5ed2e783b81367d1686f82a6cabdaa49d464bb6b0bcf31aa6f?d=identicon)[Alexlg89](/maintainers/Alexlg89)

---

Top Contributors

[![Alexlg89](https://avatars.githubusercontent.com/u/11302326?v=4)](https://github.com/Alexlg89 "Alexlg89 (7 commits)")

### Embed Badge

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

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

PHPackages © 2026

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