A bootstrap project for any WordPress plugin complete with:
- Widget
- Shortcode
- Admin settings
- PHP class autoloader for namespace support
- ES6 JS modules
Search/replace these strings in this order to rename the plugin:
Bigup\Plugin_Bootstrap Bigup\Plugin_Bootstrap\ bigup_plugin_bootstrap bigup-web-plugin-bootstrap Plugin Bootstrap A bootstrap project for any WordPress plugin BIGUP_PLUGIN_BOOTSTRAP_URL BIGUP_PLUGIN_BOOTSTRAP_PATH
Once you have cloned the repository, cd to the root of the project and install the dependencies:
composer install
npm install
I recommend installing phpcs and ESLint VS Code plugins. You can then set VS Code to format on save and highlight errors in realtime.
Install phpcs system-wide
composer global require squizlabs/php_codesniffer
Install phpcs VS Code Plugin
- Open Visual Studio Code.
- Press Ctrl+P on Windows or Cmd+P on Mac to open the Quick Open dialog.
- Type ext install phpcs to find the extension.
- Press Enter or click the cloud icon to install it.
- Restart Visual Studio Code when prompted.
note: If you see an error with phpcs not being found, you may need to set the path for the phpcs executable manually in the plugin settings. You can either configure this to point to the absolute path of the global phpcs binary, or the relative path of the local phpcs binary in the project.
See here for more instructions.
Install ESLint VS Code Plugin
- Open Visual Studio Code.
- Press Ctrl+P on Windows or Cmd+P on Mac to open the Quick Open dialog.
- Type ext install dbaeumer.vscode-eslint to find the extension.
- Press Enter or click the cloud icon to install it.
- Restart Visual Studio Code when prompted.
Add this config to your settings.json
to enable format on save:
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
See here for more instructions.
Full linting for CSS/SASS, JS/TS, PHP, markdown and more.
This project uses npm package @wordpress/scripts to lint CSS, JS and markdown files, plus some other helpful tasks.
To lint and fix PHP, phpcs is used along with composer package wp-coding-standards/wpcs to enforce WordPress code style.
See package.json and composer.json for npm and composer scripts respectiveley and/or see the package links above for further instructions.
To run a script:
npm run [script name]
You can override the preconfigured script code styles with your own config by placing a config e.g. eslintrc.json
in the root. Your config will be merged with the default settings.
Note This bundle setup is a work in progress! To-do: create separate bundles for admin/front-end
This project is setup to make it easy to go from raw code to bundled, minified assets in a distributable zip. To achieve this Webpack is configured independantly of the WordPress scripts.
npm run build
Runs Webpack using the config in the root. It bundles and minifies JS and CSS from src and outputs bundle.js and bundle.css in /public
. These bundles are then enqueued in the PHP Initialisation class.
npm run zip
uses zip-webpack-plugin
This project is licensed under the MIT License.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.