PHP allows you to make an assignment within a conditional expression. What order are the expressions evaluated? In this episode, you’ll roll up your sleeves and write some code to find out while Tonya explains it to you.
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.
Functions in the Conditional Expression
A conditional expression can be comprised of functions, literals, constants, and variables. How do functions work? What is the evaluation order? In this episode, you will build expressions with functions and discover the flow and order.
Anatomy of a Conditional Expression
Let’s talk about what a conditional expression is, what’s its purpose (intent), and what it does. In this episode, we setup this series for you to deeply learn about conditional expressions.
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.
WordPress Tip: Do You Have to Specify all the Arguments for add_action and add_filter?
The question I often get is: If I only need a couple of the arguments that a filter or action makes available, do I have to specify all of them in the callback function for add_filter() and add_action(). For example, if a filter, such as shortcode_atts_{$shortcode} has 4 arguments, but I only need 3, do I have to wire it up for all 4? In this video, Tonya explains why you have control over what you want to receive by looking into WordPress core at apply_filters().
PHP Tip: Use array_merge and Not foreach to Merge Defaults
In this quick tip, Tonya shows you how to reduce your code when you want to merge default parameters (settings) together with the implement. She shows you a shortcode example from WordPress which uses a foreach() to accomplish what one line of code and do, i.e. using array_merge.
WordPress Tip – Match Arguments and Parameters When Calling Functions
You have to match the number of arguments to the number of required parameters for a PHP function. A common error is when you forget to specify the number of arguments to send when wiring up an event callback for add_action() or add_filter(). In this video, Tonya shows you why you have to specify this number.
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.