Before you write a single line of code, first you want to sit down, think through your project, and plan out what you are going to build. Listen to me. Don’t just start writing your code. It will take you less time to plan it out first and then build it. What are we building? What are the building blocks of the plugin? Let’s break down the project into key components and figure out what we are building. It’s our big picture roadmap.
Let’s get you started on the right foot. This episode will introduce the lab to you. You’ll spin up a Sandbox development website and get UpDevTools installed.
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).
Let’s run the fast approach tests. You’ll look at the SQL queries using Query Monitor as well as the data dumps you put into Core. We’ll talk about the code, how it works, and ways that you can enhance it for more versatile use cases. Then we’ll compare the two approaches. Wrap it Up Congratulations! You did a great job. We covered a lot of information in this lab including learning about database table relationships, how to join tables together, filtering down to what you need, aliasing the columns you get back, performance, scalability, and how to build a SQL […]
Let’s look closer at WordPress Core for the object $wpdb->get_results(). You’ll see that it’s a wrapper for the PHP constructs: mysql_query – PHP 5.5 or less (it’s been removed from PHP 7) mysqli_query – PHP 5 and 7 We’ll also discover that WordPress provides a filter event where the $query is exposed. This event is named “query.” We’ll convert our plugin to remove the snippet from get_results and build a callback for the “query” event. You can use this callback whenever you need to analyze or customize a query. You’ll also do a quick overview of the fast approach code.
We have our SQL query that we want to use for our project. Let’s talk about how to translate that into WordPress. How does WordPress communicate with the database? What tools are available? WordPress provides you with a set of tools to communicate with the MySQL database. This wrapper will save you time and lots of lines of code. The object you’ll use is the global $wpdb. At the time this lab was developed, WordPress does not provide a wrapper for this global object. Therefore, we have to use the global directly. In this episode, you’ll explore a couple of […]
In this episode, you’ll walk through the slow approach’s code, which can be found here. Let’s make sure you understand what’s happening at a macro level before we run the tests on it.
This hands-on lab is more advanced. It will teach you about more advanced SQL commands, such as JOIN and GROUP BY. You’ll also experiment with $wpdb, which is WordPress’ MySQL Communication wrapper. In this episode, let’s get you ready to start this lab. You’ll learn about the objectives and what you’ll be doing, as well as getting your sandbox ready to go. To get started, you are going to want to install this lab’s companion plugin into your Sandbox project. This plugin is freely available on GitLab. Just follow the instructions in the video (or the README.md) to install. Next, […]
WordPress gives you the means to add new post types. In this hands-on lab, you will explore configuring and registering a new custom post type. You are actively building a team biography plugin, where team members are displayed on a business-centric website.
Let’s talk about how I found the event name to use to turn the editor back on again in the previous video. Then you’ll look at WordPress Core to see where and how it turns off the editor for the specific Posts Page. You’ll also look at WordPress Core for the function remove_post_type_support. It’s time to reverse engineer WordPress Core.