General rules
To make sure that it is made as easy as possible for other developers to understand the general flow of the folder structure, there are some general rules to follow:
- A ‘master’ file at the root should exist for any file that has grown too large, and has needed to be divided in to multiple files/directories
- Files that are not the ‘master’ should be sectioned in to purposefully named directories
- If a file becomes difficult to scan consider breaking it in to multiple files and, potentially, it’s own directory with multiple files in.
Examples of good practice can be found below.
WordPress Themes
index.php
style.css
script.js
header.php
footer.php
functions.php (master file)
library (main WordPress specific functions for the theme)
navigation.php
theme-support.php
enqueue-scripts.php
widget-areas.php
partials (reused code used in multiple templates)
sidebar_left.php
slider-hero.php
WordPress Plugins
namespace>_main.php (master file)
admin (Backend directory)
css
admin-styles.css
js
admin-scripts.js
partials
class-<namespace>-admin.php (Back-end code)
public (Frontend directory)
css
public-styles.css
js
public-scripts.js
partials
class-<namespace>-public.php (Front-end code)
includes
class-<namespace>.php (master file for this directory)
class-<namespace>-activator.php (activation processes)
class-<namespace>-deactivator.php (deactivation processes)
SCSS directories for child themes
style.scss (master file)
config (nothing in here should render in the .css file)
_config.scss
_globals.scss
_accessibility.scss
_functions.scss
_mixins.scss
design (all of the generic theme styling)
_content.scss
_header.scss
_footer.scss
_menus.scss
_widgets.scss
features (styles applied to a feature, unique to a page)
_custom_widget.scss
_sliding_banner.scss
_hero_images.scss