WordPress.org

Plugin Check with Playground CLI

While working on the WordPress.org MCP server (yes, WordPress.org now accepts plugin submissions directly from your you AI assistant), I wanted to make it easy for AI agents to run plugins against Plugin Check before trying to submit a plugin to the Plugin Directory for review.

The best Claude could come up with was a convoluted prompt, explaining how to set up wp-env, set up Plugin Check, and run it locally. It was long, required a lot of steps, and gave ample opportunity for AI agents to get stuck or confused and give up.

While participating in Automattic’s AI Enablement training in New York, I managed to come up with a much easier way with the help of WordPress Playground (Thank you Adam and Bero for you help)! Turns out it supports running inline CLI commands now, albeit still requiring a blueprint.json file.

The whole command can now be condensed down to:

  1. Create blueprint.json
{
  "steps": [
    {"step": "installPlugin", "pluginData": {"resource": "wordpress.org/plugins", "slug": "plugin-check"}},
    {"step": "wp-cli", "command": "wp plugin activate plugin-check my-plugin"},
    {"step": "cp",
      "fromPath": "/wordpress/wp-content/plugins/plugin-check/drop-ins/object-cache.copy.php",
      "toPath": "/wordpress/wp-content/object-cache.php"}
  ]
}
  1. Run the check
npx @wp-playground/cli php \
  --blueprint=blueprint.json \
  --mount=/path/to/my-plugin:/wordpress/wp-content/plugins/my-plugin \
  --quiet \
  -- /tmp/wp-cli.phar plugin check my-plugin \
  --categories=plugin_repo --format=json \
  --error-severity=7 --warning-severity=6 \
  --include-low-severity-errors --exclude-checks=prefixing

If it accepted an inline json blob as a blueprint, it could even be a one-liner! Albeit a very long one.


Pretty cool what’s possible with WordPress Playground these days. And if you’ve not had a chance to check out WordPress.org’s MCP yet, take it for a spin! Let me know what you think.

Standard

3 thoughts on “Plugin Check with Playground CLI

    • Nice catch! Correct, it only runs static checks.

      However, it looks like runtime checks can be enabled with just a few changes to the blueprint:

      {
        "steps": [
          {"step": "installPlugin", "pluginData": {"resource": "wordpress.org/plugins", "slug": "plugin-check"}},
          {"step": "wp-cli", "command": "wp plugin activate plugin-check my-plugin"},
          {"step": "cp",
            "fromPath": "/wordpress/wp-content/plugins/plugin-check/drop-ins/object-cache.copy.php",
            "toPath": "/wordpress/wp-content/object-cache.php"}
        ]
      }
      

      Two things worth noting:

      1. The plugin under test has to be active.
      2. The cp step has to come after the last wp plugin … step. Plugin Check registers an after_invoke hook that auto-deletes the drop-in when any wp plugin subcommand finishes, so an earlier copy gets deleted before plugin check runs.

      I’ll update the MCP prompt with it soon.

Leave a comment