dev-master
9999999-dev https://github.com/mahdy-nasr/WpNoncerunning wordpress nonce in opject orianted manner
MIT
by Mahdy Nasr
1.0.0
1.0.0.0 https://github.com/mahdy-nasr/WpNoncerunning wordpress nonce in opject orianted manner
MIT
by Mahdy Nasr
Wallogit.com
2017 © Pedro Peláez
running wordpress nonce in opject orianted manner
Wordpress nonce in an object-oriented manner, (*1)
this package used instead of wp_nonce_*() functions in WordPress. it built in an object-oriented way and also make the code more readable., (*2)
it tested against WordPress v4.9., (*3)
either via direct composer command :, (*4)
composer require mahdy/wpnonce
or via editing composer.json file and then use composer update, (*5)
{
"require": {
"mahdy/wpnonce" : "1.0.0"
}
}
the package used for generating and verifying the WordPress Nonce., (*6)
1- via constructor, (*7)
$nonce = new \WpNonce\Nonce("Xaction");
2- via setter function, (*8)
$nonce = new \WpNonce\Nonce();
$nonce->setAction("Xaction");
It used for URL and form field. The default value is "_wpnonce", (*9)
$nonce->setName("theNewName");
1- Exciplicitly, (*10)
/*if you didn't set the action in constructor, you have to use setter before to use this function*/ $nonce_string = $nonce->generateNonce();
2- As string, (*11)
/*use the object directly */ $str = "the following object will return as Nonce string ".$nonce;
$url = "https://somewebsite.com/"; $nonce_url = $nonce->generateNonceUrl($url);
It take 2 optional parametars: generateNonceField($referer = true, $echo = true), (*12)
$nonce_HTML_input = $generateNonceField()
it return 1 if the nonce generated in last 12h and 2 if it generated in last 24h, (*13)
if (\WpNonce\NonceVerifier::verify($nonce, $action)) {...}
Verifying using checkAdminReferer($action, $input_name = "_wpnonce") function., (*14)
if (\WpNonce\NonceVerifier::checkAdminReferer($action)) {...}
the function checkAjaxReferer($action, $arg_name = false, $die = true) has 2 optional parametars., (*15)
if (\WpNonce\NonceVerifier::checkAjaxReferer($action)) {...}
1- you have first to install PHPUnit, (*16)
2- open the package folder: vendor/mahdy/wpnonce change to this directory to run the phpunit, (*17)
3- before run change the vendor/mahdy/wpnonce/bootstrap.php and change the WORDPRESS_PATH to your WordPress installation directory., (*18)
4- in command line from package directory run, (*19)
$ phpunit
running wordpress nonce in opject orianted manner
MIT
running wordpress nonce in opject orianted manner
MIT