There are times when you need to control the PHP output buffer. Shortcodes are a good example of when you want to capture the buffer and return it to WordPress instead of sending it out to the browser. In this hands-on lab, you will dive into the functionality available to you for the PHP output control.
In this hands-on lab, we’ll take a different approach to introduce you to the PHP output buffer. I’ll show you how to use it for typical use cases you’ll have in your projects:
- Adding more HTML to the content by using the
"the_content"
filter event. - Shortcode’s HTML
This lab comes with a companion plugin that you will install from Click here GitHub . You and I will walk through that setup process together.
What You Will Learn
- What the output buffer is
- How to turn it on
- How to get content out of the buffer and return it back
- Why you want to get the HTML out of the PHP functions and put it into a View file
- How to leverage the PHP output buffer to let you load a view file and then return it back, i.e. instead of sending it out to the browser
What You Setup to Do This lab
Make sure you have a sandbox setup on your local computer and ready to go. If you need help doing that, see this article in the Help Center.
Code. Eat. Code. Sleep. Dream about Code. Code.
Episodes
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