spock / wp-nonce-wrapper
There is no license information available for the latest version (v0.4) of this package.
Simplified WordPress nonce usage
v0.4
2016-03-17 20:11 UTC
Requires (Dev)
- brain/monkey: ~1.0
This package is auto-updated.
Last update: 2024-12-13 21:30:53 UTC
README
Use WordPress Nonce an object oriented way
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