2017 © Pedro Peláez
 

library wordpress-nonce

Implementation of the whole featured WordPress Nonces in an object oriented way. Included in the root directory is a unit test case.

image

okuley/wordpress-nonce

Implementation of the whole featured WordPress Nonces in an object oriented way. Included in the root directory is a unit test case.

  • Friday, September 16, 2016
  • by niiokuley
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WpNonceOOP

A compose package which serves the functionality of working with WordPress Nonces in object oriented environment, (*1)

Table of contents: * Requirements * Installation * Usage, (*2)

Requirements

  • PHP >= 5.3.0
  • WordPress >= 4.6

Installation

You can install this class both on command-line or by pasting it into the root of your plugin directory., (*3)

via Command-line

Using Composer, add Custom Nonce Class to your plugin's dependencies., (*4)

composer require okuley/wordpress-nonce:dev-master

Another way

  1. Download the latest zip of this repo.
  2. Unzip the master.zip file.
  3. Copy and paste it into the root of your plugin directory.
  4. Continue with your project.

Usage

Setup the minimum required thigs:, (*5)

<?php 

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use Nonces\WpNonce;


// Instantiate an object of the class
$nonce = new WpNonce();

Examples

Adding a nonce to a URL:, (*6)

$url="/../wp-admin/post.php?post=48";
$complete_url = $nonce->wp_nonce_url( $url, 'edit-post_'.$post->ID );

Adding a nonce to a form:, (*7)

$nonce->get_wp_nonce_field( 'delete-post_'.$post_id );

creating a nonce:, (*8)

$newnonce = $nonce->wp_create_nonce( 'action_'.$post->id );

Verifying a nonce:, (*9)

$nonce->wp_verify_nonce_field( 'delete-post_'.$post_id );

Verifying a nonce passed in an AJAX request:, (*10)

$nonce->wp_check_ajax_referer( 'post-comment' );

Verifying a nonce passed in some other context:, (*11)

$nonce->wp_check_admin_referer( $_REQUEST['my_nonce'], 'edit-post_'.$post->ID );

The Versions

16/09 2016

dev-master

9999999-dev

Implementation of the whole featured WordPress Nonces in an object oriented way. Included in the root directory is a unit test case.

  Sources   Download

GNU Library General Public License

The Requires

  • php >=5.3.0

 

by Andrew Nii Okuley Tettey