This video aims to demonstrate how to create a simple WordPress plugin.
In this specific tutorial, we will be focusing on building a contact form plugin, it will allow you save submissions into the database using a Custom Post Type, as well as send the submission via email. You’ll also have a plugin options page to add any special options you’d like to customise how your plugin works. I’ve tried to address security issues like Sanitisation, Nonces and ways to protect your plugin and WordPress installation in general.
There’s obviously a lot more stuff we can do with it, but to keep this tutorial simple as possible, I’ve addressed the most common needs for a plugin. In future, I will add to this specific plugin extra features. So stay tuned!
Github Repo:
Really Simple WP Theme used in this video:
00:00 Start
00:20 Basic Introduction
02:40 Plugin Folder setup
03:20 Securing your plugin
08:17 Create your Plugin Class
09:28 Installing Carbon Fields into Plugin via Composer
13:19 Set up Composer Autoload & Constant for Plugin Path
15:28 Instantiate our Class
16:05 Breaking our Plugin into Separate Files for Simplicity
18:20 Setting up Carbon Fields for our Custom Plugin Options
34:45 Creating a Shortcode for our Contact Form
38:16 Create Form Template for Front End Display
41:43 Set up REST Endpoint to Receive Post Requests
44:34 Set up AJAX to Point to our REST Endpoint
51:13 Handle Form Data (Nonce check, Send Email)
1:12:58 Displaying Submissions in the WordPress Admin (Custom Post Type)
1:27:53 Set Up Meta Box to Display Submission Data
1:45:10 Creating Custom Columns on Submission Post Type
1:54:07 Enable Searching Custom Meta Data in Submission Table
1:58:55 Enqueue CSS for Contact Form
2:05:15 Sanitising Form Data
2:15:20 Make Plugin Options Work in Our Plugin
2:24:24 Sort Plugin Menu Order
2:26:03 Make Submissions Only Accessible By Admins
2:27:01 Summary & Ending
source