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.
Ins and Outs of PHP Namespace for WordPress
PHP Namespace gives you the means to encapsulate your code modules to improve readability and prevent code naming collisions. In this hands-on lab, you will migrate from prefixing convention to PHP namespacing. You will learn the ins and outs of namespacing.
Wrap It Up
Let’s recap what you learned in this hands-on lab. You’ll also add in animation effects too. Congratulations! You did a great job.
Caching
In past episodes, we talked about caching a collection of elements to avoid multiple returns to the DOM to fetch the elements. Let’s talk about it now in the context of the script you are writing. You’ll see an additional “why” of caching.
Scope
Scoping deals with who has access to the memory. Every language provides scoping rules. JavaScript is different from PHP. Let’s talk about scoping for JavaScript.
jQuery’s $
The variable $ does not have context and does not natively mean jQuery. It can also stand for Mootools and any value. You need to specifically initialize jQuery to the $ variable. Let’s talk about it in relationship to the IIFE. I’ll show you how to pass jQuery into the IIFE (yes, you can pass in objects) and then assign it to the variable for use within the IIFE’s scope.
Meet the IIFE
IIFE stands for Immediately Invoked Function Expression and is pronounced as “iffy.” Let’s talk about what it is, why and when you want to use it, and then how to write it. You’ll learn about scope too.
Declaring Functions
JavaScript has different approaches to declaring and defining functions: constructor, expression, anonymous, named, etc. Let’s take a look at the most popular that you’ll likely see.
Loading Scripts
Let’s get out of the browser’s console and write your first script. In this episode, you will simply create a script file and then learn how to load that file into the DOM through WordPress. Yes, you will learn about enqueuing script files using the WordPress event wp_enqueue_scripts and its function wp_enqueue_script. Psst…if you need to learn about WordPress’ event-driven engine (you know that thing in Core that handles hooks/filters), go take this hands-on lab. Get the Sandbox Plugin