Building a Plugin for WordPress

Home / Guides / Building a Plugin for WordPress
4 Lessons
19m read.
Advanced
Build Plugins for WordPress

This course will take you through creating a WordPress plugin for your site using PSR-4 – PHP Standard Recommendation – 4. This recommendation specifies the process of autoloading classes from the file paths. The standard used in this tutorial also specifies where to place files that will be auto-loaded once our plugin is activated.

Course pre-requisites

The guide pre-requisites are very easy to learn and acquire knowledge on. Take off a few minutes to look them up and grasp the basic concepts about them.

Basic PHP and Object Oriented Programming.

Basic PHP and Object Oriented Programming.

You should have some background knowledge in PHP and Object Oriented Programming Principles

Composer Package Manager for PHP

Composer

You should know what composer is for you to really make the most out of the course. Composer is a package manager for PHP, similar to NPM for JavaScript.

WordPress

WordPress – Plugins and Blocks

Since we will be creating a plugin, you need to have an idea or two about plugins in WordPress. You also need to know what Blocks are since the tool we will be creating will be on how to display the reusable block.

Who is this guide for?

This guide is meant for anyone aspiring to build their own WordPress plugin. It could be a custom plugin with custom functions for a specific website or that commercial plugin that you wish to sell.

What will you learn?

This guide will instruct you through how to best organise folders and files in your plugin.

You will learn how to structure plugins the right way (or the MRK WP way) that should grow from small to large projects without failure.

At the end of this course, you will have an idea of how the autoloading for the classes works in PSR-4.

In addition to this, your plugin will also display the reusable blocks menu in the WP Admin area.

What tools/software do you need?

Local for WP
Local for WP

WP Local

Local enables you to set up a local WordPress development environment. With this tool, you can connect your website hosted via WP Engine to your local development environment.

Local enables you to pull down your site from the server to your local environment and vice versa. You can also push files from your local environment to the WP Engine server.

You can download Local from their website.

GITHUB

Github

We will be using Github for version control and sharing all our code from these tutorials. You can find MRKWP on Github via this link: https://github.com/MRKWP/

VS Code IDE

VS Code – Code Editor

You will need a code editor to write and edit your code. In this tutorial, we will be using the VS Code. You can download it via this link: https://code.visualstudio.com/download.

You can use any other code editor you are more comfortable/familiar with.

Table of Contents