We want our data store to be globally accessible to all plugins and the theme. But we want to control the access and interaction with the items in the store. Let’s talk about why both of these are important features.
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.
Defining the Container: Data Type & Retain
Let’s define the container’s data type and how to retain the items in the container. There are different strategies: JSON file database in-memory cache – such as Redis in-memory using a PHP data type We’ll discuss the problems and strengths of each. If you’d like to learn more about in-memory PHP data type, checkout the Array Data Type in the PHP Docx.
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.
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.
Migrate Site Footer & Widgets
Let’s continue now by working on the footer widgets and site footer area.
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.
PHP Variables Bootcamp
In order to be proficient in PHP, you need to first know variables. It’s learn and do time. In this lab, you are focusing on user-defined variables, the data they represent, how they are passed and assigned into function parameters’ list, naming, and their scope. For Pro members, you learn more about the PHP internals, how variables are linked to their data, and how memory moves around under the hood.
PHP does Type Juggling and determines the data type of the variable based upon its context. You can learn more about PHP Type Juggling in the Docx.
Variable Scope When Including Files
Let’s see what happens when you include files into another file. What happens with the variables between the files? In this episode, you will write code to include a view into a function and then access the variables between the files.