PHP code example of pinkcrab / wp-nonce

1. Go to this page and download the library: Download pinkcrab/wp-nonce 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/ */

    

pinkcrab / wp-nonce example snippets


    $nonce = new Nonce('my_none_key');

    // To get the current nonce token
    $nonce->token();
    
    // To validate
    $nonce->validate($_POST['nonce']); // true/false

    // To add to url
    $url = $nonce->as_url('http://www.url.com', 'my_nonce'); // http://www.url.com?my_nonce={nonce_value}

    // Validate url.
    $nonce->admin_referer('my_nonce'); // true/false if set in url.
 php

// Create with a custom key
$custom_nonce = new Nonce('custom_key');

 php

$nonce = new Nonce('url_key');

// To get the current nonce value.
print $nonce->token(); // 31b31db189

$nonce_token = nonce->token(); // 31b31db189