PHPackages                             xwp/wp-safe-input - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. xwp/wp-safe-input

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

xwp/wp-safe-input
=================

0.0.1(7y ago)1101MITPHP

Since Feb 12Pushed 7y ago50 watchersCompare

[ Source](https://github.com/xwp/wp-safe-input)[ Packagist](https://packagist.org/packages/xwp/wp-safe-input)[ RSS](/packages/xwp-wp-safe-input/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Safe Input Library for WordPress
================================

[](#safe-input-library-for-wordpress)

[![Build Status](https://camo.githubusercontent.com/3fde5c399a2e87eb3d1686a1833be40b05832d178bf38e7ccb9aa52fc53c6a9b/68747470733a2f2f7472617669732d63692e636f6d2f7877702f77702d736166652d696e7075742e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/xwp/wp-safe-input)[![Coverage Status](https://camo.githubusercontent.com/51aa7fe14d2c6c2eb15e8cf171976298e75adc55dd69556f824cd52fe8bd4389/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7877702f77702d736166652d696e7075742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/xwp/wp-safe-input?branch=master)

A helper library for validating and sanitizing form input data.

Setup
-----

[](#setup)

Use [Composer](https://getcomposer.org) to add [this library](https://packagist.org/packages/xwp/wp-safe-input) to your project:

```
composer require xwp/wp-safe-input
```

Usage
-----

[](#usage)

See the sample plugin in the [`example` directory](example).

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.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2648d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?d=identicon)[kasparsd](/maintainers/kasparsd)

![](https://www.gravatar.com/avatar/415bc53586018077324af64dad074bf430ba1b72471550489372668274a13b12?d=identicon)[xwp](/maintainers/xwp)

---

Top Contributors

[![kasparsd](https://avatars.githubusercontent.com/u/169055?v=4)](https://github.com/kasparsd "kasparsd (19 commits)")

---

Tags

php-librarywordpress

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xwp-wp-safe-input/health.svg)

```
[![Health](https://phpackages.com/badges/xwp-wp-safe-input/health.svg)](https://phpackages.com/packages/xwp-wp-safe-input)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
