2017 © Pedro Peláez
 

library wp_nonce_helper

basic support class for wordpress nonce ussage

image

pebo/wp_nonce_helper

basic support class for wordpress nonce ussage

  • Friday, March 30, 2018
  • by pebopro
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Pebo_wp_nonce_helper

Helper clas for handling nonces on WorPress.

Ussage:

to include this class in to your project:, (*1)

  • download or clone this project and place the file Pebo_wp_nonce_helper.php in to your library folder (inside your project).
  • include the class in your code file:
include_once dirname(__FILE__).'/you_library_path/Pebo_wp_nonce_helper.php';
  • Or using composer:
    composer require pebo/wp_nonce_helper=dev-master
  
  • Then call methods using the formula:
Pebo_wp_nonce_helper.php::method_name($args ...);

, (*2)

Functionality:

Setting nonces life time:, (*3)

Pebo_wp_nonce_helper.php::set_nonce_duration($time_in_secconds);

, (*4)

Creating a nonce url (for a link):
<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>
Nonce validation:

  if(Pebo_wp_nonce_helper::nonce_verify('nonce_name', 'action_name') != false){
    //Do Something..
  {
  
Create nonce hidden field inside a form :
<form method="post">
   <!-- some inputs here ... -->
   <?php Pebo_wp_nonce_helper::get_hidden_field( 'name_of_my_action', 'name_of_nonce_field' ); 
?>
</form>
Validate a nonce hidden field.

  if(Pebo_wp_nonce_helper::check_nonce_field('name_of_my_action', 'name_of_nonce_field') != false){
    //Do Something..
  {
  

, (*5)

The Versions

30/03 2018

dev-master

9999999-dev

basic support class for wordpress nonce ussage

  Sources   Download

MIT

by PeBo