Building a Plugin 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.
You should have some background knowledge in PHP and Object Oriented Programming Principles
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 – 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?
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
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 – 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
Using PHP Standards in WordPress
WordPress powers over 50% of the internet. According to W3Techs, WordPress is currently used by 60.1% of all websites. T
Reusable Blocks Menu in WP Admin
Watch Tutorial What you will learn in this video: In this video, you will learn how to create a PSR-4 WordPress Plugin.
PSR-4 Helpful Links
Here are some links to extra resources and documentation you will use in this course