/
WordPress boilerplates
WordPress boilerplates
The following boilerplates are following WordPress industry standards best practices, conventions and tools. If you are not familiar with them please read our internal documentation on our WordPress development stack.
Plugin boilerplate
- In the root folder of the plugin we should find
index.php
andplugin-yourpluginname.php
which serves as the plugin init file. - All other PHP : must be located in
/inc/
, must follow WordPress coding style and coding standards and should ideally be object oriented. - External libraries and dependencies should be loaded using composer and will be located in
/vendor/
. - All static files should be located in
/assets/
, properly named and placed in the correct folder (css/
,js/
,images/
,fonts/
, etc... ). - Inline CSS and JavaScript should be strictly limited to passing variables to scripts and stylesheets. All other JS/CSS code should be
/assets/js/
and/assets/css/
and properly enqueued. Try to enqueue scripts and styles as smartly as possible to prevent cluttering the website with unnecessary resources. Ideally your assets should be minified,packed and mapped. - If a task runner is used (for linting or minification), npm-script should be used. While grunt and gulp are great tools, they are usually unnecessary for small projects like WordPress plugins and create unnecessary dependencies and points of failure.
- While you can write pure CSS, we encourage your to use SASS to write modern and modular CSS.
- In the root folder you will also find some configuration files for our different development tools and the plugin README file.
.gitkeep
files are here only for documentation purpose and can be deleted in production.- Please follow our guidelines regarding PHPDocs in WordPress projects
- Make sure to have an empty
index.php
in each sub-folder of your project to prevent directory indexing if the server is miss-configured.
Theme boilerplate
- In the root folder of the theme we should find style.css, functions.php as well as all our templates php files.
/template-parts/
contains re-usable template parts to be included usingget_template_part
and other WordPress native template helper functions./inc/
contains all other PHP files.- All our PHP files must follow WordPress coding style and coding standards and should be, when possible, object oriented (ie: Widgets, Metaboxes, ...).
- External libraries and dependencies should be loaded using Composer and will be located in
/vendor/
. - All static files should be located in
/assets/
, properly named and placed in the correct folder. - Inline CSS and JavaScript should be strictly limited to passing variables to scripts and stylesheets. All other JS/CSS code should be located in
/assets/js/
and/assets/css/
and properly enqueued. Try to enqueue scripts and styles as smartly as possible to prevent cluttering the website with unnecessary resources. Ideally your assets should be minified, packed and mapped. - If a task runner is used (for linting or minification), npm-script should be used. While grunt, gulp, etc. are great tools, they are usually unnecessary for small projects like WordPress themes and they create unnecessary dependencies and points of failure.
- While you can write pure CSS, we encourage your to use SASS to write modern and modular CSS.
- In the root folder you will also find some configuration files for our different development tools and the theme README file.
.gitkeep
files are here only for documentation purpose and can be deleted in production.- Please follow our guidelines regarding PHPDocs in WordPress projects
- Make sure to have an empty
index.php
in each sub-folder of your project to prevent directory indexing if the server is miss-configured.
, multiple selections available,
Related content
WordPress 101
WordPress 101
More like this
Using SASS/SCSS
Using SASS/SCSS
More like this
[Outdated] WordPress Developement Stack and Tools
[Outdated] WordPress Developement Stack and Tools
More like this
Web Development Resources
Web Development Resources
More like this
Copyright © 2024 The President and Fellows of Harvard College * Accessibility * Support * Request Access * Terms of Use