xwp/wp-safe-input
Composer 安装命令:
composer require xwp/wp-safe-input
包简介
README 文档
README
A helper library for validating and sanitizing form input data.
Setup
Use Composer to add this library to your project:
composer require xwp/wp-safe-input
Usage
See the sample plugin in the example directory.
The core logic looks like this:
use XWP\SafeInput\PostMeta; use XWP\SafeInput\Request; add_action( 'save_post', function ( $post_id ) { $request = new Request( INPUT_POST ); $meta = new PostMeta( $post_id ); if ( $request->verify_nonce( 'nonce-action', 'nonce-input-name' ) && $meta->can_save() ) { if ( 'on' === $request->param( 'input-field-name' ) ) { // Update post meta value. } else { // Delete post meta value. } } } );
TODO: Document what happens in the example above.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-12