One of our jobs is to build quality code that is reusable again and again without changing the codebase. Ideally, we’d like to configure what’s different and have the codebase the same for all of our projects. In Part 3, you will convert the Collapsible Content plugin into the ModularConfiguration design pattern by moving all runtime configurable parameters into configuration files Then the codebase will be made reusable. The actual implementation then is determined by the configuration file that’s loaded. This approach will save you time.
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.
Let’s Build the Collapsible Content Plugin – Part 1
Let’s get you started building custom (from scratch) WordPress plugins. In Part 1 of this series, you are going to build the basics of the Collapsible Content plugin. As you are building it with Tonya, you’ll learn deeply about custom plugin development, file structures, jQuery, PHP, WordPress core, shortcodes, Gulp, and much more.
Yoda Conditions: To Yoda or Not to Yoda
Tonya explains the Yoda conditions programming style. She discusses its intent and the problem it seeks to solve. A handy guide and litmus test are included to help you decide when to use it in your programs. Both PHP and JavaScript examples are provided to test your knowledge.
if/else Backwards Code Pattern – Code Smell
Code Smell Alert: A common code pattern that I see is where the if/else logic and the if conditional is backwards. I call this the “if/else backwards code pattern.” This code pattern makes the code less readable, which decreases its quality. There are two clues to let you know that you have stumbled into this pattern: The if conditional is set off of a false state. Typically you’ll see a not operator (!) as your clue. The if logic is setting a default state. But that is the job of the else. Smelly Version This is the smelling code pattern: […]
Smelly Code: the “if/return true/false” Code Pattern
When doing a conditional expression, it’s a smelly code pattern to then return true or false. Why? The conditional expression already returns a true or false state. Therefore, you do not need to be so verbose and hardcode a boolean return. Here is the smelly code pattern: Refactor this code down to one line to make it more readable. It’s less code too (skinny). Strive to reduce your code and make it more simple. If you see this pattern in your code, then refactor it. Remember, you want your code to be as skinny (as few lines) as possible.
Building the HTML View File
It’s time to build out the HTML structure and put it into the view. What is a view? Why do you want to use it? Let’s talk about the qualities of clean, quality code. You will also learn about how to load the view as well as the variable scope. To learn more about variable scope and including files, go to the PHP Variables Bootcamp.
Procedural, functional, or OOP?
Question: Which programming paradigm should I do? Answer: It doesn’t matter. Nope. You can program in any of these paradigms. What matters is you write clean, quality code and that you are proficient in one of these paradigms.
Falsey Conditional Expression
What constitutes a falsey state? And when there is one variable in a conditional expression, what is it doing? How does it work? In this episode, you will build code to explore the falsey conditional expression. You will learn about what and why the state is falsey.
Code Tip: Understanding the Ternary Operator
Let’s talk about the ternary operator. It can be confusing for many. In this video, Tonya puts the if/else side-by-side with its equivalent ternary to help you know and understand it. The alternate syntax tip is found here. This tip is valid for JavaScript and PHP.
Introduction to PHP Object-Oriented Programming (OOP) for WordPress
Object-oriented programming (OOP) seeks to emulate real objects through code. In life, objects have both characteristics, those attributes that define it, and behavior. OOP is a completely different approach to programming than procedural. As such, its actual implementation is often misapplied and misunderstood. In this hands-on lab, you will get an introduction to OOP. You’ll explore how to implement it for your WordPress plugins and theme.