Wallogit.com
2017 © Pedro Peláez
basic support class for wordpress nonce ussage
to include this class in to your project:, (*1)
include_once dirname(__FILE__).'/you_library_path/Pebo_wp_nonce_helper.php';
composer require pebo/wp_nonce_helper=dev-master
Pebo_wp_nonce_helper.php::method_name($args ...);
, (*2)
Setting nonces life time:, (*3)
Pebo_wp_nonce_helper.php::set_nonce_duration($time_in_secconds);
, (*4)
<a href="<?php print Pebo_wp_nonce_helper::create_nonce_url(admin_url('options.php?page=my_plugin_settings'), 'doing_something', 'my_nonce');?>" class="button button-primary"><?php esc_html_e('Do Something!', 'my-plugin-textdomain');?></a>
if(Pebo_wp_nonce_helper::nonce_verify('nonce_name', 'action_name') != false){
//Do Something..
{
<form method="post"> <!-- some inputs here ... --> <?phpPebo_wp_nonce_helper::get_hidden_field( 'name_of_my_action', 'name_of_nonce_field' );
?>
</form>
if(Pebo_wp_nonce_helper::check_nonce_field('name_of_my_action', 'name_of_nonce_field') != false){
//Do Something..
{
, (*5)