Plugins - 3ev/wordpress-core GitHub Wiki
Wordpress Core provides a set of conventions for structuring your plugins. These include a file structure for your plugin code and a number of improved ways of hooking into the Wordpress core.
###File structure
The recommended file structure for your plugins with Wordpress Core is something like this:
- my-plugin/
- config/
- acf-json/
- actions.php
- post_types.php
- shortcodes.php
- src/
- MyPluginVendor/
- Action/
- Model/
- Shortcode/
- views/
- my-plugin.php
There are two main directories here; config/ and src/. config/ will contain all of your hook registrations, and src/ will contain all of your plugin's classes and templates.
###PSR-4 autoloading
It's recommended that you use PSR-4 autoloading for your plugin's source code, with everything nested under a top-level namespace that corresponds to your plugin (or plugins) vendor.
If you're using this library then you'll already be using Composer, which makes PSR-4 autoloading a breeze. You just need to add the following config to your composer.json:
{
"autoload": {
"psr-4": {
"MyPluginVendor\\": "path/to/plugins/my-plugin/src/MyPluginVendor"
}
}
}