Lab Introduction
Lab: Reusable Meta Box Module
Video Runtime: 13:01
In the last lab, you and I built a custom meta box for the Subtitle custom fields, adding the feature of subtitles for posts. What happens if you need to add more than one meta box to a project? Using the code from the last lab, you would have to copy and paste the meta box file, change what’s different and each of the function names, and then create a new view file. In doing so, your code is redundant with repeating code patterns. Plus, it takes you time to make the codes, meaning an error could occur.
What if you need to make a change in the functionality of the meta box generation and that change affects all of your custom meta boxes? You would have to make that change for every single meta box. In doing so, you are spending exponential amounts of your time as well as creating opportunities for errors.
To emphasize the point, in this lab, you’ll create another meta box. Then we’ll do a code review to identify the repeating patterns. I want you to embrace the reusable mindset. Together, we’ll go through the steps to transform our meta box code into a reusable module that accepts a configuration file, handles everything for you, and calls your view file. A black box code generator if you will.
To start, let’s rename our plugin, change the bootstrap’s plugin file header DocBlock and namespace.
-
Need the code for the new bootstrap file? Click here
There’s a time to code and …. yup, that sums it up.
Episodes
Total Lab Runtime: 04:38:42
- 1 Lab Introductionfree 13:01
- 2 Add Another Meta Box - Portfoliopro 11:05
- 3 Code Review - Repeating Patternspro 07:17
- 4 The Reusable Mindsetfree 07:52
- 5 Separating Implementation from Business Logicfree 06:31
- 6 Plan It Outpro 06:35
- 7 Laying Out the Architecturepro 08:16
- 8 Configuration Model - Add Parameterspro 11:58
- 9 Configuration Model - Render Parameterspro 10:36
- 10 Configuration Model - Save Parameterspro 07:23
- 11 The Implementation Configurationspro 08:33
- 12 Fix the Config Modelpro 01:53
- 13 Architect the ConfigStore - Part 1pro 07:33
- 14 Architect the ConfigStore - Part 2pro 13:34
- 15 Loading the Configuration into the Storepro 16:04
- 16 Get Configuration or Parameter from the Storepro 12:43
- 17 Wire Meta Box to the ConfigStorepro 13:03
- 18 Merging Configuration with the Defaultspro 10:50
- 19 Get Only the Meta Box Keys From ConfigStorepro 22:29
- 20 Rethink the Save Functionalitypro 07:58
- 21 Is it Okay to Save?pro 05:41
- 22 Remap Custom Fields Config for Savepro 11:54
- 23 Fix the Default Mergepro 18:03
- 24 Walk Through & Test Our Save Functionpro 08:53
- 25 Improving the Renderpro 09:30
- 26 Optimization, Review, & Housekeepingpro 10:13
- 27 Wrap it Upfree 09:14