4 Ways to Set up a WordPress Plugin Boilerplate.

wp scaffold plugin my-plugin
npx wp-strap plugin
WPPB.me Boilerplate
composer init --type=wordpress-plugin
{
"name": "chigozieorunta/my-plugin",
"description": "A simple plugin to illustrate Composer boilerplate setup.",
"type": "wordpress-plugin",
"license": "GPL",
"authors": [
{
"name": "chigozieorunta",
"email": "chigozieorunta@yahoo.com"
}
],
"minimum-stability": "dev",
"require": {}
}
{
"name": "chigozieorunta/my-plugin",
"description": "A simple plugin to illustrate Composer boilerplate setup.",
"type": "wordpress-plugin",
"license": "GPL",
"authors": [
{
"name": "chigozieorunta",
"email": "chigozieorunta@yahoo.com"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {
"MyPlugin\\": "src/"
}
}

}
composer dumpautoload -o
"require": {},
composer install
<?phpnamespace MyPlugin;class HelloWorld {
private $message;
public function __construct() {
$this->message = "Hello World!\n";
}

public sayHello() {
return $this->message;
}
}
<?phprequire_once __DIR__ . '/vendor/autoload.php';$message = new MyPlugin\HelloWorld();echo $message->sayHello();
<?phprequire_once __DIR__ . '/vendor/autoload.php';use MyPlugin\HelloWorld;$message = new HelloWorld();echo $message->sayHello();
php index.php
Hello World!

--

--

--

Full Stack Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

5 steps to debug your complex SQL queries in Firebolt

Accelerating Digital Transformation: What Every CEO Needs to Know About Software Delivery…

Do you know any number you can make with a combination of a power of 2 ?

Product release: react-channel and adding Kotlin

Using Nested Forms with Sinatra

Checkout Field Editor for WooCommerce

Traefik 1.6 — Get Our Latest tetedemoine!

Flutter & Shaders — An initial look

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chigozie Orunta

Chigozie Orunta

Full Stack Engineer

More from Medium

How HTML page structure can improve your SEO

Five Data-Backed Reasons to Hire Remote WordPress Developers

Programmatically creating a new order in Woocommerce

10 Chrome Extensions… [Part 2]

An image showing chrome icon written “Google Chrom Xtensions”