PHPackages                             stevegrunwell/wp-enforcer - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. stevegrunwell/wp-enforcer

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

stevegrunwell/wp-enforcer
=========================

Git hooks to encourage well-written WordPress.

v0.5.0(8y ago)11114.2k14[7 issues](https://github.com/stevegrunwell/wp-enforcer/issues)2MITShell

Since Nov 23Pushed 5y ago4 watchersCompare

[ Source](https://github.com/stevegrunwell/wp-enforcer)[ Packagist](https://packagist.org/packages/stevegrunwell/wp-enforcer)[ RSS](/packages/stevegrunwell-wp-enforcer/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (10)Used By (2)

WP Enforcer
===========

[](#wp-enforcer)

[![GitHub release](https://camo.githubusercontent.com/6e1293d70f2cd50835794077f701797225cba56c3c1bbaeeacae0e0c6daf1f75/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73746576656772756e77656c6c2f77702d656e666f726365722e737667)](https://github.com/stevegrunwell/wp-enforcer/releases/latest)[![GitHub license](https://camo.githubusercontent.com/00f5a4abb108fca6034e403aa8563f49fa5339dd29e17f05bbd2fd5ada7a6170/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73746576656772756e77656c6c2f77702d656e666f726365722e737667)](https://github.com/stevegrunwell/wp-enforcer/blob/master/LICENSE.txt)

When writing for a platform as big as WordPress – especially in a team environment – a consistent set of coding standards is vital. Having multiple developers committing code using a mixture of spaces and tabs, inconsistent formatting, or otherwise varying coding styles can lead to headache-inducing merge conflicts.

There are a number of great tools available to check against established coding standards (namely [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)), but setting them up on a project can be a pain. WP Enforcer is designed to make this setup a breeze.

How does it work?
-----------------

[](#how-does-it-work)

WP Enforcer uses [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automatically run PHP\_CodeSniffer every time a developer tries to make a commit; if the code isn't up-to-snuff, the commit will be rejected and the developer will get a message explaining what needs to be fixed.

**Note:** If your project already has messy standards you may not want to make WP Enforcer mandatory until *after* you've cleaned up the codebase or suddenly commits will be quite painful! See [Adding to an Existing Project](#adding-to-an-existing-project) for an easy work-around.

Installation
------------

[](#installation)

The easiest way to install WP Enforcer is via Composer:

```
$ composer require --dev stevegrunwell/wp-enforcer
```

This will add WP Enforcer to your `composer.json` file and install the WP Enforcer package.

Next, you'll need to run the WP Enforcer installation script to copy the Git hooks into your local repository:

```
$ ./vendor/bin/wp-enforcer
```

If you'd like to require WP Enforcer for all developers on your project, you can add the following scripts to your `composer.json` file to have WP Enforcer automatically set up Git hooks on `composer install` and `composer update` (for more information, please see [Composer Scripts](https://getcomposer.org/doc/articles/scripts.md)):

```
{
	"scripts": {
		"post-install-cmd": [
			"wp-enforcer"
		],
		"post-update-cmd": [
			"wp-enforcer"
		]
	}
}
```

### Writing for WordPress.com VIP

[](#writing-for-wordpresscom-vip)

WP Enforcer includes built-in support for the [WordPress.com VIP coding standards](https://vip.wordpress.com/documentation/developers-guide-to-wordpress-com-vip/), simply add `--vip` when you run the `wp-enforcer` command (including in the post-install and post-update commands).

If you need to switch an existing project to the WordPress.com VIP coding standards, you can add the following to your project's phpcs.xml file (replacing "WordPress-Extra", if it's set):

```

```

### Using a custom ruleset

[](#using-a-custom-ruleset)

If you want to use a custom XML configuration file with PHP\_CodeSniffer, add `--ruleset=[FILE]` when you run the `wp-enforcer` command.

Configuration
-------------

[](#configuration)

PHP\_CodeSniffer allows you to [define a custom, default ruleset by creating a phpcs.xml file in your project root](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). WP Enforcer will automatically create a phpcs.xml file in your project if one doesn't already exist, but you can edit this to exclude certain files/directories, ignore specific rules, or load additional rulesets.

For a complete list of configuration options, see [the PHP\_CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml).

Adding to an Existing Project
-----------------------------

[](#adding-to-an-existing-project)

Adding coding standards to an existing project can be a painful process. WP Enforcer will only run the Git hook against changed files, but if the current codebase is a mess, making even standards cleanup commits becomes a giant hassle.

If you're adding WP Enforcer to a current project, it's recommended to follow the installation instructions above **in a new clean-up branch**, then remove the pre-commit hook:

```
$ rm .git/hooks/pre-commit
```

> **Reminder:** Use the `rm` command with care; double-check everything you're passing to it before you execute, as we'd hate to see you lose valuable repository information (or worse: your operating system).

This leaves you with a copy of PHP\_CodeSniffer, a phpcs.xml file, and the WordPress Coding Standards but removes the "don't commit improperly formatted code" restrictions. While still in your clean-up branch, work through the codebase and clean up coding standards, running PHP\_CodeSniffer manually as needed:

```
$ ./vendor/bin/phpcs
```

You may also run PHP Code Beautifier and Fixer, which can fix many common indentation and formatting issues automatically, using the PHP Code Beautifier and Fixer (phpcbf) command:

```
$ ./vendor/bin/phpcbf
```

Once CodeSniffer comes back clean, re-run the WP Enforcer installation script to restore the Git hook, forcing all future commits to be clean:

```
$ ./vendor/bin/wp-enforcer
```

Finally, merge your clean-up branch into master, kicking your project's coding standards compliance into high gear.

Bypassing WP Enforcer
---------------------

[](#bypassing-wp-enforcer)

If it's necessary to bypass WP Enforcer's sniffs for a particular commit (for instance, you're committing small chunks of a file that has older, non-compliant code) you may do so by using [`git commit --no-verify`](https://git-scm.com/docs/git-commit#git-commit--n).

It's recommended that WP Enforcer is only bypassed when making changes in legacy files that simply haven't been cleaned up yet. For more on integrating WP Enforcer with legacy projects, please see [Adding to an Existing Project](#adding-to-an-existing-project).

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.9% 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

Every ~92 days

Recently: every ~136 days

Total

7

Last Release

3267d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05f4d610f0de13ac1c23825f691fd05f2dd37ae9e8f0483e2dc4f1ca1e2bfb32?d=identicon)[stevegrunwell](/maintainers/stevegrunwell)

---

Top Contributors

[![stevegrunwell](https://avatars.githubusercontent.com/u/233836?v=4)](https://github.com/stevegrunwell "stevegrunwell (87 commits)")[![bswatson](https://avatars.githubusercontent.com/u/303029?v=4)](https://github.com/bswatson "bswatson (7 commits)")[![bhubbard](https://avatars.githubusercontent.com/u/3837?v=4)](https://github.com/bhubbard "bhubbard (3 commits)")[![bradp](https://avatars.githubusercontent.com/u/66798?v=4)](https://github.com/bradp "bradp (1 commits)")[![leewillis77](https://avatars.githubusercontent.com/u/1097338?v=4)](https://github.com/leewillis77 "leewillis77 (1 commits)")

---

Tags

coding-standardscomposer-packagesgit-hooksphp-codesnifferwordpresswordpressPHP\_CodeSniffercoding-standardsgit-hooks

### Embed Badge

![Health badge](/badges/stevegrunwell-wp-enforcer/health.svg)

```
[![Health](https://phpackages.com/badges/stevegrunwell-wp-enforcer/health.svg)](https://phpackages.com/packages/stevegrunwell-wp-enforcer)
```

###  Alternatives

[php-stubs/wordpress-stubs

WordPress function and class declaration stubs for static analysis.

19013.0M261](/packages/php-stubs-wordpress-stubs)[phpcsstandards/phpcsutils

A suite of utility functions for use with PHP\_CodeSniffer

6233.4M57](/packages/phpcsstandards-phpcsutils)[woocommerce/woocommerce-sniffs

WooCommerce sniffs

496.8M40](/packages/woocommerce-woocommerce-sniffs)[syde/phpcs

Syde PHP coding standards for WordPress projects.

1019.7k7](/packages/syde-phpcs)[wpsitecare/carelib

A collection of helpful functions to make creating an awesome theme more enjoyable.

164.6k](/packages/wpsitecare-carelib)[bostondv/bootstrap-ninja-forms

Adds Bootstrap classes to Ninja Forms

222.2k](/packages/bostondv-bootstrap-ninja-forms)

PHPackages © 2026

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