Lab: PHP Output Control and Buffer Basics
Video Runtime: 07:54
Let me introduce you to what you will be doing in this lab and why it matters. PHP gives you the ability to capture what you are sending out to the browser. Instead of sending it immediately out, you capture it in a buffer.
Why would you want to do that? In order to continue processing the HTML.
Some good examples are:
- Post title filter
- Content filter
For each of the above, you need to return the HTML back to WordPress, the theme, or the plugin that needs to continue processing it.
A design pattern that I often see in WordPress is assigning HTML to a variable and then building up the HTML. But that’s problematic in that it’s hard to read, debug, and extend. Often times, it’s hard to find missing closing tags. Right?
A better approach is to pull all of that HTML out of the functions and business logic, putting them into a separate view file. Then you write it as native HTML. You will do that in this lab.
There’s a time to code and …. yup, that sums it up.
Total Lab Runtime: 00:44:16
- 1 Lab Introductionfree 07:54
- 2 Setting Up the Labfree 08:24
- 3 Add HTML to Content and Return it Backpro 13:38
- 4 Shortcode View Filepro 10:04
- 5 Wrap it Uppro 04:16