radix/nonce-oop 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

radix/nonce-oop

Composer 安装命令:

composer require radix/nonce-oop

包简介

Wordpress Nonce OOP

README 文档

README

This is an oop wrapper for wordpress nonces functionality.

Installation

If you have not done that already add composer autoloader to your wordpress main index.php:

require_once('vendor/autoload.php');

Add to your composer.json in require this: "radix/nonce-oop": "1.0 and run composer update.

Usage

Initialize the facade.

At the beginning of the file you want to use nonces in put:

use radix\NonceOop\NonceFacade;

then you can instantiate a common facade via:

$facade = new NonceFacade('testAction');

Without a second argument it will use the default SimpleNonce variant. If you want you can also use RequestNonce and AjaxNonce, just add them to the use declaration and inject their insances into the facade like that:

use radix\NonceOop\{NonceFacade, RequestNonce};

// ...

$facade = new NonceFacade('testAction', new RequestNonce());

Use the interface.

After that is done you have four methods that you can use:

$simpleNonce  = $facade->create();
$fieldNonce   = $facade->createField();
$urlNonce     = $facade->createUrl('http://example.com');
$isNonceValid = $facade->check($simpleNonce);

The methods wrap original WordPress nonce functions.

  • create method creates a simple 10-character string,
  • createField method gives you HTML string containing hidden input field with a nonce in it. Refer to the method interface to see what options you can use.
  • createUrl method gives you an URL with a nonce appended to URL's query. Refer to the method interface to see what options you can use.
  • check method validates the nonce. When used with SimpleNonce it only checks the string, other classes check the $_REQUEST superglobal.

Extending

You can add your own class that implements NonceServiceInterface and inject it into the facade on initialization.

Tests

In order to run tests type:

vendor/bin/phpunit --bootstrap vendor/autoload.php vendor/radix/nonce-oop/tests/src

Please note that you need to have PHPUnit installed.

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固