Let’s build the centralized data, state, and configuration parameters store in an Object Oriented (OOP) architecture. What You Will Learn X Prerequisites See the list of prerequisites and suggestions on the series landing page.
Let’s build the centralized data, state, and configuration parameters store in a static class architecture. What You Will Learn X Prerequisites See the list of prerequisites and suggestions on the series landing page.
Let’s build the centralized data, state, and configuration parameters store in a procedural function-based architecture. What You Will Learn X Prerequisites See the list of prerequisites and suggestions on the series landing page.
It occurred to me that there were strategies I did in the last episode which need further explanation such as: How mb_substr works 05:21 Why did I use mb_substr instead of mb_strpos 08:40 Refactoring to make the code more clear 09:21 How does function_exists() work and why/when do you use it 11:01 Should you use namespacing or function_exists() for helper utilities In this episode, let’s dive into each of these strategies to help you figure out the best approach for you.
In WordPress, we register callbacks to events by using add_action or add_filter. In the last episode, you learned that you must specify the fully qualified name to invoke a function (i.e. run it) outside of the namespace. This applies to add_action or add_filter. In this episode, you will learn why as well as a shorthand version using the magic constant __NAMESPACE__.
Whew, you did it! Congratulations for completing this lab! Let’s review what you learned as well as show you the code here on Know the Code. Remember, namespacing is only available in PHP version 5.3.0 and up. That shouldn’t be a problem for you. Why? Because 5.3 stopped being supported back in 2014. It’s old. Anything older than it can be problematic. Therefore, build your code to be at least 5.3 and up. You can check the PHP supported versions by clicking here.
In this episode, let’s stop and talk about how you architect your code. Code should be built in modules. These modules are not assembled into your plugin or theme. It’s not snippets of code. Rather, they are complete, fully-tested, ready-to-go component or feature modules. All you have to do is change the configuration and none of the codebase. That makes it a reusable module. For example, let’s say you are building a theme. In your code libraries, you have modules for: WooCommerce bbPress LearnDash MemberPress BuddyPress Customizer and more The theme you are building needs WooCommerce, bbPress, and Customizer. You […]
Next, let’s take a real world plugin and convert it from prefixing to namespacing. Let’s convert Tom McFarlin’s Easier Excerpts plugin. You can install this plugin within the WordPress back end by going to Plugins > Add New and then type in Easier Excerpts. In this episode, you will walk through the steps to remove the prefixing, add in the namespacing, and provide better function naming that starts with a verb.