2017 © Pedro Peláez
 

library wp-nonce-wrapper-class

A package that provides the functionality of working with WordPress Nonces in an object orientated way.

image

perezlabs/wp-nonce-wrapper-class

A package that provides the functionality of working with WordPress Nonces in an object orientated way.

  • Tuesday, February 2, 2016
  • by perezlabs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WordPress Nonce Wrapper Class

This class provides the functionality of working with WordPress Nonces in an object orientated way., (*1)

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

Requirements

  • PHP >= 5.4
  • WordPress >= 3.5

Installation

You can install this class via command-line or drag it into the root of your plugin directory., (*3)

via Command-line

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

composer require perezlabs/wp-nonce-wrapper-class:dev-master

Another way

  1. Download the latest zip of this repo.
  2. Unzip the master.zip file.
  3. Drag it into the root of your plugin directory.
  4. Happy coding :)!

Usage

Setup the minimum required thigs:, (*5)

<?php
require_once 'vendor/autoload.php';

use Perezlabs\WpNonceWrapper\WpNonceWrapper;

// Instantiate the class
$nonce = new WpNonceWrapper();

Examples

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

$complete_url = $nonce->wpNonceUrl( $bare_url, 'trash-post_'.$post->ID );

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

$nonce->wpNonceField( 'delete-comment_'.$comment_id );

Creating a nonce:, (*8)

$newNonce = $nonce->wpCreateNonce( 'my-action_'.$post->ID );

Verifying a nonce:, (*9)

$nonce->checkAdminReferer( 'delete-comment_'.$comment_id );

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

$nonce->checkAjaxReferer( 'process-comment' );

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

$nonce->wpVerifyNonce( $_REQUEST['my_nonce'], 'process-comment'.$comment_id );

The Versions

02/02 2016

dev-master

9999999-dev

A package that provides the functionality of working with WordPress Nonces in an object orientated way.

  Sources   Download

The Requires

  • php >=5.3.0

 

wordpress nonces