This project is no longer actively maintained. We recommend using the WordPress Coding Standards and use their recommended configuration for your project.
WP Engine Coding Standards for WordPress
If WordPress Coding Standards offer a baseline for developers to use when contributing to or extending WordPress, think of WP Engine Coding Standards as an additional layer of best practices that:
- help developers achieve greater consistency within their themes and plugins
- assist developers in meeting the requirements of a WP Engine Solution Partner
- ensure that all software listed in the WP Engine Solution Center is of the highest quality
- offer users maximum performance and security benefits when using those themes and plugins in a modern hosting environment (PHP 7+)
The information included here walks you through the process of installing and using WP Engine Coding Standards to lint your code.
WP Engine Coding Standards (WPECS) uses Composer to install these main dependencies:
If you're using Homebrew on Mac, you can install Composer with: brew install composer
. Otherwise, follow the official installation instructions for Composer.
- Clone the repository and install the dependencies:
git clone [email protected]:wpengine/wpengine-coding-standards.git
cd wpengine-coding-standards
composer install
- Link your coding standards to your
phpcs
installation:
phpcs --config-set installed_paths /path/to/wp-engine-coding-standards
You can also install the coding standards as a dependency in your local project. Here's how
- Add the following repository to your composer.json
"repositories": [
{
"type": "git",
"url": "https://github.com/wpengine/wpengine-coding-standards.git"
}
]
- Manually add the following to
require-dev
in composer.json
"wpengine/wpengine-coding-standards": "dev-master"
-
Run
composer install
orcomposer update
to ensure your project is configured. -
You can now use
WP-Engine
orWP-Engine-Strict
in any IDE that uses the local phpcs. If you already have a phpcs.xml in your project, simply add the following to it:
<rule ref="WP-Engine-Strict"/>
Clone or download this repository. From terminal, navigate to the download location and install WPECS globally with the following command:
make install
You will then be able to run WPECS from any directory.
Running make install
will install WPECS dependencies and register coding standards with PHPCS.
- Note you might need to manually move the binaries to your path, or properly set path, if make fails.
Run the phpcs
command line tool on a given file or directory, for example:
phpcs --standard=WP-Engine wp-load.php
WP-Engine Coding Standard
The required standard for secure WordPress development.
wpecs .
WP-Engine-Strict Coding Standard
The recommend standard for WP Engine authored plugins.
wpecs --standard="WP-Engine-Strict" .
While the following is based on the parent WordPress Coding Standards, simply swap out the ruleset you need for WP-Engine
or WP-Engine-Strict
as appropriate.
- PhpStorm : Please see "PHP Code Sniffer with WordPress Coding Standards Integration" in the PhpStorm documentation.
- Sublime Text : Please see "Setting up WPCS to work in Sublime Text" in the wiki.
- Atom: Please see "Setting up WPCS to work in Atom" in the wiki.
- Visual Studio: Please see "Setting up PHP CodeSniffer in Visual Studio Code", a tutorial by Tom McFarlin.
- Eclipse with XAMPP: Please see "Setting up WPCS when using Eclipse with XAMPP" in the wiki.
USAGE: wpecs [--strict] [phpcs-options] Run the specified path against the WP Engine Coding Standards Attempt to fix sniffs against the WP Engine Strict Coding Standards
For help understanding errors or warnings and suggestions for troubleshooting specific issues, please refer to the full WP Engine Coding Standards Documentation.
All external contributors to WP Engine products must have a signed Contributor License Agreement (CLA) in place before the contribution may be accepted into any WP Engine codebase.
- Submit your name and email
- 📝 Sign the CLA emailed to you
- 📥 Receive copy of signed CLA
❤️ Thank you for helping us fulfill our legal obligations in order to continue empowering builders through headless WordPress.