This template should be used to create all new WordPress plugins.
Please replace this text with a brief description of your plugin.
This plugin requires PHP version 8.2 or above.
Install the dependencies:
composer installRun the tests:
vendor/bin/kahlan specRun the linters:
vendor/bin/psalm --show-info=true --find-unused-psalm-suppress
vendor/bin/php-cs-fixer fixNote that this project aims to create fully typed code, with no Psalm output. We use a Psalm plugin to provide type annotation and stubs for WordPress globals, so the need for explicit annotation should be minimal.
Developers should aim for the output of Psalm to look something like this using the strictest error level:
❯ vendor/bin/psalm --error-level=1 --find-unused-psalm-suppress
Target PHP version: 7.4 (inferred from composer.json).
Scanning files...
Analyzing files...
------------------------------
No errors found!
------------------------------
Checks took 0.01 seconds and used 6.608MB of memory
No files analyzed
Psalm was able to infer types for 97.7273% of the codebaseTo create a new plugin start by modify the following:
index.php- Add Metadata values for the new plugin (name, version, etc).index.php- Rename this file to the plugin name e.g.my-new-plugin.php.composer.json- Package Metadata and namespace (psr-4).load.php- Define the namespace.README- Update to contain any specific instructions and information for the plugin.
As we're distributing the vendor.phar file it may be a good idea to add an autoload-suffix" to the config object in composer.json and then re-generate the lock file. This ensures that there are no other namespace clashes and a unique hash is generated in the composer.lock and vendor.phar file. This is especially important if other plugins have been based off this template.
For example in composer.json:
"config": {
"autoloader-suffix": "MyNewPluginNameHere",
"platform": {
"php": "8.2"
}
},