This episode is different. In this one, we’re talking strategy. It’s time to think about how we should approach setting the theme’s version. Should we use the minified or full stylesheet? Does it matter? Hmm, first, we need to look at how WordPress does it. Then we’ll look for a mechanism to change between the files. Let’s walk through WordPress Core and look at how it extracts the stylesheet’s version. We’ll explore wp_get_theme(). Spoiler alert: there is no mechanism. Bummer. Okay, then let’s talk through if we need to change our code or not. If you use an automated minifier, […]
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.
Version Numbering Scheme
Before we go any further, let’s talk about version numbering scheme. There is no best practice or set standard that all must adhere to. Rather, each group, company, or team needs to define and standardize their version numbering system. WordPress uses a three sequence numbering scheme: 4.8.1, where the third sequence is a minor release. I recommend that you read this document, especially if you are going to work in Core. Other libraries, frameworks, and applications define and use their own numbering scheme. Take a look at Wikipedia’ Software versioning article. Quickly you’l notice that there are multiple strategies that […]
Cache Busting Strategies
Now you understand what a query string is, why WordPress uses it for the version, and why it’s a problem. Now, let’s talk about different strategies to ensure we get the benefits of cache busting. The strategies are: Use a CDN. This is your best strategy for performance. Make sure that all asset resources that you enqueue or load into the DOM have a version assigned to them. ALL of them. Let WordPress handle changing the static URL. Place the assets into a folder that is named by the version number. Embed the version number into the static URL.
Understanding the Problem
In this episode, let’s discuss what the problem is with using URL query string. It’s important for you to understand the problem first in order to solve it. Right? Do this episode before you move on. Let’s start by analyzing the speed of this lab using Pingdom’s website speed test. Here’s a link to the test that I ran. Running the test, it explains why it scores query strings: Resources with a “?” in the URL are not cached by some proxy caching servers. Therefore, the problem is that some proxy caching servers may not cache the resources. That means […]
The Intent of ?ver=1.0.0
Why does WordPress append the ?ver= whatever your version number is? Why does it ask us to provide a version number when we enqueue? Why? What is the intent of versioning? Answer: It’s for cache busting. Why? Browsers cache when you view the web page. It holds a local version in its cache. If the URL doesn’t change, then the browser will pull from its local cache. That means the viewer will NOT see your changes. Whoopsie. Appending the version number of the asset to its static URL changes the URL. That’s why WordPress handles it for you. But you […]
What is a URL Query String?
In this episode, let’s talk about what a query string is. Makes sense, right? You first need to understand the URL and those additional parts of information. Then we can move forward.
Forget Hard Coding Version Number
In this episode, you’ll build an automatic way to set the theme’s version number. These strategies eliminate the need to hard code the theme’s version number. Let’s start with the Twenty Seventeen theme. I want to show you that these techniques work on any theme. Then in the next episode, we’ll move it over to a Genesis-powered child theme. For strategy 1, when you are in development/debug mode, we want to use the file’s modification time instead of having to change the asset’s released version number.
Lab Introduction
Assets are the stylesheets, scripts, images, fonts, etc. that are on the website’s hard drive (i.e. web host’s hard drive) that are downloaded to the browser. Versioning gives us the ability to change each asset’s static URL to ensure our changes go out to the browser (bust through cache). In this hands-on coding lab, you will be learning better techniques and strategies for automating your asset versioning in WordPress. No more hard coding the version number when you enqueue. This is a lab that everyone needs regardless of skill level. Whether you are an implementer or advanced developer, this one […]
Plan out the Shortcodes
It’s time for you and me to think about how to make the shortcodes reusable. Let’s put our three shortcodes up side-by-side and identify what each has in common. We are looking for patterns, those clues to identify reusable opportunities.
Specify Certain Labels Option
What if someone needs to specify some of the labels, but s/he wants the remaining ones to be generated? Hmmmm, that’s an interesting notion. It seems like a valid optional feature that someone would want from your plugin. Let’s build that feature.