Download the PHP package madaritech/wp-oop-nonces without Composer

On this page you can find all versions of the php package madaritech/wp-oop-nonces. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-oop-nonces

wp-oop-nonces

Package that serves the WordPress Nonces functionality (wp_nonce_*()) in an object orientated way.

Requirements

Installation

Install with Composer:

Run the tests

To run tests, executes commands below:

Usage

The code refers to the wordPress workflow for nonce creation and verification. For more info see Codex.

Nonce Generation

In WordPress the nonce generation is achieved with the wp_create_nonce() function specifying a string representing the action.

Similarly, to proceed with nonce generation use the Nonce_Generator class with the proper action:

Then, to generate the nonce use the generate_nonce() method:

Nonce Url Generation

To add a nonce to a URL, WordPress uses wp_nonce_url() specifying the bare url and a string representing the action. Optionally is possible to specify a string for the name parameter, otherwise it defaults to '_wpnonce'.

Similarly, to generate a url with a nonce query parameter use the Nonce_Url_Generator class with the proper action value and optionally with the proper name parameter, otherwise it defaults to '_wp_nonce'.

So, use the generate_nonce_url() method with the proper url to generate the url with the nonce.

The same class can also generate a nonce directly:

Nonce Field Generation

To add a nonce to a form, WordPress uses wp_nonce_field() specifying a string representing the action. By default wp_nonce_field() generates two hidden fields, one whose value is the nonce and one whose value is the current url (the referrer), and it echoes the result.

Similarly, to generate form fields with nonce use the Nonce_Field_Generator class with the proper action value:

Optionally, the constructor accepts other parameters that affects the nonce field generation result (generate_nonce_field() method):

  1. name: the name of the nonce field. Defaults to '_wpnonce'.
  2. referer: boolean value to add an hidden field with refer url value. Set it to false to not add the field. Defaults to true.
  3. echo: boolean value to print the field/s. Set it to false to not print the fields. Defaults to true.

So, use the generate_nonce_field() method to generate the field/s with the nonce.

The same class can also generate a nonce directly:

Nonce Validation

To verify a nonce WordPress uses wp_verify_nonce() specifying the nonce and the string representing the action.

Similarly, validating funtionality is provided through the Nonce_Validator class; the constructor accept an action parameter (the same used to generate the nonce we want to validate) to verify the nonce:

Nonce Straight Validation

To validate a nonce use the validate_nonce() method with the nonce to verify as parameter:

If the validation is successful the method returns true; false otherwise.

Nonce Request Validation

To validate a nonce received in a page through request (GET or POST) use the validate_request() method:

If the validation is successful the method returns true; false otherwise.


All versions of wp-oop-nonces with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package madaritech/wp-oop-nonces contains the following files

Loading the files please wait ....