Many projects require more than one custom post type or taxonomy. If you are building a typical business-centric website, then your client may need a FAQ, Portfolio, Testimonials, and more. Each of these requires a custom post type. Obviously, you would not want to add a Portfolio module to the Collapsible Content plugin. Displaying your client’s project portfolios to show off their work and services is not related to and does not have the same intent as what the Collapsible Content plugin. Therefore, you would build a separate Portfolio plugin. Let’s move our temporary portfolio code out of the FAQ […]
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Rewrite Rules
In this episode, you and I will move the rewrite rules handler out of the FAQ Module and put it into our new Custom Module. We’ll simplify the process during plugin activation by removing all the code and replacing it with delete_option( ‘rewrite_rules’ );.
Custom Post Type Generator – Registration
Next, you and I need to build a registry mechanism for our custom post type generator. We need a way for plugins to hook into our custom module and pass each custom post type’s configuration to us for processing. Let’s talk about the different approaches to achieve this feature. There are different strategies that we can use: Use the WordPress event-driven engine by building a custom filter We could build a configuration store. For the custom post type, let’s build a custom filter event. Later for the taxonomy, we’ll build a configuration store. Why? I want to give you two […]
Link the FAQ into the Taxonomy Generator
It’s time to link the FAQ Module into our new Taxonomy Generator. This episode has a twist for you as you’ll discover the code is repeating between the post type and taxonomy configuration loading. You get to learn about how to use the same callback for two separate filter events and then using current_filter() to determine which one invoked the callback. It’s a slick approach I use often.
Build the Topic Taxonomy Config
Like we did for the post type, let’s extract the runtime configuration parameters out of the FAQ Module and move them to the configuration file. You and I will walk through the process together, step-by-step and talk about the strategy of identifying these parameters, the extraction process, and then how to layout the configuration file.
Test it Out
Let’s test the registration code for a single custom post type. This test will ensure that our automatic supported features and label generations do work as we expect.
Loading the Config File
In the last episode, you extracted the FAQ’s custom post type runtime parameters out of the FAQ module. In this episode, I want to show you how PHP can load this file and then assign the returned array to a variable. This technique demonstrates the configuration architecture and design approach. After this episode, my goal is to help you visualize how we inject these parameters back into the code for use when a web page is requested by a viewer or user.
Build the FAQ Custom Post Type Config
I think it will best to start with extracting the runtime configuration parameters out of the codebase and move those into a configuration file. Let’s walk through the process together, step-by-step and talking about the strategy of identifying these parameters, the extraction process, and then how to layout the configuration file.
Wrap it Up, Review, and Commit Changes
Let’s do a little clean up before you commit these changes. Then let’s commit the final changes to your GitHub repository. What’s the whole point to the ModularConfig architecture? The point is to help you to build your projects faster. ModularConfig puts code to work for you to generate code for you. It abstracts away redundant code so that you have less code to build, test, and maintain. It saves you a ton of time! What happens when you remove the common tasks and redundant code? What happens? It takes less code to build your projects. If a bug happens, […]
Test the Shortcodes
In this episode, you and I are going to test all three shortcodes. Here is the test content we’ll use: