定制 farsil/wp-nonce 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

farsil/wp-nonce

Composer 安装命令:

composer require farsil/wp-nonce

包简介

Object oriented implementation of Wordpress nonces

README 文档

README

wp-nonce is a replacement library for wordpress nonces written in PHP. It aims to provide an object oriented interface that can be used in lieu of the wordpress wp_nonce_* functions.

Installation

Add the following entry to the required list in your composer.json:

"farsil/wp-nonce": "v1.0.*"

Or, alternatively, run:

$ composer require farsil/wp-nonce

Usage

Nonce generation is performed through the Nonce_Generator class, and nonce validation is performed through the Nonce_Validator class. The method names are reminiscent of the corresponding methods of the Wordpress core functions, and behave similarly, with a few differences. See the documentation for additional details.

Example

<?php
// We don't need to load themes
define( 'WP_USE_THEMES', false );

// This line assumes your Wordpress installation is in your PHP include path,
// change accordingly if it is not the case.
require_once 'wp-load.php';

// Let composer autoload wp-nonce classes.
require_once 'vendor/autoload.php';

// Generate a new nonce. Default lifetime is 1 day.
$gen = new Wordpress\Nonce_Generator( 'test-nonce' );
$token = $gen->generate();

// In order to properly validate the generated token, the constructor parameters
// need to match those used in Nonce_Generator.
$val = new Wordpress\Nonce_Validator( 'test-nonce' );
echo $val->verify( $token );

Expected Output:

1

Tests

wp-nonce includes a comprehensive PHPUnit test suite. Since wp-nonce includes a phpunit.xml.dist file, all you need to do is to navigate to the project root, and run:

$ php /path/to/phpunit.phar --include-path=/path/to/wordpress

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固