A while back the Plugin Check tool was first announced, and version 1.0 is just around the corner. It’s a plugin to test your WordPress plugins 🤯. Specifically, it is a tool for testing whether your plugin meets the required standards for the WordPress.org plugin directory. Additionally, Plugin Check flags violations or concerns around plugin development best practices in areas such as internationalization, accessibility, performance, and security.
This joint effort between the plugin review and the core performance teams is why I want to make a case for using Plugin Check for your existing WordPress plugin. While the similar Theme Check plugin only focuses on theme submissions, Plugin Check’s goal is to be helpful even during development. The tool has two categories of sniffs: static checks (using static analysis tools like PHP_CodeSniffer) and runtime checks, where it actually activates your plugin to test it “live”.
Many of these checks or sniffs are not fully available yet, but here are some examples of what the test tool can flag in the future:
- Scripts and styles exceeding a certain file size
- Unnecessarily enqueueing scripts and styles on every page instead of only when needed
- Unnecessarily marking database options as autoloaded, slowing down the alloptions query
If more plugins follow best practices like these, the plugin ecosystem will be in much better shape performance-wise! That’s why now is the ideal time to start using the tool, so that you are setup for success already today and have a headstart once these checks are implemented.
Integrating Plugin Check
So how can you incorporate Plugin Check into your development workflow?
One way is to simply install the plugin on a local environment and run it against your plugin.
Another way, and what I would recommend, is to integrate it into your Continuous Integration (CI) pipeline.
For this reason I built a dedicated GitHub action. It automatically runs Plugin Check and posts all results as annotations on your source files so you know exactly where to look for resolving any errors or warnings.
Integration can be as simple as this:
name: 'build-test'
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- 'releases/*'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run plugin check
uses: WordPress/plugin-check-action@v1
Code language: PHP (php)
As for the static checks, if you are already using PHPCS, you don’t really need Plugin Check to run the same sniffs twice, so those can be disabled:
- name: Run plugin check
uses: WordPress/plugin-check-action@v1
with:
exclude-checks: |
late_escaping
plugin_review_phpcs
Check out the documentation for more examples and a full list of supported configuration parameters.
Looking for more ways to optimize your WordPress plugin’s performance? Check out my guide on setting up performance testing. Spoiler: there is a GitHub action too!
Leave a Reply