We have three shortcodes: QA, teaser, and FAQ. Let’s move their configurations out of the codebase and into their own configuration files. We’ll walk through creating the files and adding in the new parameters we specified in the last episode.

Developing & Empowering WordPress Developers
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.
0 Videos Runtime
We have three shortcodes: QA, teaser, and FAQ. Let’s move their configurations out of the codebase and into their own configuration files. We’ll walk through creating the files and adding in the new parameters we specified in the last episode.
0 Videos Runtime
Let’s start by building the beginning of our Shortcode boilerplate within the Custom Module. This boilerplate code will be responsible for: Registering the shortcode configuration from each of the modules, plugins, and/or theme within your project. Loading each configuration file into memory. Storing the configuration for the shortcode to access. Registering the shortcode and its callback with WordPress, i.e. add_shortcode and processing and rendering the shortcode’s HTML. Let’s walk through the thought process together step-by-step.
0 Videos Runtime
Let’s test out all of our new code and make sure everything works as intended. There will be a few typos and boo boos. You’ll see me think through when I’ve made a mistake and find the root cause.
0 Videos Runtime
We want to use one label generator for both the custom post type and taxonomy. Why? Because both custom types share a number of the labels, i.e. we don’t want to be redundant. Therefore, before we can refactor the label generator, first we need to audit all of the labels.
0 Videos Runtime
Custom post types and taxonomies both need custom labels to improve the user’s experience with the back-end interfaces. They both share some of the same label structures. Therefore, it makes sense to build one custom label generator that serves both the taxonomies and post types. In this episode, you will move the label generator out of the FAQ module and into the Custom module. You’ll be refactoring the code to accept the runtime configuration parameters.
0 Videos Runtime
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.
0 Videos Runtime
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.
0 Videos Runtime
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 […]
0 Videos Runtime
0 Videos Runtime
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 […]
Know the Code flies on WP Engine. Check out the managed hosting solutions from WP Engine.
WordPress® and its related trademarks are registered trademarks of the WordPress Foundation. The Genesis framework and its related trademarks are registered trademarks of StudioPress.
This website is not affiliated with or sponsored by Automattic, Inc., the WordPress Foundation, or the WordPress® Open Source Project.