Skip to content

Check the theme against the WordPress Coding Standards on every PR - #275

Merged
amjadr360 merged 2 commits into
mainfrom
chore/coding-standards
Nov 16, 2026
Merged

amjadr360 merged 2 commits into
mainfrom
chore/coding-standards

Conversation

@amjadr360

@amjadr360 amjadr360 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

The theme already had the WordPress Coding Standards tools set up (PHPCS with WPCS, ESLint, Stylelint, Prettier), but nothing ever ran them, so main had built up about 950 violations. This PR fixes all of them and adds a Lint check that runs on every pull request, so new ones can't slip in. npm run lint runs the same checks locally.

  • Almost all of the diff is whitespace from the auto-fixers. The few real changes: the navigation script now gets the theme version in its URL, so browsers stop caching an old copy; one unused filter argument is gone; and "Saving..." becomes "Saving…", which translators will see as a new string.
  • PHPCS now also checks PHP 7.4 compatibility, the extendable text domain and the function prefix.
  • Stylelint no longer flags CSS rule order. Reordering the theme's CSS to satisfy that rule would change which styles win. The generated stylesheets are skipped, because they are rewritten every time they are generated.
  • Open PRs that touch the same PHP, JS or CSS files will need main merged in and npm run lint run before their checks go green.

Tested on WordPress 7.1 and PHP 7.4 with WooCommerce: the front end, animations, post editor and site editor all load with no errors, and the reformatted product search template opens in the site editor with no invalid blocks.

The PHPCS, ESLint, Stylelint and Prettier setups were already here, but
nothing ran them, so main had drifted to hundreds of violations. A Lint
workflow now runs all four on each pull request, and `npm run lint` runs
the same set locally.

PHPCS gains PHPCompatibilityWP pinned to the theme's PHP 7.4 floor, and
checks the `extendable` text domain and function prefix. Pattern headers
skip the file-docblock sniffs: they are registration metadata.

Stylelint stops flagging rule order (descending specificity, duplicate
selectors): reordering theme CSS to satisfy them changes which rule
wins. The generated stylesheets are skipped, since a fix made here is
overwritten the next time they are generated.
Most of the diff is the fixers' whitespace. The changes a reviewer
should look at:

- The navigation script now carries the theme version, so a release
  busts its browser cache like every other theme asset.
- The WooCommerce template filter drops its unused query argument.
- The animation config reads through wp_json_file_decode().
- "Saving..." becomes "Saving…", a new string for translators.
- product-search-results.html takes the Prettier layout the other
  templates already use; the site editor opens it with no invalid
  blocks.

Checked on WordPress 7.1, PHP 7.4, with WooCommerce: the front end, the
animations, and the post and site editors load with no errors.
@amjadr360
amjadr360 marked this pull request as ready for review November 16, 2026 01:01
@amjadr360
amjadr360 merged commit b6a80d6 into main Nov 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant