PHP code example of spock / wp-nonce-wrapper

1. Go to this page and download the library: Download spock/wp-nonce-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spock / wp-nonce-wrapper example snippets


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();

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

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

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

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