An object has both characteristics and behavior. It is built from a blueprint. To help you grasp the concept, let’s relate software objects to physical, real world objects. We are going to talk about homes in a new subdivision. You’ll see how the concept of homes (objects) and be translated into software objects and OOP.
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.
What is Object-Oriented Programming (OOP)?
The acronym OOP stands for object-oriented programming. OOP is a programming paradigm, meaning it’s another approach for how you architect and build code. OOP is programming that is oriented to (focused on) objects. It seeks to emulate the real world. What does that mean? Let’s relate this concept to the objects you know. Look around your office. Grab an ink pen. Now, look at it. An ink pen is mass-produced from a blueprint. Millions of ink pens were made just like yours. Each pen has characteristics, such as the color of the ink, cap or click, body color, and size. […]
Lab Introduction
Welcome to the Introduction to PHP OOP for WordPress lab. This is a gentle introduction to object-oriented programming. This lab starts where the typical WordPress developer is at, meaning I’ll start with procedural and help you to make the leap over into OOP. In this lab, you’ll learn what OOP is and what it is not. You’ll be writing some code to help you see how it works. OOP is a different mindset. It can be difficult to wrap your mind around. Therefore, you need to work with me. You’ll also need to focus on the intent and concepts. Therefore, […]
Building Strings with Dots and Variables
PHP gives you the means to build dynamic strings. You can run a function and then append a string literal to the end of it. You can embed a variable into a string. You can append the value of the variable to another string. You see it in the themes and plugins, as well as WordPress Core. Let’s talk about it. With the PHP concatenation operator, i.e. . (dot), you are able to smoosh two string values together to make a new string. For example, look at this code: What is the above code doing? It’s loading a file using […]
Putting it All Together
As I told you before, the key is to read code. The more code that you read, the more you’ll learn and grow. The skills you gained in this lab empowered you to be able read the basic structure of themes and plugins. No, you might not be able to understand all of the code. But you can see the patterns. You’ll see the functions and know the basics of how they are defined and called. You’ll know that some can accept information to work on while others don’t need anything. You’ll see default parameters defined and know how that […]
PHP 101: Gentle Introduction to WordPress Programming
Welcome to WordPress programming. In this hands-on code building lab, you are going to get a gentle introduction into PHP programming. This lab assumes that you do not know anything about programming or PHP. You’ll start at the beginning and incrementally learn the major concepts and instructions you’ll encounter. It’s PHP 101.
Add a FAQ Feature to the Collapsible Content Plugin – Part 2
In this hands-on lab, you and I will walk through the entire process of adding a new feature to an existing WordPress plugin. You’ll start with the Collapsible Content plugin and then add a FAQ feature to it. This feature will require you to plan, think, and execute building a custom post type, custom taxonomy, advanced SQL queries, custom archive, and shortcode.
PHP 101: Building Strings
We need to build a string from dynamic content. We’ll have a string literal and we need to insert some content into it at the appropriate spot. How do we do it? There are a couple of techniques you can use in PHP including embedding variables and functions and using a formatted string with sprintf or printf.
Test Entry Footer Terms
Next, we need to test our new rendering code. Does it work on each of the pages and only for those that have terms? Let’s test it together. Here is the department taxonomy term rendered into the entry footer of a post: Here it is for a team bio single: Then we need to commit our work to GitHub to save it. Let’s do that together.
PHP 101: Concatenating Assignment Operator
The term “concatenating” means that we are smooshing two strings together by appending the one on the right to the one on the left. The result is a new string value. For example, let’s say that a variable $post_meta has a value of ‘[post_categories] [post_tags]‘. You want to append another shortcode to the end of it. How do you do that? There are two different ways to achieve this and make an assignment.