spock/wp-nonce-wrapper

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (v0.4) of this package.

Simplified WordPress nonce usage

Maintainers

Package info

github.com/PatelUtkarsh/wp-nonce-wrapper

pkg:composer/spock/wp-nonce-wrapper

Statistics

Installs: 20

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v0.4 2016-03-17 20:11 UTC

This package is auto-updated.

Last update: 2026-03-14 00:24:44 UTC


README

Use WordPress Nonce an object oriented way

Build Status

Installation:

"spock/wp-nonce-wrapper": "0.4"

to your composer.json file and run a composer update

Or

composer require spock/wp-nonce-wrapper

Usage:

Get Nonce with expiry:

use spock\helper\Nonce_Wrapper;
$nonce_obj = new Nonce_Wrapper('doing_some_form_job', 60*60); // 60 sec * 60 min = 1hr; Note: default is 1 day.
$nonce = $nonce_obj->create_nonce();

Verify Nonce:

$nonce = $_REQUEST['nonce'];
$nonce_obj = new Nonce_Wrapper('doing_some_form_job');
if ( $nonce_obj->verify_nonce( $nonce ) )
    //Verified Source 
else 
    // Unknown Source

Create nonce input field:

//This will echo input field
$nonce_obj->create_nonce_field();

Create nonce url

$url   = $nonce_obj->create_nonce_url( 'http://w.org' );

Check user is coming from another admin page.

// This will check current url 
if ($nonce_obj->check_admin_referral())
   //doing it right
else 
   //doing it wrong

Changelog

0.4

  • Remove php magic method usage
  • Refactor code
  • Improved documentation

0.3

  • Nonce expire control added
  • Added missing nonce function

0.2

  • Nonce field support
  • Nonce url support
  • Check user is coming from admin referral

0.1

  • Initial basic functionality