Let’s talk about naming of variables, functions, etc. in your code. In this video, you will learn some handy guidelines on naming by intent to let your code express what it’s doing, why it exists, how to use it, and what to expect from it. This tip is valid for all programming regardless of the language or technology.
A Collection of Insights, Tips, Tricks, & Lessons Learned
A collection of stories, insights, tips, tricks, and lessons learned to help you develop the way you think about solving problems through code and technology.
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.
PHP Tip: What makes a conditional expression false (falsey state)?
In this video, you will learn the intent of this `if` conditional expression as well as what evaluates to false. This is known as checking the falsey state.
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 – Put in the Shortcode Name for shortcode_atts
Help out your fellow developers and put the shortcode name as the third parameter in the function shortcode_atts(). Why? To allow other developers to modify the default attributes you specify with your shortcode. Tonya shows you how this works and the benefit to the site owner.
PhpStorm Tip – Multiple Selections (Multicursor)
Ever wonder how to quickly select multiple instances of a literal, variable, function, or comment? PhpStorm provides you with a keymapping for making multiple selections (multicusors). Check it out. Thank you to Jeffrey Way at Laracasts.com for the tip!
PhpStorm Tip – One Keystroke to Automatically Format to WordPress Coding Standard
Ever wonder how to automatically reformat your code to a particular coding standard in PhpStorm? In this video, you’ll learn how to configure PhpStorm to apply the WordPress PHP Coding Standard and then the key strokes to auto format your code.
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.