A demo plugin to serve as a boilerplate for developers to understand how to extend the GiveWP Donation plugin for WordPress.
- Clone this repository to your local
- Remove the
.git
directory - Run
php build.php
from the CLI - Run
composer install
from the CLI - Run
npm install
from the CLI - Update this README (see below for a starting point)
To compile your CSS & JS assets, run one of the following:
npm run dev
— Compiles all assets (except Form Extension assets) for development one timenpm run watch
— Compiles all assets (except Form Extension assets) for development one time and then watches for changes, supporting BrowserSyncnpm run dev:form-extension
— Compiles Form Extension assets for development one timenpm run watch:form-extension
— Compiles Form Extension assets for development one time and then watches for changes, supporting BrowserSyncnpm run start
— Compiles all assets for development one time and then watches for changes
GiveWP follows a domain-driven model both in core and in add-ons. Each business feature defines its own domain, including whatever it needs (settings, models, etc.) to do what it does. It's also important these domains are portable, that is, they are not bound to the plugin and could move to or from another plugin as needed.
For these reasons, each add-on has two primary directories for handling its logic:
- src/Addon
- src/Domain
The src directory handles business domain logic (i.e. a specific feature). The src directory should have no files in the root, but be a collection of folders. Each folder represents a distinct domain. Even if there is only one domain for the add-on, it should still live inside a domain directory.
It is possible for an add-on to have multiple domains, but it will always have at least one. Feel free to duplicate this directory and make more. This directory is just the starting point for the initial domain.
This unique domain directory is responsible for the fact that the add-on is a WordPress plugin. Plugins do things such as activate, upgrade, and uninstall — the logic of which should be handled there. All GiveWP add-ons also check for compatibility with GiveWP core, and this also is handled here.
The src/Addon
directory may reference code in the src
directory, but not the other way around.
No domain code should reference (and therefore depend on) the src/Addon
directory. Doing this
keeps the dependency unidirectional.
If running npm run dev
throws an error then check whether the images
folder exists in your addon directory
under src/Addon/resources
.
- If the
images
folder does not exist then create one. - If the
images
folder isn't required then remove the code fromwebpack.config.js
.
DELETE ABOVE THIS LINE WHEN REWRITING README
[Write an introduction to what this addon is for]
- Clone this repository locally
- Run
composer install
from the CLI - Run
npm install
from the CLI
To compile your CSS & JS assets, run one of the following:
npm run dev
— Compiles all assets for development one timenpm run watch
— Compiles all assets for development one time and then watches for changes, supporting BrowserSyncnpm run hot
— Compiles all assets for development one time and then watches for hot replacementnpm run dev
— Compiles all assets for production one time