Boilerplate code for starting a new WordPress plugin.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Chris Wiegman 9c0f6ea8d4
Update composer versions
2 months ago
.vscode Initial commit 4 months ago
Docker Initial commit 4 months ago
plugin Cleanup some links 3 months ago
tests Initial commit 4 months ago
.gitignore Initial commit 4 months ago
.jshintignore Initial commit 4 months ago
.jshintrc Initial commit 4 months ago
.lando.yml Initial commit 4 months ago
Makefile Fix obsolete container reference 3 months ago
README.md Cleanup some links 3 months ago
composer.json Update composer versions 2 months ago
composer.lock Update composer versions 2 months ago
gulpfile.js Initial commit 4 months ago
package-lock.json Update dependencies 3 months ago
package.json Update dependencies 3 months ago
phpcs.xml Initial commit 4 months ago
phpunit.xml.dist Initial commit 4 months ago

README.md

WordPress Plugin Starter

A starter plugin to get you going quickly with a new WordPress plugin.

What's included

  • WordPress
  • Debug Bar
  • Query Monitor
  • PHP 7.4
  • Mailhog
  • Starter plugin files
  • Starter PHP Unit Tests
  • Configuration, including Xdebug, for VSCode
  • Linting for PHP and JavaScript files using WordPress coding standards

Developing a real plugin with this code

Developing a real plugin with this code is easy.

First, rename all appropriate instances of the my name (Chris Wiegman) and the starter plugin name (wordpress-plugin-starter) throughout the codebase. For now, you'll want to do this manually as the case and spacing character can differ upon usage.

All plugin source code should go in the plugin folder. This is what is mapped as the plugin in your test site. Classes should go into the plugin/lib folder using any namespace as a subfolder. The plugin will automatically load all classes created in this fashion. See the autoloader in the main plugin file for more details.

All JavaScript files should go in the plugin/scripts folder for sake of automatic minification.

While I plan to, at some point, setup a script that will handle renaming and more in the future, it just isn't there yet. Other planned improvements include using a more modern autoloader and switching off of Gulp.

Setup and Usage of the Development Environment

A fully featured development environment is included using PHP 7.4 and more. Scripts to run commands including setup and more use make as a task runner. See the instructions below for getting started.

Before starting your workstation will need the following:

  1. Clone the repository

git clone https://gitea.chriswiegman.com/chriswiegman/wordpress-plugin-starter.git

  1. Start Lando
cd wordpress-plugin-starter
make start

When finished, Lando will give you the local URL of your site. You can finish the WordPress setup there.

WordPress Credentials:

URL: https://wordpress-plugin-starter.lndo.site/wp-admin Admin User: admin Admin Password: _password

Build and Testing

The plugin will build the .pot file for internationalization as well as minified versions of any JavaScript files:

make build

Note, assets will also build during the install phase.

The project uses the WP_Mock library for unit testing. Once setup run the following for unit tests:

make test-unit

We also use PHP_CodeSniffer with WordPress Coding Standards and JSHint with WordPress' JS Standards. Linting will automagically be setup for you if you use Visual Studio Code. If you want to run it manually use the following:

make test-lint

or, to run an individual lint, use one of the following:

make test-lint-php
make test-lint-javascript

You can run all testing (all lints and unit tests) together with the following:

make test