Skip to content

WordPress Plugin that implements the WordPress Nonces functionality in an object orientated way.

License

Notifications You must be signed in to change notification settings

ovidiul/wp-nonces-oop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wp-nonces-oop

Package that implements the WordPress Nonces functionality (wp_nonce_*()) in an object orientated way.

Requirements

  • PHP 5.6+
  • Composer
  • WordPress 4.8.3+

Installation

Install with Composer:

$ composer require ovidiul/wp-nonces-oop:dev-master

Run the tests

To run tests, executes commands below:

$ cd vendor/thinkovi/wp-nonces-oop
$ composer install
$ vendor/bin/phpunit

Features

  • PSR-4 autoloading compliant structure
  • Unit-Testing with PHPUnit
  • Comprehensive Guides and tutorial
  • Easy to use to any Framework or even a plain php file

Usage

Initialize the nonce object generator

$generator = new NonceGenerator( 'action_name', 'nonce_parameter_name' );

Then, to generate the nonce use the generate_nonce() method:

$nonce = $generator->generate_nonce();

Generate a url with nonce parameter:

$url = $generator->generate_nonce_url( 'http://www.thinkovi.com' );

Generate nonce field:

$field = $generator->generate_nonce_field();

Nonce validation:

$is_valid = $generator->validate_nonce($nonce);

To validate a nonce received in a page through request (GET or POST) use the validate_request() method:

$is_valid = $generator->validate_request();

Credits

Liuta Ovidiu [email protected] , http://www.thinkovi.com

About

WordPress Plugin that implements the WordPress Nonces functionality in an object orientated way.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages