Skip to content

Directory structure

The boilerplate comes with a predefined directory structure to help you organize your plugin files. It is designed to give you a great starting point whether you’re developing small or large WordPress plugins.

.
β”œβ”€β”€ app
β”œβ”€β”€ inc
└── src
└── blocks

Directories

Here is a brief overview of these directories, and what they are used for:

The app directory

The app directory is for PHP classes that should be autoloaded. Out-of-the-box, the directory contains several classes:

  • the Plugin class which serves as the main entry point for the plugin.
  • the Blocks class that automatically handles the Gutenberg blocks registration.
  • the Settings class is an example that demonstrate how to add a settings page to the WordPress admin dashboard.

You can add more classes in this directory to add the core features or functionalities of your plugin.

The inc directory

The inc directory is for PHP functions and other files to support the plugin’s core features and functionalities. Out-of-the-box, you will find some helper functions and a translation file in this directory.

The src directory

The src directory is for your JavaScript and Stylesheet files. When you run the npm run start or npm run build command, the files in this directory will be compiled and saved in the dist directory. You can add more files here to include additional styles or scripts in your plugin. To learn more, check out our guide on the Enqueuing scripts and styles guide.

The src/blocks directory

The src/blocks is a special directory for Gutenberg blocks. The boilerplate comes with a sample block to help you get started with creating custom blocks. You can add more blocks here, and they will be automatically loaded and registered by the plugin. To learn more, check out our recipe on Adding a block guide.