As you were building this module, did you notice the redundancies within the view files? We are using separate view files that have virtually the same HTML structures to them. That’s not good.
Why? Because if you need to make a change to the structure or one of the styling attributes, you have to remember to change it in three different places. That is an error waiting to happen. If you forget about one of them, then the change might get released and pushed out to your customers. That’s problematic.
Instead, the better strategy is to combine the shortcode and archive template views. In other words, we would have one container and one FAQ view file for shortcode and template. Let’s talk through this approach. How are we going to refactor?
Also, let’s commit our changes into the repository before we do any refactoring. Why? At each major stage of the code build, you want to capture a snapshot of those changes by committing them into your repository. It gives you a historical record, one that will help you as you look back to find what caused a problem.
And in making the commit, I write a bad commit message. You and I will walk through how to check the log, i.e.
git log, and then amend that commit message using:
git commit --amend -m 'the message goes here'
Who needs copy/paste? Right. Writing code from scratch is fun!
Total Lab Runtime: 05:11:56
- 1 Lab Introductionfree 07:51
- 2 Planning it Outfree 11:05
- 3 Module Architecturepro 17:12
- 4 Build the Basic FAQ Custom Post Typepro 06:04
- 5 Configuring the Custom Post Type Labelspro 18:33
- 6 Configuring the Custom Post Type Feature Supportspro 07:23
- 7 Configuring the Custom Post Type Optionspro 11:27
- 8 Flushing the Rewritespro 09:44
- 9 Planning the Taxonomypro 04:54
- 10 Build the Taxonomypro 05:33
- 11 Taxonomy Label Generatorpro 14:23
- 12 Flush Rewrite Rules - Taxonomypro 05:36
- 13 Architecting the Archive Pagepro 11:14
- 14 Serve Archive Template from the Pluginpro 10:41
- 15 Let Theme Override Our Archive Templatepro 21:29
- 16 Build the Archivepro 11:09
- 17 Build the Archive Viewspro 13:23
- 18 Set the Order Within the Topicpro 03:44
- 19 Review and Commit Changespro 02:34
- 20 Architect the Shortcodepro 15:23
- 21 Build the Shortcode - Single FAQpro 21:19
- 22 Fixing the Architecturepro 08:00
- 23 Define a WP_Query for Topicpro 16:10
- 24 Continue Building the Shortcodepro 11:39
- 25 Finish by Topic Shortcodepro 08:51
- 26 Planning the Refactorpro 08:01
- 27 Refactor FAQ Modulepro 19:58
- 28 Test, Fix, Commit, and Wrappro 08:36