1. Go to this page and download the library: Download brain/nonces 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/ */
brain / nonces example snippets
class TaskForm {
public function __construct(\Brain\Nonces\NonceInterface $nonce){
$this->nonce = $nonce;
$this->url = admin_url('admin-post.php');
}
public function printFrom() {
$url = add_query_arg($this->nonce->action(), (string) $this->nonce, $this->url);
echo "<form action={$url}>";
// rest of form here...
}
}
class TaskFormHandler {
public function __construct(\Brain\Nonces\NonceInterface $nonce){
$this->nonce = $nonce;
}
public function saveForm() {
if (! $this->nonce->validate()) {
// handle error here...
}
// continue processing here...
}
}
class TaskForm {
public function __construct(\Brain\Nonces\NonceInterface $nonce){
$this->nonce = $nonce;
$this->url = admin_url('admin-post.php');
}
public function printFrom() {
$url = \Brain\Nonces\nonceUrl($this->nonce, $this->url);
echo "<form action={$url}>";
// rest of form here...
}
}
class TaskForm {
public function __construct(\Brain\Nonces\NonceInterface $nonce){
$this->nonce = $nonce;
$this->url = admin_url('admin-post.php');
}
public function printFrom() {
echo "<form action={$this->url}>";
echo \Brain\Nonces\formField($this->nonce);
// rest of form here...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.