alexlg89/wpnonce 问题修复 & 功能扩展

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

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

alexlg89/wpnonce

Composer 安装命令:

composer require alexlg89/wpnonce

包简介

Wrapper Class for Wordpress wp_nonce* functions.

README 文档

README

WpNonce is a static wrapper class for Wordpress wp_nonce* functions.

Install

composer require alexlg89/wpnonce

Or just add

"require alexlg89/wpnonce": "0.0.1"

to your compsoer.json file and run a compposer update.

Usage:

Create an URL with a nonce parameter

$url = 'http://mysite.com/custommers';
$action = 'add-customer';
$name = '_myNonce';
$nonceUrl = WpNonce::url($url, $action, $name);

Or just use the default name by skipping the last parameter.

$nonceUrl = WpNonce::url($url, $action);

Create a nonce field with a specific action

$action = 'add-customer';
WpNonce::field($action);

You also can set the referer as second parameter

$referer = 'http://mysite.com/dashboard';
WpNonce::field($action, $referer);

The third parameter alows you to just get the nonce field and skip the referer field, if set to false.

WpNonce::field($action, $referer, false);

You can let the field function return the html as string, if you set the fourth parameter to false.

$html = WpNonce::field($action, $referer, true, false);

Create a nonce with a specific action

$action = 'add-customer';
$nonce = WpNonce::create($action);

Check an URL for a vaild nonce

$action = 'add-customer';
$name = '_myNonce';
$retval = WpNonce::checkAdminReferer($action, $name);

Or just use the default name by skipping the last parameter.

$retval = WpNonce::checkAdminReferer($action);

Check an AJAX URL for a vaild nonce

$action = 'add-customer';
$queryArg = '_myNonce';
$retval = WpNonce::check_ajax_referer($action, $queryArg);

If the third parameter is set to false, the script won't die, if the nonce is invalid

$retval = WpNonce::check_ajax_referer($action, $queryArg, false);

Verify a nonce with a specific action

$nonce = 'an2bf72h';
$action = 'add-customer';
$retval = WpNonce::verify($nonce, $action);

Default nonce

const DEFAULT_NONCE = '_wpnonce';

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固