Updated 1. Plugin Architecture (markdown)

Ben Goldsworthy 2021-04-25 16:55:03 +01:00
parent ad887a0494
commit 8e8247f375

@ -2,97 +2,13 @@ This Wiki page outlines how the Plugin is constructed and what does what.
It has been initially produced as part of [Issue #87](https://github.com/markcheret/footnotes/issues/87), but is a living document and is intended to keep up-to-date with changes to the project structure. As such, it is only intended to provide a high-level overview; more detailed documentation can be found in the automatically-generated documentation [here](https://markcheret.github.io/footnotes/). It has been initially produced as part of [Issue #87](https://github.com/markcheret/footnotes/issues/87), but is a living document and is intended to keep up-to-date with changes to the project structure. As such, it is only intended to provide a high-level overview; more detailed documentation can be found in the automatically-generated documentation [here](https://markcheret.github.io/footnotes/).
# Top-Level Repo. Layout 1. Repo. Root
1. Plugin Source directory (`src/`)
| Dir. Name | Description | 1. Plugin classes sub-directory (`src/class/`)
|------|-------------| 1. Plugin Dashboard sub-directory (`src/class/dashboard/`)
| `assets/` | Files to be stored in the [`assets/` directory](https://plugins.svn.wordpress.org/footnotes/assets/) on the SVN repo. (e.g., screenshots for the Plugin information page). | 1. Plugin Widgets sub-directory (`src/class/widgets/`)
| `docs/` | Automatically-generated documentation files. | 1. Plugin stylesheets sub-directory (`src/css/`)
| `src/` | The source code for the Plugin itself. | 1. Plugin images sub-directory (`src/img/`)
| `_tools/` | Useful Bash scripts (@todo this should eventually be merged with `.github/workflows/`). | 1. Plugin scripts sub-directory (`src/js/`)
| `.github/` | GitHub Actions workflows and Issue templates. | 1. Plugin translations sub-directory (`src/languages/`)
1. Plugin templates sub-directory (`src/templates/`)
# Root Files
| File Name | Description |
|------|-------------|
| `CHANGELOG.md` | The full project changelog. |
| `CODE_OF_CONDUCT.md` | The project CoC. |
| `composer.json` & `composer.lock` | Declares Composer dependencies and scripts. |
| `CONTRIBUTING.md` | A guide to contributing to the project. |
| `LICENSE` | The license under which the project is released. |
| `package.json` & `package-lock.json` | Declares NPM dependencies and scripts. |
| `README.md` | Provides an overview of the project. |
| `SECURITY.md` | Provides guidance on reporting security-related issues. |
| `wpml-config.xml` | Used by the [WPML Plugin](https://wpml.org/documentation/support/language-configuration-files/) for translation. |
| `.distignore` | Lists files to ignore when building the Plugin for distribution (@todo this is not currently used). |
| `.eslintignore` & `.eslintrc.js` | Config. files for JavaScript linting. |
| `.gitignore` | Lists files to exclude from Git version control. |
| `.prettierignore` & `.prettierrc` | Config. files for JavaScript formatting. |
| `.stylelintignore` & `.stylelinttc.json` | Config. files for stylesheet linting. |
# Plugin Source (`src/`) Layout
## Plugin Source Root Files
| File Name | Description |
|------|-------------|
| `footnotes.php` | The Plugin entry point. |
| `includes.php` | Includes all of the PHP files. |
| `license.txt` | The license under which the Plugin is released. |
| `readme.txt` | The Plugin readme for display on the WordPress Plugin Directory. |
## Plugin Source Root Directories
| Dir. Name | Description |
|------|-------------|
| `class/` | Contains the Plugin PHP code, providing most of its functionality. |
| `css/` | Contains the Plugin stylesheets. |
| `img/` | Contains images used by the Plugin (@todo can this be merged with the root `assets/` dir?). |
| `js/` | Contains JavaScript files used by the Plugin. |
| `languages/` | Contains Plugin translation files for various languages. |
| `templates/` | Contains HTML template files used by the Plugin to render various page elements. |
## `class/` Sub-directory
### `class/` Root Files
Important files are highlighted in **bold** text.
| File Name | Description |
|------|-------------|
| `config.php` | Defines various constants (@todo rename to something more accurate). |
| `convert.php` | Provides various conversion functions. |
| `hooks.php` | Registers actions with various WordPress hooks. |
| **`init.php`** | Defines the Plugin object. |
| `language.php` | Loads translation settings. |
| **`settings.php`** | Defines the various Plugin settings. |
| **`task.php`** | Provides the core function of the Plugin. |
| `templates.php` | Loads the various template files. |
| `wysiwyg.php` | Provides integration with the WordPress WYSIWYG editor. |
### `class/` Sub-directories
| Dir. Name | Description |
|------|-------------|
| `dashboard/` | Contains the files that handle dashboard page construction. |
| `widgets/` | Contains the files that handle widget construction. |
### `class/dashboard/` Sub-sub-directory
#### `class/dashboard/` Files
| File Name | Description |
|------|-------------|
| `init.php` | Initialises the Plugin settings page. |
| `layout.php` | Defines a common interface for rendering dashboard pages (@todo merge with `subpage-main.php`) |
| `subpage-main.php` | Defines the Plugin settings page layout. |
### `class/widgets/` Sub-sub-directory
#### `class/widgets/` Files
| File Name | Description |
|------|-------------|
| `base.php` | Defines a base class for all widgets. |
| `reference-container.php` | Defines the Reference Container widget. |