Plugin structure
How a brand plugin is laid out, and why distribution files decide the layout
Brand plugins are the wp-plugin-* repositories whose sole purpose is serving a
single brand, such as wp-plugin-bluehost.
Distribution files drive the layout
We have the plugins set up with .distignore and .distinclude files which
expect certain file organizations. We want our distribution files to be as small
as possible but also contain any required files. Following a standard folder
structure across our modules will ensure that we have files in proper places for
this.
To understand these rules, please refer to these files in the plugin. They are
followed for all build steps locally and via GitHub workflows. For example, any
tokens must be ignored in the distributed files and build files for security
reasons, so in the .distignore file we ignore all hidden dot files with the
line ./*.
Main plugin file
The main plugin file name must mirror the directory name, and application
scaffolding belongs in bootstrap.php rather than the main file. Both are
covered in WordPress PHP.
Modules inside plugins
Modules are installed as Composer dependencies of a brand plugin and follow their own layout. See module structure.
Related
-
Naming files and directories
Directory and filename conventions, and where they bend to a framework's expectations
-
Module structure
The directory layout every module shares, and what ends up in the distributed zip
-
WordPress PHP
PHPCS setup, namespacing, bootstrapping and the defensive habits we expect in PHP