Composer
In general, this file shouldn't look all that different from our package.json file or other config files found in the theme.
In this config, we're specifying PHP 8 and Composer 2.0 while tapping into a handful of plugins to allow for our scripts to run:
- PHP Code Sniffer
- PHPCompatibilityWP
- PHP CodeSniffer
- WP-CLI
- WP Coding Standards
- WordPress Stubs
- PHP ACF Stubs
This theme uses Composer to run a few different processes:
PHP Linting
In the package.json file, lint:php taps into Composer by running composer run-script lint. In doing so, the linter will look for any issues found in our PHP issues related to coding standards. As this is a WordPress theme, the default is the WordPress coding standards to keep in line with WordPress' overall goals for code quality.
PHP Code Sniffer will also find any warnings or breaking errors in your PHP, so if you forget to add that semicolon or have some code that may be prone to security or performance issues, PHPCS will let you know.
Language File Generation
By default, the starter theme is translatable into other languages. In the package.json file, build:pot taps into Composer by running composer run-script pot. In doing so, we're building the .pot file for our theme. This is the language file which contains the strings in your base language which can then be translated into other languages.