2022-09-30 12:54:37 -06:00

84 lines
4.2 KiB
Markdown

Boilerplate WordPress Plugin
===
A starter plugin based on my own experience.
Installation
---------------
### Requirements
This theme requires the following dependencies:
- [Node.js](https://nodejs.org/)
- [Composer](https://getcomposer.org/)
### Quick Start
Clone or download this repository then change its name to something else such as `{namespace-}amazing-plugin`. Next you'll need to edit or rename various files to give your new plugin a proper naming scheme. All files are referenced from the root of the
First, change the "name", "version", "author", "license", and any other relevant fields in `/composer.json` and `/package.json`.
As an example, let's use `Stark` as the namespace and `Alloy` as the plugin name. First, I would rename the base directory from `nmsp-plugin-name` to `strk-alloy`. Then I would search for the following and replace them as such:
| Search: | Replace |
| --------------------------------- | ---------------------------- |
| NMSP_PLUGIN_BASE_DIR | STRK_ALLOY_BASE_DIR |
| nmsp-plugin-name-text-domain | strk-alloy-text-domain |
| Namespace Plugin Name | Stark Alloy |
| nmsp_plugin_name_menu | strk_alloy_menu |
| nmsp-plugin-name-menu-slug | strk-alloy-menu-slug |
| NMSP_PLUGIN_NONCE | STRK_ALLOY_NONCE |
| NMSP_PLUGIN_SLUG_REWRITE_NAMES | STRK_ALLOY_REWRITE_NAMES |
| NMSP_PLUGIN_SLUG_PAGE_NAME | STRK_ALLOY_PAGE_NAME |
| nmsp_plugin_slug_page_name | strk_alloy_page_name |
| PluginNamespace | Stark |
| PluginNamespaceTests | StarkTests |
| nmsp-plugin-name-menu-slug | strk-alloy-menu-slug |
| Namespace Plugin Name | Stark Allow |
| nmsp_plugin_name_settings_title | strk_alloy_settings_title |
| nmsp_plugin_app | strk_alloy_app |
| nmsp-plugin-admin-css | strk-alloy-admin-css |
| nmsp-plugin-admin-js | strk-alloy-admin-js |
| nmspPluginAdminApi | strkAlloyAdminApi |
| nmsp-plugin-admin-app | strk-alloy-admin-app |
| nmsp-plugin-name.css | strk-alloy.css |
| nmsp-plugin-name.js | strk-alloy.js |
| nmspPluginApi | strkAlloyApi |
| nmsp-plugin-front-app | strk-alloy-front-app |
| nmspcli | strkcli |
Then I would rename the following:
| Original | New Name |
| --------------------------------------- | --------------------------------- |
| `/nmsp-plugin-name.php` | `/strk-alloy.php` |
| `/includes/class-nmspcli.php` | `/includes/class-strkcli.php` |
| `/resources/css/nmsp-plugin-name.css` | `/resources/css/strk-alloy.css` |
| `/resources/js/nmsp-plugin-name.js` | `/resources/js/strk-alloy.js` |
### Setup
You'll need to run a few commands to set up the plugin for further development.
```bash
composer install
npm install && npm run compile
```
### Available CLI commands
- `composer lint:wpcs` : checks all PHP files against [PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/).
- `composer lint:php` : checks all PHP files for syntax errors.
- `composer make-pot` : generates a .pot file in the `languages/` directory.
- `npm run compile:css` : compiles SASS files to css.
- `npm run compile:rtl` : generates an RTL stylesheet.
- `npm run watch` : watches all SASS files and recompiles them to css when they change.
- `npm run lint:scss` : checks all SASS files against [CSS Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/).
- `npm run lint:js` : checks all JavaScript files against [JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/).
- `npm run bundle` : generates a .zip archive for distribution, excluding development and system files.