A skeleton WordPress plugin
Open Issues: 3
- php: ^8.0
- alleyinteractive/composer-wordpress-autoloader: ^1.0
This package is auto-updated.
Last update: 2023-03-31 18:17:35 UTC
This is a skeleton WordPress plugin that can scaffold a WordPress plugin. This
template includes a base plugin file, autoloaded PHP files, unit tests powered
by Mantle, front-end assets compiled via Webpack,
and Continuous Integration via GitHub Actions. Actions are
configured to test the plugin and also build it for release. A
v0.1.0-built tags will be created with all dependencies included
for use when submoduling a plugin. The built branches will include Composer
dependencies and any compiled front-end assets (if using them).
The plugin supports front-end assets which can be enqueued inside
src/assets.php or from within an entry points
index.php file. For plugins that don't require front-end assets, the configuration script below will prompt you to delete the front-end files if you don't wish to use them.
Follow these steps to get started:
- Press the "Use template" button at the top of this repo to create a new repo with the contents of this skeleton.
php ./configure.php) to run a script that will replace all placeholders throughout all the files.
- Have fun creating your plugin! 🎊
Create WordPress Plugin
Tags: vendor_name, create-wordpress-plugin
Stable tag: 0.1.0
Requires at least: 5.9
Tested up to: 6.1
Requires PHP: 8.0
License: GPL v2 or later
A skeleton WordPress plugin.
You can install the package via composer:
composer require alleyinteractive/create-wordpress-plugin
Activate the plugin in WordPress and use it like so:
$plugin = Create_WordPress_Plugin\Skeleton\Example_Plugin(); $plugin->perform_magic();
npm run test:watch to keep the test runner open and watching for changes.
happen when running development or production builds.
composer test to run tests against PHPUnit and the PHP code in the plugin.
entries directory and entry points
All directories created in the
entries directory can serve as entry points and will be compiled with @wordpress/scripts into the
build directory with an accompanied
index.asset.php asset map.
Enqueuing Entry Points
You can also include an
index.php file in the entry point directory for enqueueing or registering a script. This file will then be moved to the build directory and will be auto-loaded with the
load_scripts() function in the
functions.php file. Alternatively, if a script is to be enqueued elsewhere there are helper functions in the
src/assets.php file for getting the assets.
Scaffold a block with
create-block command to create custom blocks with
@wordpress/create-block and follow the prompts to generate all the block assets in the
Block registration, script creation, etc will be scaffolded from the
bin/create-block/templates/block/ templates. Run
npm run build to compile and build the custom block. Blocks are enqueued using the
load_scripts() function in
Updating WP Dependencies
Update the WordPress dependency packages used in the project to their latest version.
@wordpress dependencies to their latest version use the packages-update command:
npx wp-scripts packages-update
This script provides the following custom options:
--dist-tag– allows specifying a custom dist-tag when updating npm packages. Defaults to
latest. This is especially useful when using
@wordpress/dependency-extraction-webpack-plugin. It lets installing the npm dependencies at versions used by the given WordPress major version for local testing, etc. Example:
npx wp-scripts packages-update --dist-tag=wp-WPVERSION`
WPVERSION is the version of WordPress you are targeting. The version
must include both the major and minor version (e.g.,
6.1). For example:
npx wp-scripts packages-update --dist-tag=wp-6.1`
Please see CHANGELOG for more information on what has changed recently.
This project is actively maintained by Alley Interactive. Like what you see? Come work with us.
The GNU General Public License (GPL) license. Please see License File for more information.