Why you should start using Plugin Check now

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.

Screenshot of Plugin Check in WordPress admin, where you can select a plugin to test and the specific categories to focus on

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.

Screenshot of file annotations on GitHub added by the Plugin Check action.

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: swissspidy/wp-plugin-check-action@v1Code 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: swissspidy/wp-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!


Comments

2 responses to “Why you should start using Plugin Check now”

  1. Thank you for this great insight!

    I was using PHPCS but would love to switch to this instead if it has the same checks included given the additional benefits.

    1. I wouldn’t see it as a replacement for PHPCS, as Plugin Check only covers a small part of the WordPress coding standards and best practices. Plus, Plugin Check is more for one-off testing, whereas PHPCS can be integrated more into the development workflow. So if you are already using PHPCS, keep it for sure, and then use Plugin Check for everything beyond that.

Leave a Reply

Your email address will not be published. Required fields are marked *