定制 arraypress/wp-sanitize-polyfills 二次开发

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

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

arraypress/wp-sanitize-polyfills

Composer 安装命令:

composer require arraypress/wp-sanitize-polyfills

包简介

Additional sanitization functions that complement WordPress core.

README 文档

README

Additional sanitization functions that complement WordPress core. These functions follow WordPress naming conventions and feel like native functions that should exist in core.

Installation

composer require arraypress/wp-sanitize-polyfills

Functions

sanitize_object_ids

Sanitize an array of object IDs (post IDs, term IDs, user IDs, etc.).

$ids = sanitize_object_ids( [ '1', 2, '3', 0, '', 2, 'abc' ] );
// Returns: [ 1, 2, 3 ]

sanitize_amount

Sanitize a monetary/decimal amount.

$price = sanitize_amount( '$1,234.567' );
// Returns: '1234.57'

$price = sanitize_amount( '99.9', 0 );
// Returns: '100'

$price = sanitize_amount( '-45.5', 2 );
// Returns: '-45.50'

sanitize_comma_list

Sanitize a comma-separated list into an array.

$tags = sanitize_comma_list( 'apple, banana, , cherry' );
// Returns: [ 'apple', 'banana', 'cherry' ]

sanitize_newline_list

Sanitize a newline-separated list into an array.

$lines = sanitize_newline_list( "line one\nline two\n\nline three" );
// Returns: [ 'line one', 'line two', 'line three' ]

sanitize_emails

Sanitize a list of email addresses. Accepts comma-separated string, newline-separated string, or array.

// From comma-separated string
$emails = sanitize_emails( 'john@example.com, invalid, jane@example.com' );
// Returns: [ 'john@example.com', 'jane@example.com' ]

// From array
$emails = sanitize_emails( [ 'john@example.com', 'not-an-email', 'jane@example.com' ] );
// Returns: [ 'john@example.com', 'jane@example.com' ]

is_valid_json

Check if a string is valid JSON.

is_valid_json( '{"name": "John"}' );  // true
is_valid_json( 'not json' );           // false
is_valid_json( '' );                   // false

Requirements

  • PHP 7.4+
  • WordPress (for sanitize_text_field(), sanitize_email(), is_email())

License

GPL-2.0-or-later

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-02-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固