We need to improve our plugin’s post type supported features generator. Why? We need to include a mechanism to add new features when configured. Let’s walk through the refactoring process together, step-by-step. In this episode, you will improve the code and remove the specific implementation to make it reusable.
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.
Reusable Taxonomy Generator
Next, we need to move the taxonomy registration out of the FAQ Module and build our generator. Let’s use the same strategy as the post type, where on init we fetch all of the configurations and then loop through them, passing one-by-one to the registration handler. This episode should be very simple for you.
Building Custom Post Type Generator
Let’s start building our central custom post type generator. This is the module that handles: Receiving all of the custom post type configurations in your project Loop through each of them to do the following: Generate the features supported by the custom post type Generate the labels Build the arguments and then register the custom post type with WordPress We’ll start by copying and pasting the code from our FAQ module into the new Custom module. Then we’ll start working on refactoring it. Our goal is to remove all of the specific implementation code, i.e. to make it generic and […]
Creating Configuration Repository
Planning it Out
Let’s talk about and plan what we are going to do in this lab. We want to build a central repository, some module, that will be responsible for generating and registering post types, taxonomies, and shortcodes. There are different strategies for building a central repository: You can build a central plugin, such as Fulcrum1. Build a package and then publish it on Packagist. Then you’d use Composer to include it into your plugin. Or you can build a module and place it into one of your plugins for the project. 1Fulcrum is currently being rebuilt with some new goodies in […]
Configuration in ModularConfiguration Architecture
Let’s talk about the “configuration” part of ModularConfig. How do you design your code to be configurable? What does it mean? Why would you want to? Our codebase is filled with hard-coded parameters that specify the implementation we want. For example, registering a custom post type requires: Labels Supported features Arguments Post type name Imagine that your project has more than one custom post type. For example, let’s say you’re building a business-centric website and the client wants: FAQ Portfolio Testimonials Team bios That means, your project has at least four new post types. Think about that. Imagine what your […]
Modular in ModularConfiguration Architecture
Let’s talk about what the modular part of ModularConfig is. How do you design your code to be modular? What does it mean? The de facto in WordPress is to use snippets and boilerplates. This lab introduces you to the modular approach. Boilerplates give you a code structure or template. Then you edit the code to change the implementation. You may go to a website, fill out a form, and then that site automatically edits the code’s boilerplate to change it for you out of convenience. But the code is being changed to fit your project’s implementation. Snippets are tiny […]
What is Reusable?
What does reusable mean to you? Why would you want to use it? In software, the concept of being “reusable” means that you design your code such that you can reuse it project-after-project with minimal to no rework of the code. Think about that. Imagine the time you’ll save when you have a library of pre-built, well-tested, and proven code modules. You can then load the modules and quickly build your projects. But the key is: minimal to no rework of the code. That is what makes it reusable. Why? Think about it. If you pull in a snippet of […]
Lab Introduction
In this lab, you will learn about how to make your code reusable. You’ll learn about what it is, why you want to change your mindset to build code in a reusable way, and then how to do it. You are a professional web developer. It’s your career and/or business. You need to make money. Designing your code to be reusable is a strategy to reduce your time and thus costs over the entire lifecycle of the code itself. In other words, it makes you more profitable. To get started, make sure that you have completed Part 1 and 2 […]
Collapsible Content Plugin with OOP – Part 4
The best way to learn OOP is to build convert something that you already know from procedural to OOP. That will make the thought processes and methodologies more relatable for you. In Part 4, you will convert the Collapsible Content Plugin from procedural to Object Oriented Programming (OOP).